Reverse geocoding an input position
The PTV xLocate service enables you to reverse geocode. This means the xLocate finds for a certain input coordinate the next address, street name or city. The input coordinate is defined by its x and y values, specifying the geographical point in a two-dimensional coordinate system (longitude and latitude in WGS84). Using the web serviceA web service represents a communication technology applied in computer networks. It provides an interface described in a machine-processable format, for example WSDL. APIs, it is very simple to integrate this functionality.
Prerequisites
Check if the following prerequisites are fulfilled before you start with the use case:
- Installed and licensed PTV xLocate service
- Installed PTV map data
Programming Guide
The following sample illustrates the basic steps that are necessary to reverse geocode an input position via the web service A web service represents a communication technology applied in computer networks. It provides an interface described in a machine-processable format, for example WSDL. API:
// Search for the position. xlocate.searchLocations({ "$type": "SearchByPositionRequest", "coordinate" : { "x": "6.130490", "y": "49.610400" }}, searchCompleted); // Process the results. function searchCompleted(response, exception) { if (response.results instanceof Array) { print('Reverse Geocoding succeeded and yielded ' + response.results.length + ' result(s).'); } else { print('Reverse Geocoding did not succeed.'); } }Related Topics
- The Reverse Geocoding Showcase provides an extended code sample to reverse geocode an input position and displaying results on a map. Also based on Leaflet, this showcase uses additional UI elements.
- Match a GPS position to the road network