Google Maps API v3 - 未定义GIcon

时间:2021-11-21 19:52:29

I know they are some issues from v2 to v3 what can i do here to fix it?
GIcon is not supported by v3?

我知道他们是从v2到v3的一些问题我在这里可以做些什么来修复它? 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);

found from here https://developers.google.com/maps/documentation/javascript/overlays?hl=de-DE#SimpleIcons

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

thanks for any help or tips!

感谢您的帮助或提示!

1 个解决方案

#1


13  

GIcon is not supported by Version 3, and does not appear in the documentation you link to.

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

  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
  });

You can specify an image to use directly, you don't need a helper object like Version 2's GIcon. However, if you want non-standard sizes etc you will need to use a MarkerImage object as described in the documentation at https://developers.google.com/maps/documentation/javascript/overlays?hl=de-DE#ComplexIcons

您可以指定要直接使用的图像,不需要像Version 2的GIcon那样的辅助对象。但是,如果您需要非标准尺寸等,则需要使用MarkerImage对象,如https://developers.google.com/maps/documentation/javascript/overlays?hl=de-DE#ComplexIcons中的文档所述

(Version 2's GIcon has its equivalent as the optional MarkerImage in Version 3)

(版本2的GIcon与版本3中的可选MarkerImage等效)

#1


13  

GIcon is not supported by Version 3, and does not appear in the documentation you link to.

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

  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
  });

You can specify an image to use directly, you don't need a helper object like Version 2's GIcon. However, if you want non-standard sizes etc you will need to use a MarkerImage object as described in the documentation at https://developers.google.com/maps/documentation/javascript/overlays?hl=de-DE#ComplexIcons

您可以指定要直接使用的图像,不需要像Version 2的GIcon那样的辅助对象。但是,如果您需要非标准尺寸等,则需要使用MarkerImage对象,如https://developers.google.com/maps/documentation/javascript/overlays?hl=de-DE#ComplexIcons中的文档所述

(Version 2's GIcon has its equivalent as the optional MarkerImage in Version 3)

(版本2的GIcon与版本3中的可选MarkerImage等效)