谷歌地图API V3 - 没有定义GICON(Google Maps API v3 - GIcon

2019-07-29 18:00发布

我知道他们是从V2一些问题V3我能在这里做来解决它?
GICON不v3上支持?

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

感谢您的帮助或提示!

Answer 1:

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具有其等效作为任选MarkerImage版本3)



文章来源: Google Maps API v3 - GIcon is not defined