我有一个在谷歌地图上在格子和经度之间移动的代码。我想要更改标记的图标,并将地图对齐在弧度,经度和经度,经度的终点之间。请你们帮助我吗?提前致谢
这是我的代码:
<script>
var markers = [];
function initialize() {
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 4,
center: new google.maps.LatLng(<?php echo $mapdata->deplat?>,<?php echo $mapdata->deplng;?>),
mapTypeId: google.maps.MapTypeId.ROADMAP
});
var startPos = new google.maps.LatLng(<?php echo $mapdata->deplat?>,<?php echo $mapdata->deplng;?>);
var endPos = new google.maps.LatLng(<?php echo $mapdata->arrlat?>,<?php echo $mapdata->arrlng;?>);
// generate fake points for route
var pointsNo = 80;
var latDelta = (endPos.lat() - startPos.lat()) / pointsNo;
var lngDelta = (endPos.lng() - startPos.lng()) / pointsNo;
var positions = [];
for (var i = 0; i < pointsNo; i++) {
var curLat = startPos.lat() + i * latDelta;
var curLng = startPos.lng() + i * lngDelta;
positions.push(new google.maps.LatLng(curLat, curLng));
var curMarker = new google.maps.Marker({
map: map,
position: new google.maps.LatLng(curLat, curLng),
visible: false
});
markers.push(curMarker);
}
}
function displayMarker(markers, index, delay) {
if (index > 0)
markers[index - 1].setVisible(false);
else {
markers[markers.length - 1].setVisible(false);
}
markers[index].setVisible(true);
if (index < markers.length - 1) {
setTimeout(function () {
displayMarker(markers, index + 1, delay);
}, delay);
} else {
displayMarker(markers, 0, delay);
}
}
//google.maps.event.addDomListener(window, 'load', function() {
initialize();
//});
$('input[type=button]').click( function() {
var delay = 40;
displayMarker(markers, 0, delay);
});
</script>