【问题标题】:Custom google maps marker with user image inside the pin带有用户图像的自定义谷歌地图标记在图钉内
【发布时间】:2016-06-28 01:28:53
【问题描述】:

我正在尝试在地图上显示用户,我已经在应用程序中实现了地图,但现在我正在尝试制作自定义标记,在图钉内显示用户的照片,如下所示:Custom markers,如何我能做到吗?

澄清一下,我要做的是在标记图标位图中显示位图

【问题讨论】:

标签: android google-maps google-maps-markers


【解决方案1】:

您可以定义一个图标来显示而不是默认标记图像。定义一个图标涉及设置一些属性,这些属性决定了标记的视觉行为。下面的代码应该可以解决问题。

function initMap() {
  var map = new google.maps.Map(document.getElementById('map'), {
    zoom: 4,
    center: {lat: -33, lng: 151}
  });

  var image = 'filePath' + 'usersPhoto.png';
  var beachMarker = new google.maps.Marker({
    position: {lat: -33.890, lng: 151.274},
    map: map,
    icon: image
  });
}

查看 Google Maps API 了解详情https://developers.google.com/maps/documentation/javascript/examples/icon-simple#try-it-yourself

【讨论】:

  • 我没有使用 javascript,我知道如何更改图标,我需要一种将用户图像放入 pin 的方法,就像我提到的示例一样。还是谢谢
猜你喜欢
  • 1970-01-01
  • 2011-10-09
  • 2016-09-20
  • 1970-01-01
  • 2014-12-21
  • 1970-01-01
  • 2013-05-20
  • 2015-01-28
  • 2014-07-18
相关资源
最近更新 更多