I am currently working on an application that utilizes the Gmaps API for geolocalization. One of the challenges I faced was adding new markers based on user events. To address this, I created a service that listens to map events and adds markers when clicked. However, I encountered difficulty in modifying certain $scope properties within this service. Below is an example of the service I have developed:
climbingApp.factory('Markers', function(){
return {
addListener: function() {
google.maps.event.addListener(
map,
'click',
function( e ) {
var marker = new google.maps.Marker({
position: e.latLng,
map: map
});
}
);
}
}
});
I am seeking guidance on how to retrieve the value of e.latLng and use it to update a specific $scope property. Any advice would be greatly appreciated.