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.
-
Copy the contents of step_1.html into a new
.html
file on your own machine and open it viahttp://
protocol in your browser.Don't have a local web server running?
You can find information to help you set one up here.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.
-
Listen for the appropriate event to retrieve the current user's location (once it's available).
-
Include a QueryTask to pass the user location in a request to an Esri service that hosts US Census Block Groups.
-
Draw the feature that is retrieved as a new Graphic on the map.
In the end your app should look something like this:
ie: sample code ripe for stealing
are you thirsty for more?
- pan/zoom the map to the extent of the census block being drawn.
- customize census block symbology and give it a popup.
- add nearby census block features when the page loads and use our new GeometryEngine for the query (instead of making a request to the ArcGIS Service).
- use Geoenrichment to find out the total population of the census block.
- create a 3D version of the application using the JS API 4.0.