【问题标题】:Change Google Maps Icon Marker Hue Color with Error: "Uncaught ReferenceError: BitmapDescriptorFactory is not defined"更改 Google 地图图标标记色调颜色并出现错误:“未捕获的 ReferenceError:未定义 BitmapDescriptorFactory”
【发布时间】:2017-07-10 01:48:22
【问题描述】:

我已经检查了 Internet 的各个角落是否存在此错误“未捕获的 ReferenceError:BitmapDescriptorFactory 未定义”。我能找到的最接近的网站是有完全相同问题但没有答案的人。见here

有很多使用 BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE) 示例创建标记的示例,但我没有以相同的方式创建标记。

这是我的代码产生上述错误的样子。

var marker = new google.maps.Marker({
  position: new google.maps.LatLng(45.09342894,-36.9823909),
  map: map,
  visible: true,
  animation: google.maps.Animation.DROP,
  //icon: 'http://maps.google.com/mapfiles/ms/icons/red-dot.png',
  icon: BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE),
});

我知道我可以使用注释掉的行,但我想要默认的 google 图标,因为 png 图像的质量不太好。

谁能指导我如何在我正在使用的方法中实现这一点,或者如何将此方法转化为可行的方法?

谢谢!

【问题讨论】:

  • 您知道如何在网络上执行此操作吗?

标签: javascript google-maps google-maps-api-3 google-maps-markers


【解决方案1】:

这不是 javascript 中的选项,如果您正在为 Android 开发,可以使用 BitmapDescriptionFactory 类,请参阅此处的指南:

https://developers.google.com/maps/documentation/android-api/marker#customize_the_marker_color

【讨论】:

    猜你喜欢
    • 2019-09-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-22
    • 1970-01-01
    • 2011-01-29
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多