I have a PhoneGap hybrid app developed with ArcGIS JS API 3.24 and Framework7 v1. I have a map click event that’s working in IOS, but not Android. Is there an event handler method that works for both?
map.on('click', function(evt){
code here...
});
Is he tagged here? I can't send him a message.
I tagged him already
Thanks!
Hey Levi, map click event works on Cordova 8.0.0 using ArcGIS API for JavaScript 3.24 and Android 8.1.0. That tells me it's very possible Framework 7 is introducing the problem.
Did you try using the ArcGIS API for JavaScript 4.x?
I did not. The ArcGIS JS 3.24 portions of this app were ported over from our website. Should I add a Cordova script? The iOS version of this is working like as it should and is ready to be distributed, so I can't make any major changes now.
>> Should I add a Cordova script?
From your code snippet line 12 above, I assumed you're already using Cordova?
Since we don't test the JS API with Framework7, here are some options for you:
- Try porting a simple test app to JS API 4.x and see if you have the same issue
- Deep debug this issue in Framework7
- Use something other than Framework7
Something is interfering with the map click. You could try debugging inside the Framework7 code click handlers, for example, click.js.
OK. Instead of map.on("click"), $$(document).on(“click”) seems to work on iOS and Android, but it as not as responsive as map.on("click"). Also, sometimes the ESRI basemaps don't load when I navigate to the pages. I have to go back and try again.
It's working in iOS, but I get this error in the dev console in Safari TypeError: undefined is not an object (evaluating 'b.type') in relation to this function:
$$(document).on("click", function(evt){
var mp = webMercatorUtils.webMercatorToGeographic(evt.mapPoint);
x = mp.x.toFixed(3);
y = mp.y.toFixed(3);
map.graphics.clear();
var graphic = new Graphic(evt.mapPoint);
map.graphics.add(graphic);
map.infoWindow.setFeatures([graphic]);
map.infoWindow.resize(200,200);
map.infoWindow.setContent(" Longitude: " + x.toString() + " <br>Latitude: " + y.toString());
map.infoWindow.show(evt.mapPoint)
map.infoWindow.setTitle("Forecast Reports");
});
I think it's having trouble with evt,mapPoint, but it's still generating a popup.