Reputation: 47
I am taking NorthEast coordinates with the following code. But how can I show this lat0 coordinate in the marker function. Can you help me?
google.maps.event.addListener($scope.map, 'idle', function(event){
var lat0 = $scope.map.getBounds().getNorthEast().lat();
var lng0 = $scope.map.getBounds().getNorthEast().lng();
var lat1 = $scope.map.getBounds().getSouthWest().lat();
var lng1 = $scope.map.getBounds().getSouthWest().lng();
});
this is working well but how to show lat0 in marker funtion
var createMarker = function (info) {
var marker = new google.maps.Marker({
map: $scope.map,
position: new google.maps.LatLng(info.lat, info.lng),
title: info.prop_Name,
animation: google.maps.Animation.DROP,
lat0 : **lat0** ?? notworking ??
});
}
note: info.lat0 not working
Upvotes: 1
Views: 60
Reputation: 513
The variables are not updated with the digest cycle.
Use apply on your scope and it works great.
google.maps.event.addListener($scope.map, 'idle', function
$scope.test = $scope.map.getBounds().getNorthEast().lat();
$scope.$apply();
});
Template:
Lat0: {{test}}
I just made tests, I let you use it as you want with your markers.
Upvotes: 2