我为我的小纸牌游戏的用户提供了个人资料页面,例如 这个 - 我通过查找他们的城市来显示他们的位置。我当前的jQuery代码在这里:

<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script> 
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> 
<script type="text/javascript"> 

$(function() {
    // the city name is inserted here by the PHP script
    findCity('New-York');
});

function createMap(center) {
    var opts = {
        zoom: 9,
        center: center,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    return new google.maps.Map(document.getElementById("map"), opts);
}

function findCity(city) {
    var gc = new google.maps.Geocoder();
    gc.geocode( { "address": city}, function(results, status) {
        if (status == google.maps.GeocoderStatus.OK) {
            var pos = results[0].geometry.location;
            var map = createMap(pos);
            var marker = new google.maps.Marker({
                map: map, 
                title: city,
                position: pos
            });
        }
    });
}

</script>
......
<div id="map"></div>

而且效果很好,但是我只会得到一个简单的红色标记,并显示一个点:

map with a marker

有没有请求显示用户化身而不是简单标记的方法?

我的数据库中有用于用户图片的URL(以及名称,城市等)

它们主要是大图像(大于200x300)。

有帮助吗?

解决方案

Google Maps API确实支持自定义图标,并在其文档中进行了解释 这里.

可以找到一个例子 这里

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top