Getting Started
To get started using this JavaScript API, you will first need credentials and then copy the code below for referencing the API within your webpage.
<script type="text/javascript" src="http://apps.nowwhere.com.au/MDSQuickMap/GeocodeControl.ashx?key=YOUR_API_KEY_HERE"></script>
Once you have the credentials and the above code, you can now start using the geocoding API to retrieve the geographic location of a street address.
Note: all input or output coordinates are Latitudes and longitudes on the GDA94 (i.e. WGS84) datum. (As used by most GPS devices)
Geocoding Example
So, lets dive right in with a simple code example of retrieving coordinates from a simple address.
var g = new MapDS.Geocode.Geocoder();
g.getLocations(new Address(null,null,'2065'),
function(results) {
alert(results);
}
);This will give you the following JSON result:
"Code": 1,
"Locations": [{
"Accuracy": 95,
"AddressLine": "",
"Country": "Australia",
"Locality": "",
"Position": {
"Latitude": -33.823248,
"Longitude": 151.195504
},
"PostalCode": "2065",
"Region": "NSW"
}]
} The result you see above has a property code, which identifies the quality of the overall address match.
| Code |
Description |
| 0 |
Address not found. |
| 1 |
Found a single address |
| 100 |
Multiple locations matching the search criteria were found. |
| 110 |
Could not find address. |
| 120 |
Invalid postcode. |
| 888 |
Manual positioning, not exact match |
| 999 |
Manual positioning, exact match
|
There is also a collection of locations, these contain the set of geocoded results. Each location will contain an Accuracy property.
| Accuracy |
Description |
| 10 |
Found street address. |
| 20 |
Street number not found – found nearest number. |
| 30 |
Found street address in surrounding town/suburb. |
| 40 |
Found nearest street number in surrounding town/suburb. |
| 50 |
Street number not found - centred on street. |
| 60 |
Found street centre in surrounding town/suburb. |
| 70 |
Found suburb centre. |
| 80 |
Street not found - centred on suburb. |
| 90 |
Street not found - centred on postcode. |
| 95 |
Found postcode centre. |
Coming Soon!
We will also be releasing reverse geocoding into this API. Currently this functionality and more detailed geocoding options are only available through our Web Services API.
API Reference
MapDS.Geocode.Geocoder
This is the main geocoding class to obtain geocodes for addresses from the MapData Sciences servers.
Constructor
| Constructor |
Description |
| Geocoder() |
Creates a new Geocoder object. |
Methods
| Method |
Return Type |
Description |
| getLocations(address:Address, callback:Function) |
Array |
Performs a geocode on the given address, results are passed to the specified callback. |
| setCountryCode(countryCode) |
None |
Sets the country for result biasing. Must conform to ISO-3166 2 letter codes. Overriden by the Address country value, if set. Default is 'AU'.
|
| getCountryCode |
String |
Retrieves the country code. |
| reset |
None |
Resets the Geocoder back to the default setttings. |