2

在 Google 地图上显示用户的最佳方式是什么?我需要显示头像图像 (25x25px) 和用户名以及可点击的个人资料链接。

我一直在 api 文档中搜索,但标记和覆盖选项让我感到困惑,我应该使用什么功能/选项?

谢谢你。

4

2 回答 2

4

解决方案是MarkerImage此链接将为您提供帮助。

var latlng = new google.maps.LatLng(lat, lng);
var marker = new google.maps.Marker({
    icon: new google.maps.MarkerImage('avatar.png', null, null, new google.maps.Point(13, 25)), // 13 stands for centering
    position: latlng
});
于 2012-08-06T23:16:51.750 回答
0

So as Jill-Jênn Vie said above, the image can be set by MarkerImage;

The user name can be set as a tooltip of that marker/image, it is the "title:" parameter of the marker.

Then to open user profile on click add this event for "marker":

google.maps.event.addListener(marker, 'click', function() {window.location = 'http://google.com'});

I would paste the full code but it is already modified to include many markers defined as array.

于 2012-08-07T01:25:31.237 回答