我在我的一个页面中添加了一张地图,但内容与容器不一致,我在独立页面中尝试了相同的地图,它工作正常。
地图呈现如下:在此处输入链接描述
该地图实际上以伦敦为中心,因此看起来像和对齐问题,但我无法修复它。这是创建地图的函数:
function loadMap(){
geocoder = new google.maps.Geocoder();
var address = document.getElementById('address').value;
geocoder.geocode( { 'address': address}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
thisLocation = results[0].geometry.location;
console.log("location = " + thisLocation);
var tagem = new google.maps.LatLng(thisLocation);
var mapProp = {
center:new google.maps.LatLng(51.51121389999999, -0.11982439999997041),
zoom:5,
mapTypeId:google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("googleMap"),mapProp);
marker = new google.maps.Marker({position:tagem,animation:google.maps.Animation.BOUNCE});
marker.setMap(map);
}else{
console.log('Geocode was not successful for the following reason: ' + status);
}
});
}
任何帮助,将不胜感激。