Closed rohi closed 10 years ago
If you've bound your center to a scope variable, all you need to do is set the variable to the new center you want (as a google.maps.LatLng object) and the map will update.
<div ng-controller="MyCtrl">
<gm-map gm-center='myCenter' ...>
<gm-markers ....></gm-markers>
</gm-map>
<button ng-click="updateCenter()"></button>
</div>
function MyCtrl($scope) {
$scope.updateCenter = function() {
$scope.myCenter = new google.maps.LatLng(newLat, newLng);
};
}
This doesn't seem to be working in 1.0: http://jsfiddle.net/znyqN/
@jraede
It works fine just a small thing to change in your jsfiddle. Change gm-zoom="zoom" to gm-zoom="options.map.zoom" so now the scopes match.
Ok cool. So then what's the point of gm-map-options if it doesn't correctly do the two-way binding? I have no problem typing "options.map" every time for the various attributes but you should make this clear in the documentation so nobody gets confused.
How do we update center of the map without redrawing the markers.