Multimap logo Multimap Open API V1.2 Example

A Basic Example

This example explains and expands upon the JavaScript used in the Introduction. That example demonstrated that just a few lines of JavaScript code can be used to output a basic map viewer.

The first important code line is the MMAttachEvent line. This is a way of telling the browser that you wish a specific function, in this case the onLoad function, to be called when the page loads. This works in all browsers supported by the API.

The first line of code within the function is used to create a new map viewer and link it to the container DIV. Nothing is drawn on the screen yet, allowing you to make changes to the viewer first. You must keep a reference to this viewer, as you will use it for any operations that you wish to perform later.

The second line of code tells the map viewer to draw itself within the container. You must pass in a set of coordinates on which you wish to center the viewer. These should be passed in as latitude and longitude encapsulated within an MMLatLon object. Either you can pass the MMLatLon object directly to the drawAndPositionMap function or you can wrap it with an MMLocation object which will allow you to tell the viewer to draw the location at a different zoom factor from the default.

Callback method *new*

The Multimap Open API now allows you to use a 'callback method' to determine how your application responds when the Multimap Open API has loaded. To use this feature:

  1. Include your callback function in a URL such as
    http://developer.multimap.com/API/maps/1.2/OA08061815803962482?callback=myFunction
  2. Define a function that corresponds to your callback:
    function myFunction() {
      alert( 'API loaded' );
    }
    
  3. Your callback function is called when the Multimap Open API has loaded.

Function(s) introduced:

MultimapViewer: goToPosition() *new*, MultimapViewer()

What You Should See

If you view this in your browser you should see a Multimap draggable map centered on Saint James Avenue, Boston, Massachusetts, USA, at zoom factor 15.

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...

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