我按照这个例子来做这个教程。以下是链接:(https://developers.google.com/maps/documentation/javascript/examples/marker-animations-iteration)
我有4个地方及其纬度和经度:
- >威斯敏斯特大桥[51.5018457,-0.1225088]
- >大本钟[51.5031154,-0.1207032]
- >伦敦眼[51.503773,-0.1224413]
- >亨格福德桥和金禧桥[51.503773,-0.1224413]
这是我写的代码:
<!DOCTYPE html>
<html>
<head>
<script src="http://maps.googleapis.com/maps/api/js"></script>
<script>
var myCenter = new google.maps.LatLng(51.508742, -0.120850);
var neighborhoods = [
new google.maps.LatLng(51.504728,-0.1216795),
new google.maps.LatLng(51.5031154,-0.1207032),
new google.maps.LatLng(51.5018457,-0.1225088),
new google.maps.LatLng(51.503773,-0.1224413)
];
var markers = [];
var map;
function initialize()
{
var mapProp =
{
center: myCenter,
zoom: 16,
mapTypeId : google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById('googleMap'), mapProp);
}
function drop()
{
clearMarkers();
for (var i = 0; i < neighborhoods.length; i++)
{
addMarkerWithTimeout(neighborhoods[i], i * 200);
}
}
function clearMarkers()
{
for (var i = 0; i < markers.length; i++)
{
markers[i].setMap(null);
}
markers = [];
}
function addMarkerWithTimeout(position, timeout)
{
window.setTimeout(function()
{
markers.push(new google.maps.Marker
({
position: position,
map: map,
animation: google.maps.Animation.DROP
}));
}, timeout);
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body>
<div id="panel">
<button id="drop" onclick="drop()">Drop Markers</button>
</div>
<div id="googleMap" style="width:800px;height:600px;"></div>
</body>
</html>
答案 0 :(得分:1)
您的值有误,请参阅地图以获取示例https://www.google.com/maps/place/51%C2%B030'17.0%22N+0%C2%B007'18.1%22W/@51.504728,-0.1216795,17z/data=!3m1!4b1!4m2!3m1!1s0x0:0x0
我不知道你想要指出的是什么,但它正指向你正在问的地方。