I want to fire dragend event of a marker in another event say click event on the map. how can I do that?
google.maps.event.addListener(map,'click',function(pt){ posSelectMarker.setPosition(pt.latLng); //Here I want to fire dragend event. });
To add an event, head to Google Maps on Android, tap on Contribute >Events > Add a public event. You can add an event name, tag the location, and add the time and date of the event as well. There's an option to add an image, write more event details, and add description as well.
Add different color markerspng at the end of the URL to get a blue marker. To add a green marker simply change it to green-dot. png so that the URL will be http://maps.google.com/mapfiles/ms/icons/green-dot.png .
You can allow users to move a marker on the map by setting the marker's draggable property to true . For more information about draggable markers, see below.
To reload the markers, when you create then, push them to an array. Then create a function where you iterate through the array, setting the markers map as null. After this, erase the array.
Use event.trigger
;
google.maps.event.trigger(markerObject, 'dragend', args);
This is a bit more complete:
theListener = google.maps.event.addListener(posSelectMarker,'dragend',function(event){
console.log(event.latLng);
});
Note that you can get at the object with the event param
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With