1
votes

I am trying to get an event called on map drag or I want to get lat and lon whenever the center of the map change. I am using cordova-plugin-googlemaps which provides native api for google maps.

map.on(plugin.google.maps.event.CAMERA_CHANGE, function(latLng) {


alert("Map is dragging.\n");});

This does not work. Although events like MAP_CLICK does.

1

1 Answers

0
votes

See answer below

var mapdiv = document.getElementById('location-map');
var map = plugin.google.maps.Map.getMap(mapdiv);

var marker = map.addMarker({
    position : {
        lat : latitude,
        lng : longitude,
    },
    animation : plugin.google.maps.Animation.DROP,
    title : 'Lat : ' +latitude+ ', Lng : ' +longitude
});

marker.setDraggable(true);
marker.showInfoWindow();
marker.addEventListener(plugin.google.maps.event.MARKER_DRAG_END, function(point) {
    marker.setTitle('Lat : ' +point.lat+ ', Lng : ' +point.lng);
    marker.showInfoWindow();
});

Find more details at https://github.com/mapsplugin/cordova-plugin-googlemaps