Reputation: 7291
I'm changing a marker position to somewhere else in google map in runtime. It works nicely.
I also want to set the map center position to that latlon. But map becomes gray when i change the center latlon. Here is my code-
var myLatlng = new google.maps.LatLng(20.780691190209286, 80.41932580000002);
var currentMarker = myMarkers[0];
currentMarker.setPosition(myLatlng);
var center = new google.maps.LatLng(myLatlng);
myMap.setCenter(center);
google.maps.event.trigger(myMap, 'resize');
myMap.setZoom(myMap.getZoom());
Any suggestion?
Upvotes: 0
Views: 96
Reputation: 11258
This line is wrong
var center = new google.maps.LatLng(myLatlng);
LatLng()
is specified as LatLng(lat:number, lng:number, noWrap?:boolean)
so you cannot provide another latlng object to initialize it.
You can just call:
myMap.setCenter(myLatlng);
Upvotes: 2