4

I am using http://angular-ui.github.io/angular-google-maps and I am not able to catch the event of simple click on the map.

I tried it 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 doesn't work like this and I don't know what to do. I would like to be able to get the coordinates of the clicked location. Thnx

1 Answer 1

3

You didn't bind event property of <ui-gmap-google-map> directive to the 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>
Sign up to request clarification or add additional context in comments.

1 Comment

I have a working implementation in my web app (angularJS + TypeScript). but the same code doesn't work on a cordova Ionic v1 app. setting up the map, adding markers etc. all work fine, except for map events. they don't even fire up. any ideas?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.