0

我有一个谷歌地图标记功能,可以成功地在这样的地图上创建标记:

 // 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;
  }

这是现有代码的 tinyurl: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',});
4

1 回答 1

1

icon 属性只需要是 url。您不需要额外的“图标:”,并且应该在末尾删除额外的逗号(IE 在发现悬空逗号时似乎会抛出异常)。此外,您不需要的括号 - 但可能不会伤害任何东西。

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

我明白你的想法是从哪里来的。不知道为什么她/他对此有所了解。额外的“图标:”搞砸了。

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

{
title:html,
icon: 'https://chart.googleapis.com/chart?chst=d_map_pin_letter&chld=4|FF776B|000000'
}
于 2013-04-24T19:13:54.030 回答