In this tutorial, we will be building an interactive “census” maproom. Users will be able to click anywhere on the map to get census data for that location.
First, create a new map service in ArcGIS Server that contains some census data:
- Create an ArcMap project with a census tract layer that has census data in the attribute table
- Publish the project as a new map service on ArcGIS Server
Here is an example map service.
Querying an ArcGIS Server Layer
Once you have a map service on ArcGIS Server, you can query the layers that the service contains. For the example map service, there is one layer “us_tracts” which you can access here:
You can then click on the “query” link at the bottom of the page to go to the ArcGIS query wizard page:
In the query page, fill the wizard form with the following to access data for a specific location:
- Enter a known lat/lon pair in this format (lon,lat) in the filter geometry box.
- Select “point” for geometry type
- Enter “*” for return fields
- select “json” for format
- click the Query(GET) button
Notice how this returns a JSON feed for the census tract polygon the point falls in (it’s a point-in-polygon spatial query). Also, notice the URL that is generated from this call. If you take away all the irrelevant url parameters, this is the trimmed url string:
What this means is that you can perform a spatial query to this published map service, and instantly retrieve data for any given point within the layer’s bounds! Since this is a census tract layer that encompasses the entire USA, any latitude/longitude point within the entire country will produce a successful return of data. Now let’s apply this logic by making this spatial query call to ArcGIS Server dynamically from a Google Map using jQuery.