ArcGIS JS API 4 Locate widget like WebAppBuilder

1433
10
07-11-2022 09:35 AM
BobCowling2
New Contributor III

Hello,

I am wondering how to get the geolocation icon in the ArcGIS JS API 4 locate widget to look and behave more like the My Location Widget from the WebAppBuilder on a mobile device. I am aware that WAB uses JS API v3 but I would think it must be possible to get similar look and  behavior in v4. The WAB widget on a mobile device has an accuracy buffer and the flashlight that shows the direction you are facing. I also tend to believe in my own comparison using the same device at the same location, the GPS accuracy of the My Location Widget in the WAB was better than the location widget in ArcGIS JS 4 API. Do they both not use HTML5 Geolocation? You can see in the screenshots below the visual differences between the two widgets. 

BobCowling2_0-1657557154439.png

BobCowling2_1-1657557198746.png

 

 

 

0 Kudos
10 Replies
ReneRubalcava
Frequent Contributor

4x does use the geolocation api, we just don't have the accuracy symbology. You can add it though with the info from the widget. Here's a sample.

https://codepen.io/odoe/pen/zYpmEMB?editors=1000

You can even add a line or polygon for the heading from the widget info.

0 Kudos
BobCowling2
New Contributor III

Thank you for the codepen. I do appreciate that. I am more interested in the compass direction symbology. If this is not available, would ESRI be willing to provide a working example of this functionality on ArcGIS JS v4? I understand I can do this myself with the heading information but it would be nice to have a working example with the correct symbology. Other mapping platforms such as Mapbox have these features available on their widgets.  

0 Kudos
BobCowling2
New Contributor III

Still hoping to get a response on this. The accuracy of the track widget is terrible. There are inaccuracies of over 100 feet at times. I have seen others complain about this on here and they received no response from ESRI either. I compared the track widget with the Geolocation Widget on Mapbox GL JS and the Mapbox one has nearly my exact location at all times and follows me around perfectly when I am walking. The ESRI widget GPS point bounces all over and is in the incorrect location 98% of the time. What are the settings that can be improved here to make this work better for a web field application? Also, is there an example that can be provided on how to add a compass heading arrow to the GPS blue dot? Thank you. @ReneRubalcava @AndyGup 

Tags (3)
0 Kudos
ReneRubalcava
Frequent Contributor

The Locate widget uses the geolocation api of the browser, so it's completely device dependent at that point. You can pass geolocation options to modify the max age and timeout if you like.

https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Track.html#geolocationOpt...

We don't have an example on hand showing the heading, but you can update the graphic of the Track widget to show an arrow based on the heading, you can even change it based on other results of the geolocation api like speed and altitude.

https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Track.html#graphic

BobCowling2
New Contributor III

@ReneRubalcava Thank you for the reply. The Mapbox GL JS one also uses the geolocation API and is far more accurate. I have tested both of them on the same device, same browser, same location. The Mapbox one does not have the issues the ESRI one does. I invite you to walk around outside and use the Mapbox one vs the Esri widget and report the results. https://docs.mapbox.com/mapbox-gl-js/example/locate-user/

I am looking for a solution that would behave more like the Mapbox GL JS example.

 

0 Kudos
AndyGup
Esri Regular Contributor

Hi Bob, it seems like this is a duplicate post. let's move the accuracy discussion to this other thread => https://community.esri.com/t5/arcgis-api-for-javascript-questions/poor-accuracy-of-locate-widget/m-p...

0 Kudos
AndyGup
Esri Regular Contributor

@BobCowling2  quick update on your original posting above, I've created an enhancement request to add an accuracy circle and compass heading symbol to the Track Widget.

0 Kudos
BobCowling2
New Contributor III

@AndyGup Great. Thanks a lot! Definitely looking forward to these features. 

0 Kudos
BobCowling2
New Contributor III

@AndyGup is anything official on if these features will be available and when? Thanks! 

0 Kudos