Click event in AngularJs Google Maps

I am using http://angular-ui.imtqy.com/angular-google-maps and I cannot catch the event of a simple click on the map.

I tried like this:

_scope.map = {
    center: { latitude: position.coords.latitude, longitude: position.coords.longitude },
    zoom: 16,
    events: {
       click: function(mapModel, eventName, originalEventArgs) {
            console.log("user defined event: " + eventName, mapModel, originalEventArgs);
            var e = originalEventArgs[0];
            _scope.$apply();
       }
    }
};

<ui-gmap-google-map center="map.center" zoom="map.zoom"></ui-gmap-google-map>

I don’t work like that, and I don’t know what to do. I would like to get the coordinates of the clicked location. Thnx

+4
source share
1 answer

You did not bind the eventdirective property <ui-gmap-google-map>to a variable (associative array) map.events ... So you should do:

<ui-gmap-google-map center="map.center" events="map.events" zoom="map.zoom"></ui-gmap-google-map>
+3
source

Source: https://habr.com/ru/post/1623664/


All Articles