谷歌地图标记自定义编号

Google Map Marker with custom numbering

本文关键字:自定义 编号 图标 地图 谷歌      更新时间:2023-09-26

我有一个Google Maps标记函数,可以成功地在地图上创建标记,如下所示:

 // A function to create the marker and set up the event window
  function createMarker(point,html) {
    var marker = new GMarker(point,{title:html});
    GEvent.addListener(marker, "click", function() {
      marker.openInfoWindowHtml(html);
    });
    return marker;
  }

下面是现有代码的一个小url: http://tinyurl.com/b8f9b4l

使用这个解决方案:谷歌地图:在标记中放置数字?

我已经更新了这行代码,但它没有编号。我做错了什么?

var marker = new GMarker(point,{title:html,icon:'icon: ''https://chart.googleapis.com/chart?chst=d_map_pin_letter&chld='+ (position) +'|FF776B|000000',});

icon属性只需要是url。你不需要额外的"icon:",你应该在末尾去掉额外的逗号(IE似乎在发现悬空逗号时会抛出异常)。此外,你不需要括号——但可能不会伤害任何东西。

{
title:html,
icon: 'https://chart.googleapis.com/chart?chst=d_map_pin_letter&chld=' + position +'|FF776B|000000'
}
我明白你的意思了。我不知道为什么他/她会这样做。额外的"icon:"把它搞砸了。

试试这个测试,它应该确保你在url中的变量没有任何问题。

{
title:html,
icon: 'https://chart.googleapis.com/chart?chst=d_map_pin_letter&chld=4|FF776B|000000'
}