To clarify and update my situation, for me the dojoClick fix resolves the issue where the infoWindow shows in the wrong place. This fix works on all devices. (I was wrong about the Kindle) But, I am still getting the click event firing twice on Android phones. It doesn't appear to be happening on iOS or Android tablets -- just phones.
I'm definitely seeing this error on Android, using both 3.7 compact and 3.7 complete. Consequently, infoWindows are appearing in the wrong place. Using dojoClick solves the InfoWindow problem on an Android 2.3 phone, but on a Kindle Fire HD, the fix prevents any InfoWindow from showing. Any thoughts on that?.
I have been running into this fire twice problem. Can you explain where this code should be placed? Using your sample page, where would this be placed? Does it go within the map.on click event? I do understand that the isMobile variable would have to be set prior.
if ((Object.prototype.toString.call(evt).slice(8, -1) != 'MouseEvent'))
//use older connect event style dojo.connect(map, "onClick", doIdentify); function doIdentify(evt) { //on mobile devices this event will fire multiple times, Check the evt to see if one that fires contains MouseEvent...if it does, ignore it. if ((Object.prototype.toString.call(evt).slice(8, -1) != 'MouseEvent')) { //code for click goes here. } }
Also there is an issue that when you tap/click the event fires twice. One is just an object and the other is a MouseEvent. Depending on the user agent (mobile or desktop) you need to read a different object. Here is the code to short circuit the double event and listen to the appropriate event.if ((Object.prototype.toString.call(evt).slice(8, -1) == 'MouseEvent') && isMobile || (Object.prototype.toString.call(evt).slice(8, -1) == 'Object' && !isMobile))It is up to you how to detemine if "isMobile". I suggested checking user-agent
if ((Object.prototype.toString.call(evt).slice(8, -1) == 'MouseEvent') && isMobile || (Object.prototype.toString.call(evt).slice(8, -1) == 'Object' && !isMobile))
document.dojoClick = false;
<!DOCTYPE html> <html> <head> <title>test</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=7,IE=9"> <meta name="apple-mobile-web-app-capable" content="yes"> <meta name="apple-mobile-web-app-status-bar-style" content="black"> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"> <style> html, body, #mapView { height: 100%; width: 100%; margin: 0; padding: 0; } </style> <link rel="stylesheet" href="http://js.arcgis.com/3.7/js/esri/css/esri.css" /> <script src="http://js.arcgis.com/3.7/"></script> <script> var map; require([ "esri/map", "dojox/mobile/View", //"dojox/mobile/ScrollableView", "dojo/domReady!" ], function ( Map ) { map = new Map('mapDiv', { basemap: "streets", zoom: 4 }); map.on("click", function (e) { alert(e.mapPoint.x.toFixed() + ", " + e.mapPoint.y.toFixed()); }); }); </script> </head> <body> <div id="mapDiv"></div> </body> </html>
document.dojoClick = false
Přihlášení členové mohou přispívat, sledovat aktualizace a další. Jste tu noví? Zaregistrujte si bezplatný účet.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.