MyLocation Widget Not Accurate

5710
6
Jump to solution
10-22-2015 02:12 PM
ChipHankley1
New Contributor III

I have deployed a couple of Web App Builder projects, and am noticing an inconsistency between the location shown on the web-based map versus a native app.

Here's the workflow. 

  • I physically go to a location (using an iPad),
  • browse to and load the web page (Web App Builder)
  • Click the "MyLocation" widget

The map zooms to a location.  This location is frequently NOT the location that I am in, not even close. Off by many miles.  Other times it is spot on.

Conversely, a native app (like Collector, iMaps, Google Maps, etc.) tends to be consistently accurate within my expectations of the device's GPS.

Why the difference between the two apps (browser vs. native)?  The map is using Web Mercator.  I have seen this behavior with two separate iPads.

0 Kudos
1 Solution

Accepted Solutions
YueWu1
by Esri Regular Contributor
Esri Regular Contributor

Hi Chip,

Based on my understanding, the Web App Builder "My location" widget is using the "esri/djit/locateButton". You can confirm this by checking your application folder under "arcgis-web-appbuilder-1.2/server/apps/yourAppNumber/widgets/Mylocation/Widget.js" file. You will see in line20 the class esri/djit/locateButton is called.

Essentially, this "My location" widget is using HTML5 Geolocation API, here is the documentation talked about this method "geolocationOptions" LocateButton | API Reference | ArcGIS API for JavaScript

You may wonder why bring all of the things together, The reason is because we want to know the original issue of why "location" result is not accurate. Therefore, technically speaking, if the location is not accurate, the issue is related to HTML5 Geolocation API.

Then you may wonder how does the Geolocation API work?

Depending on which browser you are using, the HTML5 Geolocation API approximates location based on a number of factors including your public IP address, cell tower IDs, GPS information, a list of Wifi access points, signal strengths and MAC IDs (Wifi and/or Bluetooth). It then passes that information to a Location Service usually via an HTTPS request which attempts to correlate your location from a variety of databases that include Wifi access point locations both public and private, as well as Cell Tower and IP address locations. An approximate location is then returned to your code via a JavaScript callback.

For more information about how accurate is HTML5 Geolocation API. Please check this blog: HTML5 Geolocation API – how accurate is it, really? « The Page Not Found Blog

You can test HTML5 Geolocation in different browsers using a test application that the blog author built. I recommend trying it on different browsers and comparing the results yourself: http://andygup.net/samples/html5geo/

Hope this information can help you.

View solution in original post

6 Replies
YueWu1
by Esri Regular Contributor
Esri Regular Contributor

Hi Chip,

Based on my understanding, the Web App Builder "My location" widget is using the "esri/djit/locateButton". You can confirm this by checking your application folder under "arcgis-web-appbuilder-1.2/server/apps/yourAppNumber/widgets/Mylocation/Widget.js" file. You will see in line20 the class esri/djit/locateButton is called.

Essentially, this "My location" widget is using HTML5 Geolocation API, here is the documentation talked about this method "geolocationOptions" LocateButton | API Reference | ArcGIS API for JavaScript

You may wonder why bring all of the things together, The reason is because we want to know the original issue of why "location" result is not accurate. Therefore, technically speaking, if the location is not accurate, the issue is related to HTML5 Geolocation API.

Then you may wonder how does the Geolocation API work?

Depending on which browser you are using, the HTML5 Geolocation API approximates location based on a number of factors including your public IP address, cell tower IDs, GPS information, a list of Wifi access points, signal strengths and MAC IDs (Wifi and/or Bluetooth). It then passes that information to a Location Service usually via an HTTPS request which attempts to correlate your location from a variety of databases that include Wifi access point locations both public and private, as well as Cell Tower and IP address locations. An approximate location is then returned to your code via a JavaScript callback.

For more information about how accurate is HTML5 Geolocation API. Please check this blog: HTML5 Geolocation API – how accurate is it, really? « The Page Not Found Blog

You can test HTML5 Geolocation in different browsers using a test application that the blog author built. I recommend trying it on different browsers and comparing the results yourself: http://andygup.net/samples/html5geo/

Hope this information can help you.

ChipHankley1
New Contributor III

This is an awesome reply!  I'll  dig into the blog post a little more, but I'm curious if some browsers make better use of the GPS on a mobile device than others.

Nice work!

MatthewKing
Occasional Contributor II

Is there a way to have WAB, either through a custom widget, a setting or code, use the phone GPS instead of HTML 5 Geolocation API?  We want to use this app as a mobile natural area trail guide showing hiking trails but like the OP it's way off.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Matthew,

  The location widget will switch to use the devices GPS if it is available.

0 Kudos
MatthewKing
Occasional Contributor II

Thanks for the quick response.  I should of added on my post that at least on my android phone it does not initiate the GPS.  I used other browser-based web maps that do call the device GPS (I get a marker icon in the notification bar when it's in use), but WAB does not.  Just wondering if there's code that can be added that will cause the location widget to call the GPS.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Matthew,

Not that I am aware of, the browser should report the presence of the GPS and then it will be used automatically.

0 Kudos