Angular-google-maps getting the geo location with the mouse

I am using the angular -google-maps library from http://angular-google-maps.org/ . I can get the most to work. What I am currently banging my head on is to make the "click" event work on the map to give me the location of the GEO where I clicked. Currently, he does not even register, that I click on the card.

Here are my partial ones:

<google-map 
    center="map.center"
    zoom="map.zoom"
    draggable='true'
    >


</google-map>

and here is the controller:

    // Create Map
    $scope.map = {
        center: {
            latitude: 40.296755,
            longitude: -111.696415
        },
        zoom: 13,
        events: {
            click: function (mapModel, eventName, originalEventArgs) {
                alert("hola?");
            }
        }

    };

Any help would be fantastic!

+4
source share
1 answer

To add an event to the map, you need to associate an associative array (object) with the events attribute of the directive:

<google-map events="$scope.events" .... ></google-map>

:

$scope.events = {"click" : function () { console.log('woo-hoo') })
+4

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


All Articles