Google Maps Api 添加标签
我正在使用以下函数从 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用 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 将呈现为
和 http://chart.apis.google.com/chart?chst =d_map_pin_letter&chld=2|FF0000|000000 将为您提供
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
and http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld=2|FF0000|000000 will get you
您可以制作自己的标记图标,并将其应用到您的地图上,请参阅
执行以下操作:(
您为每个标记制作了一个名为 icon1.png 到 icon6.png 的图标并放置在目录中)
也适用多个信息窗口,您可能需要创建一个新的全局函数 addinfowindow() ,其中包含全局定义的 infowindow (请参阅 此处)。
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:
(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).