Presented at the Esri Dev Summit in Berlin. November 19, 2012.
Sample code: github.com/esri/quickstart-js
Live examples: edn1.esri.com/quickstartjs/
Tweets from my Geolocation session at Esri Dev Summit Berlin 2012
Storified by Aaron Parecki · Mon, Nov 19 2012 06:44:00
Plenary Talk (5-minute overview)
Aaron Parecki from @geoloqi on their GeoTrigger Platform. Interesting stuff possible,session this afternoon #DevSummit http://pic.twitter.com/bt3cFafMgrischagundelsweiler
RT @JuliePowellGIS: Learn more about geoloqi and Geotriggers at 2pm #devsummit. They have JS, Android, and iOS APIs.Esri Deutschland
Geolocation in Web and Mobile Apps session - 2pm
It's all about #location in the @geoloqi session at #DevSummit. Learning a lot! http://pic.twitter.com/LjXdmVUOgrischagundelsweiler
Find more infos, slides etc. of @aaronpk on http://aaronparecki.com #DevSummitgrischagundelsweiler
Geofencing at the next level with geoloqi technology at #devsummitMartin Hausmann
Geolocation in web/mobile apps with @aaronpk at #Esri #DevSummit Berlin http://pic.twitter.com/AUslQlzuJim Barry
Nice talk about smart geofencing by @aaronpk #devsummitTomas Novotny
- Geolocation in Web and Mobile Apps Aaron Parecki CTO, Esri R&D Center, Portland Esri Dev Summit, Berlin November 2012
-
Displaying a Map - HTML
<script src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=3.2compact"></script> <script src="../quickstart-js/src/esriquickstart.js"></script> <script type="text/javascript"> var map; function init() { map = new esri.Map("map"); map.setBasemap(esri.arcgisonline.basemaps.STREETS); map.centerAtLatLon(45.512, -122.643, 8); } </script>
- Displaying a Map - iPhone
- Displaying a Map - Android
- Finding Nearby Businesses ArcGIS Geocoder Foursquare API Twitter API Yelp API Factual API Google Places API And others
-
Place Search
with ArcGIS Geocoder
var searchOptions = { place: "Cafe", // e.g. Redlands, 380 New York St, Starbucks... placeType: "Coffee Shop", // e.g. Coffee Shop, Gas Station, Shopping... searchExtent: map.extend // if null, it will search the global database }; geocodeService.findPlaces(searchOptions, geocodeResults, geocodeErrorHandler); function geocodeResults(places) { if (places.length > 0) { for (var i = 0; i < places.length; i++) { var place = places[i]; var lat = place.point.getLatitude(5); var lon = place.point.getLongitude(5); map.graphics.addPoint(place.point, { title: "<b>Geocode Result</b>", content: place.address + "<br/>Lat/Lon: " + lat + "," + lon, symbol: map.defaultSymbols.Geolocation, attributes: { "ID": "PlacesGraphicID"} }); } zoomToPlaces(places); } else { alert("Sorry, address or place not found."); } } function geocodeErrorHandler(errorInfo) { alert("Sorry, address not found!"); }
quickstart-js/samples/findplaces.html - Finding Information About a Location Reverse Geocoding
-
ArcGIS Reverse Geocoder
Sample Request: http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/reverseGeocode?location=13.421,+52.487&outSR=4326&f=json Sample Response:
- Finding the User’s Location
- Browser Geolocation Desktop browsers use nearby wifi hotspots Mobile devices may use GPS or cell tower positioning You can also use IP address lookups to get a rough location (but is usually very inaccurate)
-
Finding the User’s Location using Javascript
if(navigator.geolocation) { navigator.geolocation.getCurrentPosition(function(position){ var zoom = 13; var pt = new esri.geometry.Point(position.coords.longitude, position.coords.latitude); var options = { title: "<b>Current Location</b>", content: "Latitude: " + pt.getLatitude(3) + "</br>Longitude: " + pt.getLongitude(3), symbol: map.defaultSymbols.Geolocation }; map.graphics.addPoint(pt, options); map.centerAtPoint(pt, zoom); }); }
- Browser Geolocation 1. User sees location permission prompt 2. Browser gets a list of visible wifi access points 3. Browser sends the list to the geolocation server 4. Server replies with the location
- Browser Geolocation Usability problem with this approach: User is left with an empty page waiting for them to press “allow” You should do the best you can with no location, and then update your page after you get the user’s location Could use IP-based location to center a map somewhere that is (probably) nearby
-
Monitoring Continuous Location in Javascript
navigator.geolocation.watchPosition(function(position){ var pt = new esri.geometry.Point(position.coords.longitude, position.coords.latitude); var options = { title: "Current Location", content: "Latitude: " + pt.getLatitude(3) + "</br>Longitude: " + pt.getLongitude(3), symbol: map.defaultSymbols.Geolocation }; map.graphics.addPoint(pt, options); map.centerAtPoint(pt, 15); });
- Monitoring Continuous Location on the iPhone This will keep running in the background! (But now you will potentially drain the battery)
- Saving battery by Getting the User’s Approximate Location
-
Retrieving Approximate Location on the iPhone
[locationManager startMonitoringSignificantLocationChanges];
Your app will be re-launched in the background when the user moves “significantly” Most likely when they change cell towers Location is usually very rough, ~500-1500m accuracy -
Retrieving Approximate Location on Android
locationManager.requestLocationUpdate( LocationManager.PASSIVE_PROVIDER, 0, 0, listener);
Service runs in the background, gets locations when other providers or apps request location. Not guaranteed to get any data, but it will use no additional resources. Could be cell tower location, could be GPS - Differences between Location Services on iOS and Android
- iOS Location Services App registers for location updates from the operating system iOS delivers location events to a delegate object in the app when it’s running iOS may terminate your app due to high memory conditions, etc. If terminated, iOS will re-launch the app in the background when a location event is received Less control over when the data is received, but less code to manage
- Android Location Services App creates a background service which runs persistently The app’s service requests location data from the OS The OS delivers location data to the service More control available on Android, but also requires more code to manage
- Location-Based Triggers
- Geotrigger™ Overview Create triggers when users enter, leave, or dwell in locations.
- Sneak Preview!
- 500 Meters from a Point
-
Distance from a Point
POST /trigger/create { "app_id": "XXXXX", "app_secret": "XXXXX", "condition": { "direction": "enter", "geo": { "point": { "latitude": 52.5107, "longitude": 13.3757, "distance": 500 } } }, "action": { "message": "About 500 meters from the hotel." } }
-
3-Minute Drive-Time Polygon
POST /trigger/create { "app_id": "XXXXX", "app_secret": "XXXXX", "condition": { "direction": "enter", "geo": { "point": { "geocode": "Axel-Springer-Straße 55, Berlin", "drive_time": 600 } } }, "action": { "message": "About 5 minutes away from the hotel." } }
- Use Cases Basic and advanced applications of Geotrigger notifications
- Personalized Recommendations The next generation advertising is local, personalized, and opt-in Advanced: Location combined with history (weather alerts, etc)
- Conditional Access Once an official walks 100 feet from his building, he can no longer access confidential records. Geofences define conditional access rights.
- Gaming Scavenger hunts Social, location-based games using real-life as the playing field New revenue models Unlock levels based on venue access Retail location sponsorships
- Hospitality and Customer Service Customer’s prescription refill is ready when they get there. CRM Integration: based on their purchase history, a favorite item is on sale.
- Home Automation Energy management and notifications Enter the house, the lights turn on Leave, and the lights turn off
- Hyperlocal Weather Alerts
- Tourism Inform tourists of interesting locations as they explore your city. Bring existing datasets like Wikipedia to life
- Public Alerts Notify citizens about events such as road closures or civic emergencies based on past locations.
- Real Estate Send messages to prospective home buyers when their search criteria matches a home nearby.
- Thank You.