9

我知道他们是从v2到v3的一些问题,我可以在这里做些什么来解决它?
GIcon不支持v3?Google Maps API v3 - 未定义GIcon

// Google-Map icon object 
var gMapIcon = new GIcon(G_DEFAULT_ICON); //change to new google.maps.MarkerImage();??? 
// does icon exist 
if (mapElements[lMapElementIndex]['icon'].toString().length > 0) { 
    gMapIcon.image = html_entity_decode(mapElements[lMapElementIndex]['icon']); 
    gMapIcon.shadow = ""; 
    iconHeight = mapElements[lMapElementIndex]['iconheight']; 
    iconWidth = mapElements[lMapElementIndex]['iconwidth']; 
    gMapIcon.iconSize = new GSize(iconWidth,iconHeight); 
    gMapIcon.iconAnchor = new GPoint(0,0); 
    gMapIcon.infoWindowAnchor = new GPoint(15,10); 
} 
    var markerOptions = { 
     icon: gMapIcon //change to image? 
    }; 
    var marker = new google.maps.Marker(point,markerOptions); 

从这里https://developers.google.com/maps/documentation/javascript/overlays?hl=de-DE#SimpleIcons

感谢任何帮助或提示找到了!

回答

13

GIcon不受版本3的支持,并且不会出现在您链接到的文档中。

var image = 'beachflag.png'; 
    var myLatLng = new google.maps.LatLng(-33.890542, 151.274856); 
    var beachMarker = new google.maps.Marker({ 
     position: myLatLng, 
     map: map, 
     icon: image 
    }); 

您可以指定要直接使用图像,你不需要辅助对象就像第2版的GIcon。但是,如果你想非标准尺寸等,您将需要使用MarkerImage对象为在https://developers.google.com/maps/documentation/javascript/overlays?hl=de-DE#ComplexIcons

的文档中描述(第2版的GIcon有其等同于第3版可选MarkerImage