Google Maps API v3 - GIcon未定义 [英] Google Maps API v3 - GIcon is not defined

查看:141
本文介绍了Google Maps API v3 - GIcon未定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道他们是从v2到v3的一些问题,我可以在这里做些什么来解决它?

GIcon不被v3支持?

  // Google-Map图标对象
var gMapIcon =新的GIcon(G_DEFAULT_ICON); //改为新的google.maps.MarkerImage(); ??? (mapElements [lMapElementIndex] ['icon']。toString()。length> 0){
gMapIcon.image = html_entity_decode(mapElements [lMapElementIndex] [ '图标']);
gMapIcon.shadow =;
iconHeight = mapElements [lMapElementIndex] ['iconheight'];
iconWidth = mapElements [lMapElementIndex] ['iconwidth'];
gMapIcon.iconSize =新的GSize(iconWidth,iconHeight);
gMapIcon.iconAnchor = new GPoint(0,0);
gMapIcon.infoWindowAnchor = new GPoint(15,10);
}
var markerOptions = {
icon:gMapIcon //变成图片吗?
};
var marker = new google.maps.Marker(point,markerOptions);

在此处找到https://developers.google.com/maps/documentation/javascript/overlays?hl=de-DE#SimpleIcons



感谢您提供任何帮助或提示!

解决方案

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 具有相同的功能。

code>在版本3中)


I know they are some issues from v2 to v3 what can i do here to fix it?
GIcon is not supported by 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);

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

thanks for any help or tips!

解决方案

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

  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's GIcon has its equivalent as the optional MarkerImage in Version 3)

这篇关于Google Maps API v3 - GIcon未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆