I have the following function which takes the zoom level. However when I call the setCenter with my positional coords + zoom the map doesn't zoom in where I want to. The position of my info window is correct though. Here is the function:
function gotoLocation (longitude, latitude, zoom, isDefault) {
var position = new google.maps.LatLng(latitude, longitude);
window.refPointMarker.setPosition(position);
var info;
if (isDefault == true) {
info = "<p style='font-weight:bold; font-size:12;'>Default reference point.</p>";
info += "<p style='font-size:12;'> Click on the map to select a new location. </p>";
}
else {
info = "<p style='font-weight:bold; font-size:12;'>Current reference point.</p>";
info += "<p style='font-size:12;'> Click on the map to select a new location. </p>";
}
if (window.infoWindow) window.infoWindow.close();
window.infoWindow = new google.maps.InfoWindow({
content: info,
position: position,
anchor: window.refPointMarker
});
window.map.setCenter(position, zoom);
}
Any idea what am I doing wrong here please?
Use the setZoom function to set your zoom instead of setCenter.
var foo = 5;
window.map.setZoom(foo);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.