angular-google-maps icon indicating copy to clipboard operation
angular-google-maps copied to clipboard

CLICK EVENT NOT WORKING ON ANGULAR GOOGLE MAPS

Open ankitairen opened this issue 8 years ago • 2 comments

VIEW

{{content}}

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

ankitairen avatar Dec 21 '16 06:12 ankitairen

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 avatar Dec 21 '16 13:12 marcio199226

@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

markmssd avatar Dec 21 '16 15:12 markmssd