我们正经历着与谷歌地图API V3的问题。 问题是,当我们拖动标记在地图上也开始拖动。
我们正在经历只在Windows 8的环境+ IE浏览器 ,其在标准屏幕/移动屏幕精细触摸屏这个问题 - IPaid /其他浏览器(Safari和Firefox)。
我们用下面的解决方案,但它会抛出错误( eval javascript error
在Internet Explorer9和10):
google.maps.event.addListener(marker, 'dragstart', function(){
mapObject.setOptions({ draggable: false });
});
google.maps.event.addListener(marker, 'dragend', function(){
mapObject.setOptions({ draggable: true });
});
示例代码是在这里 。
我们还报道这个问题在这里: gmaps-API问题
编辑:
我们有一个公布了相关的问题在这里也。
有些成功的在最后 (地图还是移动了一点,但可以在瞬间被忽略)!
声明两个变量:
var isAnyMarkerIsInDraggingState = false;// if a marker is in drag state this value will be TRUE otherwise FALSE
var mapCenterPositionAtTheTimeWhenMarkerWasDragged;// Map Center Position
当标记被拖动:
google.maps.event.addListener(objMarker, 'dragstart', function () {
// Store map center position when a marker is dragged
mapCenterPositionAtTheTimeWhenMarkerWasDragged = mapObject.getCenter();
isAnyMarkerIsInDraggingState = true;
});
当标记被丢弃(拖动结束):
google.maps.event.addListener(objMarker, 'dragend', function () {
// Make Map draggable
// Set isAnyMarkerIsInDraggingState = false. Because no marker is in drag state
mapObject.setOptions({ draggable: true });
isAnyMarkerIsInDraggingState = false;
});
当拖动地图开始:
google.maps.event.addListener(mapObject, 'dragstart', function () {
// isAnyMarkerIsInDraggingState = true: means the user is dragging a marker.
// If the user is dragging the Marker then don't allow the Map to be Dragged
if (isAnyMarkerIsInDraggingState) {
mapObject.setOptions({ draggable: false });
}
});
当MAP在拖动状态:
google.maps.event.addListener(mapObject, 'drag', function () {
// isAnyMarkerIsInDraggingState = true: means the user is dragging a marker.
// If the user is dragging the Marker then don't allow the Map to be Dragged and set its CenterPosition
// to mapCenterPositionAtTheTimeWhenMarkerWasDragged
if (isAnyMarkerIsInDraggingState) {
mapObject.setCenter(mapCenterPositionAtTheTimeWhenMarkerWasDragged);
}
});
完整的示例代码是在这里 。