我正在我的网页上实施谷歌地图。点击index.php中的更新按钮后,我显示一个对话框,其中包含谷歌地图供用户查找其位置。地图显示不正确。请帮帮我!
我的js:
> [2,4,6,8,10,12,14,16,18,20]
HTML
if(!window.google||!window.google.maps){
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = 'https://maps.googleapis.com/maps/api/js?v=3&' +
'callback=initialize';
document.body.appendChild(script);
}
else{
initialize();
}
<script>
var directionsDisplay,
directionsService,
map;
function initialize() {
var directionsService = new google.maps.DirectionsService();
directionsDisplay = new google.maps.DirectionsRenderer();
var chicago = new google.maps.LatLng(51.508742,-0.120850);
var mapOptions = { zoom:3, mapTypeId: google.maps.MapTypeId.ROADMAP, center: chicago }
map = new google.maps.Map(document.getElementById("googlemap"), mapOptions);
var marker=new google.maps.Marker({
position:chicago,
});
directionsDisplay.setMap(map);
}