Get location (Latlng) of google map with click event

I need to place a new marker where ever I click. According to the Google map API documentation, I did following.

Template.googleMap.events({

'click .map-canvas': function(event){
    var marker = new google.maps.Marker({
        position: event.latLng(),
        map: map
    });
}

});

But following error occurs.
“Uncaught TypeError: event.latLng is not a function”

You need to use google.maps.event.addListener instead of the Meteor events

google.maps.event.addListener(map_canvas.map, 'click', function(event) {
    console.log(event.latLng.toString());
});
1 Like

Thanks, it worked with some modifications.