advanced geolocation for the mobile web - esri...2017 esri developer...
TRANSCRIPT
![Page 1: Advanced Geolocation for the Mobile Web - Esri...2017 Esri Developer Summit-International--Presentation, 2017 Esri Developer Summit-International, Advanced Geolocation for the Mobile](https://reader031.vdocuments.site/reader031/viewer/2022011919/600d39e6746b8b58ac0ceab5/html5/thumbnails/1.jpg)
Advanced Geolocationfor the Mobile Web
Andy Gup, @agup
![Page 2: Advanced Geolocation for the Mobile Web - Esri...2017 Esri Developer Summit-International--Presentation, 2017 Esri Developer Summit-International, Advanced Geolocation for the Mobile](https://reader031.vdocuments.site/reader031/viewer/2022011919/600d39e6746b8b58ac0ceab5/html5/thumbnails/2.jpg)
How to get a good location
Challenges
Solutions
![Page 3: Advanced Geolocation for the Mobile Web - Esri...2017 Esri Developer Summit-International--Presentation, 2017 Esri Developer Summit-International, Advanced Geolocation for the Mobile](https://reader031.vdocuments.site/reader031/viewer/2022011919/600d39e6746b8b58ac0ceab5/html5/thumbnails/3.jpg)
Smartphone/Tablet GPS
Built for consumer use-cases
Accuracy only needs to be “good enough”
Tiny antenna on bottom of device
![Page 4: Advanced Geolocation for the Mobile Web - Esri...2017 Esri Developer Summit-International--Presentation, 2017 Esri Developer Summit-International, Advanced Geolocation for the Mobile](https://reader031.vdocuments.site/reader031/viewer/2022011919/600d39e6746b8b58ac0ceab5/html5/thumbnails/4.jpg)
Geolocation Object
![Page 5: Advanced Geolocation for the Mobile Web - Esri...2017 Esri Developer Summit-International--Presentation, 2017 Esri Developer Summit-International, Advanced Geolocation for the Mobile](https://reader031.vdocuments.site/reader031/viewer/2022011919/600d39e6746b8b58ac0ceab5/html5/thumbnails/5.jpg)
Say what, 4887 meters accuracy???
Indoors using WiFi-only
![Page 6: Advanced Geolocation for the Mobile Web - Esri...2017 Esri Developer Summit-International--Presentation, 2017 Esri Developer Summit-International, Advanced Geolocation for the Mobile](https://reader031.vdocuments.site/reader031/viewer/2022011919/600d39e6746b8b58ac0ceab5/html5/thumbnails/6.jpg)
Demo
http://github.com/esri/html5-geolocation-tool-js
![Page 7: Advanced Geolocation for the Mobile Web - Esri...2017 Esri Developer Summit-International--Presentation, 2017 Esri Developer Summit-International, Advanced Geolocation for the Mobile](https://reader031.vdocuments.site/reader031/viewer/2022011919/600d39e6746b8b58ac0ceab5/html5/thumbnails/7.jpg)
Best possible accuracy…under perfect conditions
3 – 10 meters
10 – 33 feet
![Page 8: Advanced Geolocation for the Mobile Web - Esri...2017 Esri Developer Summit-International--Presentation, 2017 Esri Developer Summit-International, Advanced Geolocation for the Mobile](https://reader031.vdocuments.site/reader031/viewer/2022011919/600d39e6746b8b58ac0ceab5/html5/thumbnails/8.jpg)
Problem 1: location fluctuations
![Page 9: Advanced Geolocation for the Mobile Web - Esri...2017 Esri Developer Summit-International--Presentation, 2017 Esri Developer Summit-International, Advanced Geolocation for the Mobile](https://reader031.vdocuments.site/reader031/viewer/2022011919/600d39e6746b8b58ac0ceab5/html5/thumbnails/9.jpg)
Problem 2: all locations lumped together
Network location
GPS location
![Page 10: Advanced Geolocation for the Mobile Web - Esri...2017 Esri Developer Summit-International--Presentation, 2017 Esri Developer Summit-International, Advanced Geolocation for the Mobile](https://reader031.vdocuments.site/reader031/viewer/2022011919/600d39e6746b8b58ac0ceab5/html5/thumbnails/10.jpg)
![Page 11: Advanced Geolocation for the Mobile Web - Esri...2017 Esri Developer Summit-International--Presentation, 2017 Esri Developer Summit-International, Advanced Geolocation for the Mobile](https://reader031.vdocuments.site/reader031/viewer/2022011919/600d39e6746b8b58ac0ceab5/html5/thumbnails/11.jpg)
![Page 12: Advanced Geolocation for the Mobile Web - Esri...2017 Esri Developer Summit-International--Presentation, 2017 Esri Developer Summit-International, Advanced Geolocation for the Mobile](https://reader031.vdocuments.site/reader031/viewer/2022011919/600d39e6746b8b58ac0ceab5/html5/thumbnails/12.jpg)
??
![Page 13: Advanced Geolocation for the Mobile Web - Esri...2017 Esri Developer Summit-International--Presentation, 2017 Esri Developer Summit-International, Advanced Geolocation for the Mobile](https://reader031.vdocuments.site/reader031/viewer/2022011919/600d39e6746b8b58ac0ceab5/html5/thumbnails/13.jpg)
Use case: Stationary…
5 minutes!
![Page 14: Advanced Geolocation for the Mobile Web - Esri...2017 Esri Developer Summit-International--Presentation, 2017 Esri Developer Summit-International, Advanced Geolocation for the Mobile](https://reader031.vdocuments.site/reader031/viewer/2022011919/600d39e6746b8b58ac0ceab5/html5/thumbnails/14.jpg)
Problem 3: Accuracy will vary
Bad
So-so
GoodTime vs Accuracy
![Page 15: Advanced Geolocation for the Mobile Web - Esri...2017 Esri Developer Summit-International--Presentation, 2017 Esri Developer Summit-International, Advanced Geolocation for the Mobile](https://reader031.vdocuments.site/reader031/viewer/2022011919/600d39e6746b8b58ac0ceab5/html5/thumbnails/15.jpg)
Problem 3: Accuracy will vary
Bad
So-so
GoodTime vs Accuracy
![Page 16: Advanced Geolocation for the Mobile Web - Esri...2017 Esri Developer Summit-International--Presentation, 2017 Esri Developer Summit-International, Advanced Geolocation for the Mobile](https://reader031.vdocuments.site/reader031/viewer/2022011919/600d39e6746b8b58ac0ceab5/html5/thumbnails/16.jpg)
Accuracy vs Precision
Low AccuracyHigh Precision
High AccuracyLow Precision
High AccuracyHigh Precision
![Page 17: Advanced Geolocation for the Mobile Web - Esri...2017 Esri Developer Summit-International--Presentation, 2017 Esri Developer Summit-International, Advanced Geolocation for the Mobile](https://reader031.vdocuments.site/reader031/viewer/2022011919/600d39e6746b8b58ac0ceab5/html5/thumbnails/17.jpg)
Problem 4: GPS needs to warm up!
Initial readings less accurate or non-existent
![Page 18: Advanced Geolocation for the Mobile Web - Esri...2017 Esri Developer Summit-International--Presentation, 2017 Esri Developer Summit-International, Advanced Geolocation for the Mobile](https://reader031.vdocuments.site/reader031/viewer/2022011919/600d39e6746b8b58ac0ceab5/html5/thumbnails/18.jpg)
Technical Use Case: Cold Start
GPS takes time to calibrate
Phone rebooted
Updated phone OS
Potential for no cached values
Potential for large inaccuracy
![Page 19: Advanced Geolocation for the Mobile Web - Esri...2017 Esri Developer Summit-International--Presentation, 2017 Esri Developer Summit-International, Advanced Geolocation for the Mobile](https://reader031.vdocuments.site/reader031/viewer/2022011919/600d39e6746b8b58ac0ceab5/html5/thumbnails/19.jpg)
Technical Use Case: Warm start
GPS has been in use continuouslyGPS is (mostly) calibrated
Highest potential for accuracy and precision
![Page 20: Advanced Geolocation for the Mobile Web - Esri...2017 Esri Developer Summit-International--Presentation, 2017 Esri Developer Summit-International, Advanced Geolocation for the Mobile](https://reader031.vdocuments.site/reader031/viewer/2022011919/600d39e6746b8b58ac0ceab5/html5/thumbnails/20.jpg)
Using the Geolocation API options
errorHandler()
Timeout
maximumAge – used only during startup
enableHighAccuracy
![Page 21: Advanced Geolocation for the Mobile Web - Esri...2017 Esri Developer Summit-International--Presentation, 2017 Esri Developer Summit-International, Advanced Geolocation for the Mobile](https://reader031.vdocuments.site/reader031/viewer/2022011919/600d39e6746b8b58ac0ceab5/html5/thumbnails/21.jpg)
Snapshot location – Not Reliable!
navigator.geolocation.getCurrentPosition();
![Page 22: Advanced Geolocation for the Mobile Web - Esri...2017 Esri Developer Summit-International--Presentation, 2017 Esri Developer Summit-International, Advanced Geolocation for the Mobile](https://reader031.vdocuments.site/reader031/viewer/2022011919/600d39e6746b8b58ac0ceab5/html5/thumbnails/22.jpg)
watchId = navigator.geolocation.watchPosition(
processGeolocation,
/* OPTIONAL */
geolocationError,
{
timeout: 0,
maximumAge: Infinity,
enableHighAccuracy: true
}
);
Continuous location
![Page 23: Advanced Geolocation for the Mobile Web - Esri...2017 Esri Developer Summit-International--Presentation, 2017 Esri Developer Summit-International, Advanced Geolocation for the Mobile](https://reader031.vdocuments.site/reader031/viewer/2022011919/600d39e6746b8b58ac0ceab5/html5/thumbnails/23.jpg)
maximumAge (ms)
Max age of cached position in milliseconds
“0” – do not use cache
“Infinity” – (default) return any cached value
![Page 24: Advanced Geolocation for the Mobile Web - Esri...2017 Esri Developer Summit-International--Presentation, 2017 Esri Developer Summit-International, Advanced Geolocation for the Mobile](https://reader031.vdocuments.site/reader031/viewer/2022011919/600d39e6746b8b58ac0ceab5/html5/thumbnails/24.jpg)
timeout (ms)
Max milliseconds to return a positionThrow error if no location at timeoutWith watchPosition() can throw error repeatedly
“Infinity” – (default) don’t return until position available
![Page 25: Advanced Geolocation for the Mobile Web - Esri...2017 Esri Developer Summit-International--Presentation, 2017 Esri Developer Summit-International, Advanced Geolocation for the Mobile](https://reader031.vdocuments.site/reader031/viewer/2022011919/600d39e6746b8b58ac0ceab5/html5/thumbnails/25.jpg)
enableHighAccuracy(boolean)
Try to obtain best possible result
If GPS available and perms enabled -- use it
If Geolocation Service available -- use it
– Requires an internet connection!
– WiFi and/or Cellular
![Page 26: Advanced Geolocation for the Mobile Web - Esri...2017 Esri Developer Summit-International--Presentation, 2017 Esri Developer Summit-International, Advanced Geolocation for the Mobile](https://reader031.vdocuments.site/reader031/viewer/2022011919/600d39e6746b8b58ac0ceab5/html5/thumbnails/26.jpg)
watchPosition scenario 1:
{
timeout: 30000,
maximumAge: 300000
}
Request result < 30 secondsAccept cache value < 5 mins old
![Page 27: Advanced Geolocation for the Mobile Web - Esri...2017 Esri Developer Summit-International--Presentation, 2017 Esri Developer Summit-International, Advanced Geolocation for the Mobile](https://reader031.vdocuments.site/reader031/viewer/2022011919/600d39e6746b8b58ac0ceab5/html5/thumbnails/27.jpg)
watchPosition scenario 2:
{
timeout: 60000,
maximumAge: Infinity
}
Request result < 1 minuteReturn any cache value
![Page 28: Advanced Geolocation for the Mobile Web - Esri...2017 Esri Developer Summit-International--Presentation, 2017 Esri Developer Summit-International, Advanced Geolocation for the Mobile](https://reader031.vdocuments.site/reader031/viewer/2022011919/600d39e6746b8b58ac0ceab5/html5/thumbnails/28.jpg)
watchPosition scenario 3:
{
timeout: 60000,
maximumAge: 0,
enableHighAccuracy: true
}
Request result < 1 minuteDo NOT use cache, try GPS
![Page 29: Advanced Geolocation for the Mobile Web - Esri...2017 Esri Developer Summit-International--Presentation, 2017 Esri Developer Summit-International, Advanced Geolocation for the Mobile](https://reader031.vdocuments.site/reader031/viewer/2022011919/600d39e6746b8b58ac0ceab5/html5/thumbnails/29.jpg)
Browser Geolocation AccuracyDepends on …
Type of browserType of deviceWi-Fi On/OffGPS On/OffLocation user permissionsVPN
![Page 30: Advanced Geolocation for the Mobile Web - Esri...2017 Esri Developer Summit-International--Presentation, 2017 Esri Developer Summit-International, Advanced Geolocation for the Mobile](https://reader031.vdocuments.site/reader031/viewer/2022011919/600d39e6746b8b58ac0ceab5/html5/thumbnails/30.jpg)
Force phone to use GPS
![Page 31: Advanced Geolocation for the Mobile Web - Esri...2017 Esri Developer Summit-International--Presentation, 2017 Esri Developer Summit-International, Advanced Geolocation for the Mobile](https://reader031.vdocuments.site/reader031/viewer/2022011919/600d39e6746b8b58ac0ceab5/html5/thumbnails/31.jpg)
Solution 1: Post-process bufferingSolution 2: Cordova pluginSolution 3: 1 and/or 2 + external GPS
![Page 32: Advanced Geolocation for the Mobile Web - Esri...2017 Esri Developer Summit-International--Presentation, 2017 Esri Developer Summit-International, Advanced Geolocation for the Mobile](https://reader031.vdocuments.site/reader031/viewer/2022011919/600d39e6746b8b58ac0ceab5/html5/thumbnails/32.jpg)
Solution 1:Buffering to determine center point
Capture many points
Average all values
Calculate centroid
[{lat:-120,lon:35}, {lat:-120.01,lon:35.1}, {lat:-120.011,lon:35.02}, {lat:-120,lon:35.1}, {lat:-120,lon:35}]
![Page 33: Advanced Geolocation for the Mobile Web - Esri...2017 Esri Developer Summit-International--Presentation, 2017 Esri Developer Summit-International, Advanced Geolocation for the Mobile](https://reader031.vdocuments.site/reader031/viewer/2022011919/600d39e6746b8b58ac0ceab5/html5/thumbnails/33.jpg)
JavaScriptData Collection
Field location template
github.com/esri/html5-geolocation-tool-js
![Page 34: Advanced Geolocation for the Mobile Web - Esri...2017 Esri Developer Summit-International--Presentation, 2017 Esri Developer Summit-International, Advanced Geolocation for the Mobile](https://reader031.vdocuments.site/reader031/viewer/2022011919/600d39e6746b8b58ac0ceab5/html5/thumbnails/34.jpg)
Solution 2:Cordova/PhoneGap & Geolocation
Taps native SDKs via plugins
Direct access to geolocation functionality
Can track geolocation while in background
Battery usage optimization
![Page 35: Advanced Geolocation for the Mobile Web - Esri...2017 Esri Developer Summit-International--Presentation, 2017 Esri Developer Summit-International, Advanced Geolocation for the Mobile](https://reader031.vdocuments.site/reader031/viewer/2022011919/600d39e6746b8b58ac0ceab5/html5/thumbnails/35.jpg)
cordova-plugin-advanced-gelocation
https://github.com/Esri/cordova-plugin-advanced-geolocation
Separates GPS from Network location
Multi-threaded for high performance
Calculates centroid
Android only!
Native functionality
Separates network locations
from GPS locations
![Page 36: Advanced Geolocation for the Mobile Web - Esri...2017 Esri Developer Summit-International--Presentation, 2017 Esri Developer Summit-International, Advanced Geolocation for the Mobile](https://reader031.vdocuments.site/reader031/viewer/2022011919/600d39e6746b8b58ac0ceab5/html5/thumbnails/36.jpg)
External GPS
Can provide greater accuracy and precision
Can provide faster location acquisition
Connect via USB or Bluetooth
![Page 37: Advanced Geolocation for the Mobile Web - Esri...2017 Esri Developer Summit-International--Presentation, 2017 Esri Developer Summit-International, Advanced Geolocation for the Mobile](https://reader031.vdocuments.site/reader031/viewer/2022011919/600d39e6746b8b58ac0ceab5/html5/thumbnails/37.jpg)
Example: Trimble R1Sub-meter accuracy*
Works with Geolocation API
Overrides onboard GPS
Works on iOS and Android
![Page 38: Advanced Geolocation for the Mobile Web - Esri...2017 Esri Developer Summit-International--Presentation, 2017 Esri Developer Summit-International, Advanced Geolocation for the Mobile](https://reader031.vdocuments.site/reader031/viewer/2022011919/600d39e6746b8b58ac0ceab5/html5/thumbnails/38.jpg)
On extra step on Android
![Page 39: Advanced Geolocation for the Mobile Web - Esri...2017 Esri Developer Summit-International--Presentation, 2017 Esri Developer Summit-International, Advanced Geolocation for the Mobile](https://reader031.vdocuments.site/reader031/viewer/2022011919/600d39e6746b8b58ac0ceab5/html5/thumbnails/39.jpg)
![Page 40: Advanced Geolocation for the Mobile Web - Esri...2017 Esri Developer Summit-International--Presentation, 2017 Esri Developer Summit-International, Advanced Geolocation for the Mobile](https://reader031.vdocuments.site/reader031/viewer/2022011919/600d39e6746b8b58ac0ceab5/html5/thumbnails/40.jpg)
A GPS Experiment
START POINT
![Page 41: Advanced Geolocation for the Mobile Web - Esri...2017 Esri Developer Summit-International--Presentation, 2017 Esri Developer Summit-International, Advanced Geolocation for the Mobile](https://reader031.vdocuments.site/reader031/viewer/2022011919/600d39e6746b8b58ac0ceab5/html5/thumbnails/41.jpg)
Commercial GPS Smartphone GPS
![Page 42: Advanced Geolocation for the Mobile Web - Esri...2017 Esri Developer Summit-International--Presentation, 2017 Esri Developer Summit-International, Advanced Geolocation for the Mobile](https://reader031.vdocuments.site/reader031/viewer/2022011919/600d39e6746b8b58ac0ceab5/html5/thumbnails/42.jpg)
Solution 3: buffer, plugin + external GPS
Take a close look at use casesStudy your requirements
![Page 43: Advanced Geolocation for the Mobile Web - Esri...2017 Esri Developer Summit-International--Presentation, 2017 Esri Developer Summit-International, Advanced Geolocation for the Mobile](https://reader031.vdocuments.site/reader031/viewer/2022011919/600d39e6746b8b58ac0ceab5/html5/thumbnails/43.jpg)
Recap
Consumer vs Commercial case casesConsumer vs Commercial equipment
Accuracy vs Precision
Getting the best static location
![Page 45: Advanced Geolocation for the Mobile Web - Esri...2017 Esri Developer Summit-International--Presentation, 2017 Esri Developer Summit-International, Advanced Geolocation for the Mobile](https://reader031.vdocuments.site/reader031/viewer/2022011919/600d39e6746b8b58ac0ceab5/html5/thumbnails/45.jpg)
Works with..
![Page 46: Advanced Geolocation for the Mobile Web - Esri...2017 Esri Developer Summit-International--Presentation, 2017 Esri Developer Summit-International, Advanced Geolocation for the Mobile](https://reader031.vdocuments.site/reader031/viewer/2022011919/600d39e6746b8b58ac0ceab5/html5/thumbnails/46.jpg)
Works with…