EasyTerritory Geocoding REST Service


The EasyTerritory Geocoding Service will covert street addresses to their latitude/longitude equivalents.  Having the latitudes and longitudes of records makes it possible to place those records on a map.  In order to use this powerful feature, a Bing Maps key will be needed.  You can get a free developer (Baisc) Bing Maps key here: www.bingmapsportal.com.

Please follow these steps to call the Geocoding Service:

  1. Get a login token by calling the EasyTerritory login web service:
  2. Set the http request cookie with the login token and use the request.Method = “POST” to the EasyTerritory Geocode service:
  3. Set the request.ContentType = “application/json”.
  4. The json object to post for geocoding:
        keyCustomer: string; //any unique identifier
        keyBing: string; //your bing key
        defaultCountryCode: string;
        enableAddressFallback: boolean;
        addressList: string[],

    Important Note: keyCustomer is just a unique id (e.g. GUID) for use in caching and customer tracking (it can be any unique value).

  5. Code Sample:
     document.cookie= "oitoken=EztToken"; 
        	url: "https:/apps.easyterritory.com/{yourGuid}/app/REST/Geocode",
         	type: "POST",     
         	contentType: "application/json",
         	data: JSON.stringify( {
    			"keyCustomer":"{Your Unique Identifier}",
    			"keyBing": "{Your Bing Key}", 
    			"addressList": "{addresses to be geocoded}"
         	xhrFields: {
               withCredentials: true                                 }

    Important Note: This will not work in a client-side scenario if you attempt to go cross-domain. Cross domain situations require a server side proxy using C#.

  6. The return json object:
       results: iGeocodeResult[];
       rowCount: number;
       hasRowErrors: boolean;
       error: string;
  7. Interface IGeocodeResult
       addressStandardized: string;
       addressCorrected: string;
       addressLine: string;
       country: string;
       adminLevel1: string;
       adminLevel2: string;
       locality: string;
       postalCode: string;
       locationMerc: { x: number, y: number };
       location: { lon: number, lat: number };
       finalProvider: string;
       didFallback: boolean;
       quality: eGeocodeQuality;
       qualityString: string;
       timeStampUtc: number;
       msToComplete: number;
       warning: string;