document.dojoClick = falseafter dojox/mobile modules are loaded.
<!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;
if ((Object.prototype.toString.call(evt).slice(8, -1) == 'MouseEvent') && isMobile || (Object.prototype.toString.call(evt).slice(8, -1) == 'Object' && !isMobile))
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
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. } }