Multimap logo Multimap Open API V1.2 Example

Geocoding - Basic example

This example shows the simplest way of combining the mapping and geocoding features of the Multimap Open API, including the use of the events startGeocode and endGeocode.

Addresses can be passed directly within any function that supports MMLocation, such as goToPosition.


mapviewer.goToPosition( 
  new MMLocation( new MMAddress( { street : '31 St James Avenue', city : 'Boston', 
        state : 'MA', postal_code : '02116', country_code : 'US'} ), 11 ) );

The event types startGeocode and endGeocode are provided to allow you to detect when the asynchronous geocoding process has started and ended.

It should be noted that this is a very basic example of using the Multimap Open API geocoder and should be used with great care. When used in this fashion, if the geocoder returns multiple results the map viewer will automatically select the first entry, which may not be the result the user was expecting.

If you would like to learn how to handle multiple results by working directly with the Multimap Open API geocoder, take a look at the Using the Multimap Open API Geocoder example.

The geocoder returns results in UTF-8 format. You should ensure that the encoding of your HTML page is set to UTF-8 using a header similar to the following:

<meta http-equiv="content-type" content="text/html;charset=UTF-8">

Events used:

startGeocode, endGeocode

What You Should See

If you view this in your browser you should see a Multimap draggable map initially centered as a result of a geocoding request for an address in Boston, Massachusetts, USA, at zoom factor 11.

Links are provided to move the map to locations in London, Great Britain and Sydney, Australia, each of which is automatically generated as a result of a separate geocoding request.

The Map

The Code

There are three parts to the code below. The first is the line that links to the Multimap Open API. The second is an example of the HTML you must have in your page. The third is an example of the JavaScript required to implement the page.

The header code

<script type="text/javascript" src="http://developer.multimap.com/API/maps/1.2/OA08061815803962482"></script>

The body code

Sorry, JavaScript required...
Sorry, JavaScript required...

The JavaScript code

Sorry, JavaScript required...

For more information on the subject of Multimap Open API JavaScript code, please read the Multimap Open API documentation at: http://www.multimap.com/share/documentation/openapi/1.2/classes/.

Back to examples.

Further Help

If you require further help with your Multimap Open API implementation, please visit the Multimap Developer Forums.

For Open API news, announcements and other information, please see our blog.

For general account enquiries or further services, please contact the Multimap Sales team:

London, Great Britain +44 (0)20 7632 7800
email: sales@multimap.com