Display GPS Accuracy

611
3
Jump to solution
05-30-2014 05:41 AM
MStayner
New Contributor III
Does anyone have a working example where you show the current GPS location by adjusting the halo around the GPS point? 

Here is an example using Openlayers: http://openlayers.org/dev/examples/geolocation.html

I'm having a hard time figuring out how to do the equivalent using Esri javascript.

Thanks!
0 Kudos
1 Solution

Accepted Solutions
MStayner
New Contributor III
The solution I found was the CIRCLE class.

Below is the code I used.

    _addGraphic: function(pt, accuracy) {       var circleSymb = new SimpleFillSymbol(         SimpleFillSymbol.STYLE_SOLID,         new SimpleLineSymbol(           SimpleLineSymbol.STYLE_SOLID,           new Color([27, 95, 248,0.75]), 1         ),         new Color([27, 95, 248,0.20])       );       var radius = accuracy;       var circle = new Circle({         center: pt,         geodesic: true,         numberOfPoints: 120,         radius: radius,             radiusUnit: "esriMeters"       });       this.halo = new Graphic(circle, circleSymb);       map.graphics.add(this.halo);     }      showLocation: function(location) {       //zoom to the users location and add a graphic       var pt = new Point(location.coords.longitude, location.coords.latitude);       if ( !this.graphic ) {         this._addGraphic(pt, location.coords.accuracy);       }     }

View solution in original post

0 Kudos
3 Replies
Noah-Sager
Esri Regular Contributor
Howdy,

I poked around a bit, but didn't find anything specific about adjusting the halo. Here are the resources that I could find, hopefully they will be of use:

Class: LocateButton

Geolocation API Specification
0 Kudos
MStayner
New Contributor III
Noah,

Thanks for the reply.  I looked at the Geolocation API Specification and now have the current accuracy using: location.coords.accuracy

Now, how do I draw the halo to have a certain radius?  This example uses SimpleMarkerSymbol to draw the GPS point and halo.  The only problem is the units are in pixels.

Is there a way draw a circle graphic with a certain radius (in feet)?

Thanks!
0 Kudos
MStayner
New Contributor III
The solution I found was the CIRCLE class.

Below is the code I used.

    _addGraphic: function(pt, accuracy) {       var circleSymb = new SimpleFillSymbol(         SimpleFillSymbol.STYLE_SOLID,         new SimpleLineSymbol(           SimpleLineSymbol.STYLE_SOLID,           new Color([27, 95, 248,0.75]), 1         ),         new Color([27, 95, 248,0.20])       );       var radius = accuracy;       var circle = new Circle({         center: pt,         geodesic: true,         numberOfPoints: 120,         radius: radius,             radiusUnit: "esriMeters"       });       this.halo = new Graphic(circle, circleSymb);       map.graphics.add(this.halo);     }      showLocation: function(location) {       //zoom to the users location and add a graphic       var pt = new Point(location.coords.longitude, location.coords.latitude);       if ( !this.graphic ) {         this._addGraphic(pt, location.coords.accuracy);       }     }
0 Kudos