Go in Depth With the HERE Location Services Geocoding API

September 17, 2019

HERE Platform Geocoding APIThe HERE Location Services Geocoding API is known for its versatility and practicality. Providing a street address results in an accurate lat/long. Providing an accurate lat/long results in a street address. What many developers don’t know, however, is all the other valuable information that can be returned.
Using AdminInfo in the API call will return:

  • Time zone
  •  Local time
  •  Currency
  •  Customary side of the road for driving
  •  Measurement system

You can also make calls to the API that will return the shape of a country, state or city.

To illustrate the value of using the HERE Location Services Geocoding API to its full potential, we’re providing some sample code showing how to retrieve this type of information:

AdminInfo

Here is an example of a Geocoding call and the return of the AdminInfo for Chicago:
https://reverse.geocoder.api.here.com/6.2/reversegeocode.json?app_id=<app_id>&app_code=<app_code>&prox=41.875751,-87.620591&mode=retrieveAddresses&maxresults=1&locationattributes=adminInfo
AdminInfo Results


Shape of a Country

This code returns the shape of a country and shows that shape on a map. In this example, we use Germany:

function reverseGeocode(platform) {

        // set up Geocoder API

        var geocoder = platform.getGeocodingService(); 

        var prox = coord.lat + ',' + coord.lng;

       

        var reverseGeocodingParameters = {

            prox: prox,

            mode: 'retrieveAddresses',

            maxresults: '1',           

            additionaldata: 'IncludeShapeLevel,country'   

 

function addCountryOutline(map) {

        // clear map

        markerGroup.removeAll();

 

        // set up polygon style

        var customStyle = {

            strokeColor: 'black',

            fillColor: 'rgba(0,175,170,0.5)',

            lineWidth: 2,           

            lineJoin: 'bevel'

        };

 

        // the shape is returned as WKT and we need to convert it a Geometry

        var geometry = H.util.wkt.toGeometry(shape);

 

        // geometry is either a single or multi-polygon    

        if (geometry instanceof H.geo.MultiGeometry) {

            var geometryArray = geometry.getGeometries();

            for (var i = 0; i < geometryArray.length; i++) {

                markerGroup.addObject(new H.map.Polygon(geometryArray[i].getExterior(), { style:        customStyle }));           

            }

        } else { // instanceof H.geo.Polygon           

            markerGroup.addObject(new H.map.Polygon(geometry.getExterior(), { style: customStyle }));           

        }       

    }

Shape of a Country

HERE Location Services delivers fresh, high quality map data with a vast amount of information available when and where you need it through the HERE Geocoding API. Want to learn more about what sets HERE apart from other mapping providers? Download a copy of the What Sets HERE Location Services Apart From Other Mapping APIs? fact sheet.

New call-to-action

Share This Article