Skip to content

Commit

Permalink
add reverse geocode functionality for house address
Browse files Browse the repository at this point in the history
refs #115
  • Loading branch information
steveoh committed Feb 10, 2016
1 parent 8794762 commit 746c6cc
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 7 deletions.
26 changes: 26 additions & 0 deletions src/app/Identify.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ define([
});

this.getElevation(evt.mapPoint);
this.reverseGeocode(utm);
},
clearValues: function () {
// summary:
Expand Down Expand Up @@ -167,6 +168,31 @@ define([
that.elevFeet.innerHTML = feet;
}
});
},
reverseGeocode: function (point) {
// summary:
// hits the web api reverse geocode endpoint
// point: esri/geometry/point
console.log('app/Identify::reverseGeocode', arguments);

var that = this;
var url = lang.replace(config.urls.reverseGeocode, [point.x, point.y]);
request(url, {
query: {
apiKey: config.apiKey,
distance: 50
},
headers: {
'X-Requested-With': null
},
handleAs: 'json'
}).then(function (data) {
if (data.status && data.status === 200 && data.result.address) {
that.address.innerHTML = data.result.address.street;
} else {
that.address.innerHTML = 'n/a';
}
});
}
});
});
4 changes: 2 additions & 2 deletions src/app/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ define([

urls: {
search: 'http://api.mapserv.utah.gov/api/v1/search/{0}/{1}',
vector: 'http://mapserv.utah.gov/arcgis/rest/services/BaseMaps/Vector/MapServer',
dem: 'http://mapserv.utah.gov/arcgis/rest/services/DEM/ImageServer/identify'
dem: 'http://mapserv.utah.gov/arcgis/rest/services/DEM/ImageServer/identify',
reverseGeocode: 'http://api.mapserv.utah.gov/api/v1/geocode/reverse/{0}/{1}'
},

fieldNames: {
Expand Down
12 changes: 7 additions & 5 deletions src/app/templates/Identify.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,18 @@ <h4>WGS84</h4>
Lat: <span data-dojo-attach-point="lat"></span>
<br>
Lng: <span data-dojo-attach-point="lng"></span>
<h4>US National Grid</h4>
<span data-dojo-attach-point="nationalGrid"></span>
<h4>County</h4>
<span data-dojo-attach-point="county"></span>
<h4>House Address</h4>
<span data-dojo-attach-point="address"></span>
<h4>City</h4>
<span data-dojo-attach-point="municipality"></span>
<h4>County</h4>
<span data-dojo-attach-point="county"></span>
<h4>Land Administration Category</h4>
<span data-dojo-attach-point="landOwner"></span>
<h4>US National Grid</h4>
<span data-dojo-attach-point="nationalGrid"></span>
<h4>Elevation</h4>
<span data-dojo-attach-point="elevMeters"></span> (meters)
<br>
<span data-dojo-attach-point="elevFeet"></span> (feet)
</div>
</div>

0 comments on commit 746c6cc

Please sign in to comment.