Internet Explorer + Windows8触摸屏问题 [英] Internet Explorer + Windows8 Touchscreen issues

查看:122
本文介绍了Internet Explorer + Windows8触摸屏问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们遇到与 Google Maps API V3 相关的问题。问题是,当我们拖动标记时,地图也开始拖动。



我们只在Windows 8环境+ Internet Explorer中的触摸屏上遇到这个问题,它在正常屏幕/手机屏幕 - IPaid /其他浏览器(Safari和FireFox)上很好。

我们使用下面的解决方案,但它会引发错误(<$在Internet Explorer 9和10中,c $ c> 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});
});

示例代码在这里



我们在这里也报告了这个问题:
gmaps-api-issues



编辑:

我们发布了一个相关问题也在这里。 div>

在Last 处取得了一些成功(地图仍然有点动,但此时可以忽略)! 声明两个变量:

  var isAnyMarkerIsInDraggingState = false; //如果标记处于拖动状态,则此值将为TRUE否则为FALSE 
var mapCenterPositionAtTheTimeWhenMarkerWasDragged; //地图中心位置

标记被拖动时

  google.maps.event。 addListener(objMarker,'dragstart',function(){
//当拖动标记时存储地图中心位置
mapCenterPositionAtTheTimeWhenMarkerWasDragged = mapObject.getCenter();
isAnyMarkerIsInDraggingState = true;
});

标记被删除时(拖动结束):

  google.maps.event.addListener(objMarker,'dragend',function(){
//使地图可拖曳
//设置isAnyMarkerIsInDraggingState = false。因为没有标记处于拖动状态
mapObject.setOptions({draggable:true});
isAnyMarkerIsInDraggingState = false;
});

地图拖动开始时:

  google.maps.event.addListener(mapObject,'dragstart',function(){
// isAnyMarkerIsInDraggingState = true:表示用户正在拖动一个标记
//如果用户拖动标记,则不允许拖动地图
if(isAnyMarkerIsInDraggingState){
mapObject.setOptions({draggable:false});
}
});

当地图处于拖曳状态时:

  google.maps.event.addListener(mapObject,'drag',function(){
// isAnyMarkerIsInDraggingState = true:表示用户正在拖动
//如果用户拖动标记,则不允许拖动地图并将其CenterPosition
//设置为mapCenterPositionAtTheTimeWhenMarkerWasDragged

if(isAnyMarkerIsInDraggingState) {
mapObject.setCenter(mapCenterPositionAtTheTimeWhenMarkerWasDragged);
}
}); b


$ b

nofollow>完整的示例代码在这里。


We are experiencing an issue related to Google Maps API V3. The issue is that while we drag the Marker the map also starts dragging.

We are experiencing this issue ONLY on Touch Screens in Windows 8 Environment + Internet Explorer, its fine on NORMAL screens / Mobile Screens - IPaid/ other browsers (Safari and FireFox).

We used below solution, but it throws error (eval javascript error) in Internet Explorer9 and 10:

google.maps.event.addListener(marker, 'dragstart', function(){
    mapObject.setOptions({ draggable: false });
});
google.maps.event.addListener(marker, 'dragend', function(){
    mapObject.setOptions({ draggable: true });
}); 

Sample code is here.

We have also reported this issue here: gmaps-api-issues

EDIT:

We have a posted a related question here also.

解决方案

Some success At Last (the map still move a bit but can be ignored at the moment)!

Declared two variables:

var isAnyMarkerIsInDraggingState = false;// if a marker is in drag state this value will be TRUE otherwise FALSE
var mapCenterPositionAtTheTimeWhenMarkerWasDragged;// Map Center Position

When Marker is dragged:

   google.maps.event.addListener(objMarker, 'dragstart', function () {
        // Store map center position when a marker is dragged
        mapCenterPositionAtTheTimeWhenMarkerWasDragged = mapObject.getCenter();
        isAnyMarkerIsInDraggingState = true;
    });

When Marker is dropped (drag ends):

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;
});

When the Map Drag starts:

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 });
    }
});

When Map is in dragging state:

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);
    }
});

Complete sample code is here.

这篇关于Internet Explorer + Windows8触摸屏问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆