angular-google-maps
angular-google-maps copied to clipboard
CLICK EVENT NOT WORKING ON ANGULAR GOOGLE MAPS
VIEW
CONTROLLER
$scope.map["events"]={ click:function(map,eventName,originalEventArgs){ alert(" map event"); }; }; $scope.map.marker["events"]={ click:function(marker,eventName,model){ alert("marker event"); } };
TRIED
$scope.map["events"]={ click:function(map,eventName,originalEventArgs){ $scope.$apply(function(){ alert(" map event"); }); }; }; $scope.map.marker["events"]={ click:function(marker,eventName,model){ alert("marker event"); } }; NOTE :- marker events are working perfectly fine , but map events are not even getting triggered , I have tried applying $scope.$apply but no success , any help on this would be highly appreciated. Angular maps version used :- 2.X
Hi i have encountered the same behaviour you have to bind manually all necessary events for map, you should do it in this way:
uiGmapIsReady.promise(1).then(function(instances) {
var mapInstance = instances[0].map;
google.maps.event.addListener(mapInstance, 'zoom_changed', function() {
});
google.maps.event.addListener(mapInstance, 'dragend', function() {
});
google.maps.event.addListener(mapInstance, 'idle', function() {
});
});
@marcio199226 Although your solution works, this is not the "angular-google-maps" way of doing it.
Referring to its doc here: http://angular-ui.github.io/angular-google-maps/#!/api/google-map,
the <ui-gmap-google-map>
directive takes an event object