When I initialize google maps in my app, I do something like this:
var myOptions = {
center: new google.maps.LatLng(39.729001, -94.902342),
zoom: 3,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map"), myOptions);
setUpMarker(map);
Which works, however, I would need to set up the center of the map and zoom for the specific marker that is created by the function setUpMarker
.
I've tried inside the setUpMarker
function to do this:
fromMarker = new google.maps.Marker({
center: fromLatlng,
zoom: 5,
map: map,
title: "Here"
});
But it didn't help. Thus, how do achieve of this effect?
Thank you guys for help.
The map object has setZoom() and setCenter() functions for the same. Refer to:
https://developers.google.com/maps/documentation/javascript/events#MarkerEvents
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.