如何更改谷歌地图标记并在我的网站中添加两个标记。
目前我正在使用以下代码:
function init_map(lat,lng,ZmLevel) {
var myOptions = {
zoom:ZmLevel,center:new google.maps.LatLng(lat,lng),
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById('gmap_canvas'), myOptions);
<?php
$sql = "select * from locator_areas where cid=$city";
$res = mysql_query($sql);
while($row=mysql_fetch_assoc($res)) {
?>
marker = new google.maps.Marker({map: map,position: new google.maps.LatLng(<?php echo $row['latitude']; ?>,<?php echo $row['longitude']; ?>)});
infowindow = new google.maps.InfoWindow({
content:'<div style="color:#000000;"><?php echo str_replace("\'","`",$row['address']); ?></div>'
});
bindInfoWindow(marker, map, infowindow);
<?php }?>
}
function bindInfoWindow(marker, map, infowindow) {
google.maps.event.addListener(marker, 'click', function() {
infowindow.open(map,marker);
});
}
function loadCity() {
var cid = $('#city_name').val();
window.location = "?cid="+cid;
}
我想更改标记,并想为公司的某个新开业分店添加一个标记
最佳答案
要指定这样的图标,请将标记的图标属性设置为图像的 URL。 Google Maps API 会自动调整图标大小。
var marker = new google.maps.Marker({
map: map,
position: new google.maps.LatLng(<?=$row['latitude']?>,<?=$row['longitude']?>),
icon: imageURL
});
请阅读this article添加多个标记
关于javascript - 如何更改我网站中的谷歌地图标记,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35152071/