geodev-hackerlabs

Use HTML5 location to query a feature service

In this lab we’ll write an ArcGIS API for Javascript application that uses HTML5 to glean a user’s location and find out which census block they are inside.

  1. Copy the contents of step_1.html into a new .html file on your own machine and open it via http:// protocol in your browser.

    Don’t have a local web server running?
    You can find information to help you set one up here.

    Step 1

    because of security rules introduced in Chrome 50 (on 4/20/2016), it is mandatory to configure https in order to take advantage of HTML5 location when you move your website into production.

  2. Listen for the appropriate event to retrieve the current user’s location (once it’s available).

    Step 2

  3. Include a QueryTask to pass the user location in a request to an Esri service that hosts US Census Block Groups.

  4. Draw the feature that is retrieved as a new Graphic on the map.

Step 4

In the end your app should look something like this:


Resources

ie: sample code ripe for stealing

Bonus

are you thirsty for more?