Internet explorer Internet Explorer+;Windows8触摸屏问题
我们遇到了一个与谷歌地图API V3相关的问题。问题是,当我们拖动标记时,地图也开始拖动 我们只在Windows 8环境+Internet Explorer的触摸屏上遇到这个问题,在普通屏幕/移动屏幕-IPaid/其他浏览器(Safari和FireFox)上没有问题 我们使用了下面的解决方案,但它在Internet Explorer 9和10中抛出错误(Internet explorer Internet Explorer+;Windows8触摸屏问题,internet-explorer,google-maps,google-maps-api-3,windows-8,touchscreen,Internet Explorer,Google Maps,Google Maps Api 3,Windows 8,Touchscreen,我们遇到了一个与谷歌地图API V3相关的问题。问题是,当我们拖动标记时,地图也开始拖动 我们只在Windows 8环境+Internet Explorer的触摸屏上遇到这个问题,在普通屏幕/移动屏幕-IPaid/其他浏览器(Safari和FireFox)上没有问题 我们使用了下面的解决方案,但它在Internet Explorer 9和10中抛出错误(eval javascript error): google.maps.event.addListener(marker, 'dragstart
eval javascript error
):
google.maps.event.addListener(marker, 'dragstart', function(){
mapObject.setOptions({ draggable: false });
});
google.maps.event.addListener(marker, 'dragend', function(){
mapObject.setOptions({ draggable: true });
});
我们也在这里报道了这个问题:
编辑:
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 });
}
});
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);
}
});
我们在这里也发布了一个帖子。终于取得了一些成功。(地图仍在移动,但目前可以忽略) 声明了两个变量:
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 });
}
});
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);
}
});
拖动标记时:
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 });
}
});
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);
}
});
放下标记时(拖动结束):
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 });
}
});
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);
}
});
地图拖动开始时:
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 });
}
});
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);
}
});
地图处于拖动状态时:
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 });
}
});
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);
}
});