Geocoding, location module - GeoSmartCity-CIP/gsc-client GitHub Wiki

This module implements library functions to geocode geographical names into coordinates as well as to reverse geocode coordinates into geographical names. The module relies on a web service to supply coordinates for matching names and for supplying names for specified coordinates.

API

API is available at GitHub src/geocode/geocode.js.

Dependencies

The module depends on jQuery and Bootstrap libraries on client side. The service also relies on an instance of the GSC Hub where the geocoding API is implemented as a web service. The web service end-point for this service is public and does not require any authentication.

The module may be used independently of the rest of the GSC functionality.

Example

Usage of the module is trivial; see the following listing. Either forward or reverse geocoding is applied depending on passed argument(s). Result, a GeocodingResponse object, wraps required information on successful request.

// Invoking the geocoding engine, forward geocoding:
// Promise|GeocodingResult gsc.geocode(String name) 
var result = gsc.geocode('Brussels');

// Invoking the geocoding engine, reverse geocoding:
// Promise|GeocodingResult gsc.reverseGeocode(double lon, double lat)
var result = gsc.geocode(4.35, 50.8);

// GeocodingResponse object (valid for both forward and reverse geocoding)
{
    status: 'success',
    count: 1,
    time: 17
    data: [
       {
          geonamesid: 123,
          name: "Brussels",
          variants: "Bruxelles, Bruxelas",
          longitude:4.3500
          latitude: 50.8500 
      }
   ]
}