Ontok Geocoder Javascript Example 2

Enter an address and click on Add:

What is happening:

  1. call_ontok_geocoder is passed the address in addr, which creates a new SCRIPT element by contacting the Ontok Geocoder using the REST API with a fmt parameter of JS
  2. when the script finishes loading, the ontok_geocoder array is filled with the result, and ontok_geocoder_onload is called.
  3. the ontok_geocoder_onload function parses the result in the ontok_geocoder array using the split function and adds a marker.

Why this is cool:

  1. You don't have to do geocoding of addresses on the server. No XML parsing, etc.
For a simpler example, see this one