我需要在点击时获取标记图标 url,我在谷歌地图文档上看到有函数 getIcon() 但不知道在哪里调用它。
google.maps.event.addListener(layer, 'click', function (kmlEvent) {
alert(kmlEvent.getIcon());//Object #<Object> has no method 'getIcon'
showInContentWindow(map, kmlEvent);
});
更新:
var myOptions = {
zoom: 8,
center: null,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("kmlMapCanvas"), myOptions);
var layer = new google.maps.KmlLayer(
'https://maps.google.co.uk/maps/ms?msid=207817312541605896974.0004cdbf70e9c541de0ac&msa=0&ll=51.499019,-0.58382&spn=0.070103,0.209255&output=kml',
{
suppressInfoWindows: true,
map: map
});
google.maps.event.addListener(layer, 'click', function (kmlEvent) {
alert(kmlEvent.getIcon());//Object #<Object> has no method
showInContentWindow(map, kmlEvent);
});
我正在失去与原生标记的联系......