ArcGIS JavaScript API 3.9 - mouse-drag events don´t work in Internet Explorer 11

走远了吗. 提交于 2019-12-07 12:18:32

问题


I am facing a problem with mouse-drag event form ArcGIS API for JavaScript 3.9 in Internet Explorer 11 The code is below:

map.on("mouse-drag", zobraudalost);

function zobraudalost() {
    alert("test");
}

The problem is that, this event doesn´t fire at IE 11 (as well as mouse-drag-start, mouse-drag-end). But on the other browsers it works fine (IE9, Firefox, Chrome). The other problem is that other mouse events (click, mouse-move, etc) work fine on IE 11, so the problem is only with the mouse-drags.

Have ever you seen such problem? Do you know if there is some security settings in IE 11 which disable mouse drag events?

Thank you very much.


回答1:


Well, This issue was related to ArcGis JS API version.

I simply updated the API 3.9 to 3.16 and its started working in IE too.

Here is the running fiddler link to verify.

Fiddler : https://jsfiddle.net/vikash2402/j6h00uyt/1/

I verified in IE11, chrome and firefox.

var map;

require(["esri/map", "dojo/domReady!"], function(Map) {
    map = new Map("map", {
        basemap: "topo",
        center: [-122.45, 37.75], // longitude, latitude
        zoom: 13
    });
    
    map.on("mouse-drag", drag);
    
    function drag() {
        alert("mouse-drag");
    }
});
html, body, #map {
    height: 100%;
    width: 100%;
    margin: 0;
    padding: 0;
}
<link href="https://js.arcgis.com/3.16/esri/css/esri.css" rel="stylesheet"/>
<script src="https://js.arcgis.com/3.16/init.js"></script>


<body>
    <div id="map"></div>
</body>

Hoping this will help you :)




回答2:


I had similar problems attempting to catch mouseup in IE11. Here is the solution I found that worked:

Changed for the drag event you probably want.

if(window.PointerEvent) {
  elm.addEventListener("pointermove", foo);
} else if (window.MSPointerEvent) {
  elm.addEventListener("MSPointerMove", foo);
} else {
  elm.addEventListener("mousemove", foo);
}

Not your exact solution, but a combination of the above should do it.



来源:https://stackoverflow.com/questions/23672908/arcgis-javascript-api-3-9-mouse-drag-events-don%c2%b4t-work-in-internet-explorer-11

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!