在下面的Javascript代码中,我放置了一个google地图,它显示了mali但我想要显示Chennai(印度)。我试过但我无法解决这个问题。所以请帮我这样做。
<script
src="http://maps.googleapis.com/maps/api/js?key=AIzaSyDY0kkJiTPVd2U7aTOAwhc9ySH6oHxOIYM&sensor=false">
</script>
<script>
var myCenter=new google.maps.LatLng(15.508742,-0.500850);
function initialize()
{
var mapProp = {
center: myCenter,
zoom:5,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("googleMap"),mapProp);
var marker = new google.maps.Marker({
position: myCenter,
title:'Click to zoom'
});
marker.setMap(map);
// Zoom to 9 when clicking on marker
google.maps.event.addListener(marker,'click',function() {
map.setZoom(9);
map.setCenter(marker.getPosition());
});
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
<div id="googleMap" style="width:500px;height:380px;"></div>
答案 0 :(得分:1)
您在此行使用的坐标:
var myCenter=new google.maps.LatLng(15.508742,-0.500850);
指向马里,只需将数字更改为印度的坐标。
对于Chennai ,请使用:
var myCenter=new google.maps.LatLng(13.052138,80.251608);