Google Maps Api 添加标签

发布于 2024-09-17 17:47:14 字数 399 浏览 3 评论 0原文

我正在使用以下函数从 XML 文件创建标记。我希望将每个市场标记为 1、2、3、4、5、6 等,其中“i”是数字。请告诉我如何合并这个。谢谢

    function createMarker(point, name, address, type, i) {
  var marker = new GMarker(point, customIcons[type]);
  var html = "<b>" + name + "</b> <br/>" + address;
  GEvent.addListener(marker, 'click', function() {
    marker.openInfoWindowHtml(html);
  });
  return marker;
}

i'm using the the following function to create my markers from a XML file. i wish to label each market 1,2,3,4,5,6 etc where 'i' is the number. can some please please tell me how to incorporate this. thank you

    function createMarker(point, name, address, type, i) {
  var marker = new GMarker(point, customIcons[type]);
  var html = "<b>" + name + "</b> <br/>" + address;
  GEvent.addListener(marker, 'click', function() {
    marker.openInfoWindowHtml(html);
  });
  return marker;
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

≈。彩虹 2024-09-24 17:47:14

您可以使用 Google 的图表服务器创建动态图标,并将其设置为标记图像。

有关使用动态图标的图表服务器文档:http://code.google。 com/apis/chart/docs/gallery/dynamic_icons.html

例如,
http://chart.apis.google.com/ Chart?chst=d_map_pin_letter&chld=1|FF0000|000000 将呈现为 alt text

http://chart.apis.google.com/chart?chst =d_map_pin_letter&chld=2|FF0000|000000 将为您提供 alt text

You can use Google's Chart server to create dynamic icons, and set that as your marker image.

Chart server docs on using dynamic icons: http://code.google.com/apis/chart/docs/gallery/dynamic_icons.html

For example,
http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld=1|FF0000|000000 will render as alt text

and http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld=2|FF0000|000000 will get you alt text

压抑⊿情绪 2024-09-24 17:47:14

您可以制作自己的标记图标,并将其应用到您的地图上,请参阅

执行以下操作:(

 function createMarker(point, name, address, i) {
  var image = "icon" + i + ".png";
  var html = "<b>" + name + "</b> <br/>" + address;
  var marker = new google.maps.Marker({
    position: point,
    map: map,
    icon: image,
    title: name
  });
  addinfowindow(marker, html);
  return marker;
}

您为每个标记制作了一个名为 icon1.png 到 icon6.png 的图标并放置在目录中)

也适用多个信息窗口,您可能需要创建一个新的全局函数 addinfowindow() ,其中包含全局定义的 infowindow (请参阅 此处)。

function addwindow(pmarker, phtml){


  google.maps.event.addListener(pmarker, 'click', function() {
    infowindow.setContent(phtml);
    infowindow.open(map, pmarker);
  });

}

You can make your own Marker icons, and implement them onto your map, see here
(It might be best to use the current Google Maps API v3 if you aren't already)

Do something like:

 function createMarker(point, name, address, i) {
  var image = "icon" + i + ".png";
  var html = "<b>" + name + "</b> <br/>" + address;
  var marker = new google.maps.Marker({
    position: point,
    map: map,
    icon: image,
    title: name
  });
  addinfowindow(marker, html);
  return marker;
}

(where you have made an icon for each marker called icon1.png to icon6.png and placed in the directory)

Also for multiple info windows you may need to create a new global function addinfowindow() with a infowindow defined globally (see here).

function addwindow(pmarker, phtml){


  google.maps.event.addListener(pmarker, 'click', function() {
    infowindow.setContent(phtml);
    infowindow.open(map, pmarker);
  });

}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文