-
Notifications
You must be signed in to change notification settings - Fork 108
/
call-tiger.js
36 lines (33 loc) · 918 Bytes
/
call-tiger.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import jsonpPModule from 'jsonp-p';
const jsonpP = jsonpPModule.default;
/**
* Call the Census geospatial API.
* @param {number} x - Latitude.
* @param {number} y - Longitude.
* @param {string} layer - Layer ID.
* @returns {Promise} A promise returned from the API.
*/
function callTiger(x, y, layer) {
// See versions at https://tigerweb.geo.census.gov/arcgis/rest/services/TIGERweb
const apiVersion = 'tigerWMS_ACS2019';
const url =
'https://tigerweb.geo.census.gov/arcgis/rest/services/TIGERweb/' +
apiVersion +
'/MapServer/' +
layer +
'/query' +
'?geometryType=esriGeometryPoint' +
'&geometry=' +
x +
',' +
y +
'&inSR=4326' +
'&spatialRel=esriSpatialRelIntersects' +
'&returnCountOnly=false' +
'&returnIdsOnly=false' +
'&returnGeometry=false' +
'&outFields=*' +
'&f=json';
return jsonpP(url).promise;
}
export default callTiger;