From Angular-Google Map perspective using a controller how can i get the (longitude and latitude) center of the current map if like say my controller looks like this:
$scope.map = {
center: {
latitude: $scope.latitude,
longitude: $scope.longitude
},
zoom: 7,
bounds: {},
control: {},
};
var map = self.map.control.getGMap();
var maps = google.maps;
this.registerMap = function (myMap) {
var center = myMap.getCenter(),
latitude = center.lat(),
longitude = center.lng();
map = myMap;
$scope.latitude = latitude;
$scope.longitude = longitude;
$log.info(latitude+" "+longitude);
return;
};
$scope.$watch('$scope.map.center', function (newValue, oldValue) {
if (newValue !== oldValue) {
$log.info("value change");
var center = map.getCenter(),
latitude = center.lat(),
longitude = center.lng();
if ($scope.latitude !== latitude || $scope.longitude !== longitude)
map.setCenter(new google.maps.LatLng($scope.latitude, $scope.longitude));
}
});
As i saw at these nice tutorial http://wbyoko.co/angularjs/angularjs-google-maps-components.html and http://dylanfprice.github.io/angular-gm/1.0.0/examples/#!/map/
but these wont work on angular google map cause of different library and approach