gpt4 book ai didi

javascript - 谷歌地图 Javascript : adding user photo to a marker

转载 作者:行者123 更新时间:2023-11-29 15:50:43 24 4
gpt4 key购买 nike

我有我的小纸牌游戏用户的个人资料页面,例如 this one - 我通过查找他们的城市来显示他们的位置。我当前的 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 map API 确实支持自定义图标,并在其文档中进行了解释 here .

可以找到一个例子here

关于javascript - 谷歌地图 Javascript : adding user photo to a marker,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5819310/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com