我正在尝试获取一个在 map 拖动时调用的事件,或者我想在 map 中心发生变化时获取纬度和经度。我正在使用 cordova-plugin-googlemaps 它为谷歌地图提供 native API。
map.on(plugin.google.maps.event.CAMERA_CHANGE, function(latLng) {
alert("Map is dragging.\n");});
这不起作用。尽管像 MAP_CLICK 这样的事件确实如此。
最佳答案
请参阅下面的答案
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();
});
欲了解更多详情,请访问 https://github.com/mapsplugin/cordova-plugin-googlemaps
关于javascript - map 拖动事件 谷歌地图 android sdk cordova cordova-plugin-googlemaps,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40621113/