Multimap API V1.2 JavaScript Example
The Multimap API now allows you to make a search of the records that have been geocoded and stored in the table of addresses that we provide as part of your your Multimap service, and to display on a map the locations that the table contains.
You should manage your table of addresses through Multimap's Client Zone extranet portal; for details of how to use this, please see Multimap's Client Zone documentation.
This example shows the simplest way of combining the mapping and searching features of the Multimap API, including the use of the events startSearchRequest and endSearchRequest; these two event types allow you to detect when the asynchronous searching process has started and ended.
Please note that this is a very basic example of using the Multimap API Searching module: there are more advanced ways, too. When performing the most basic searches, if the Searching module returns multiple results, the map viewer automatically selects the first entry; this may not necessarily be the result the user was expecting. When performing more advanced searches, you can exert greater control over the results that the search returns; this requires more development work, however.
If you would like to learn how to handle multiple results by working directly with the Multimap API Searching module, how to perform spatial searching (i.e., 'Where's my nearest...?') and how to use other search operators, please see the topic on combining features of the Multimap API Searching module.
Search requests can be passed directly within any function that supports MMLocation, such as goToPosition.
mapviewer.goToPosition( new MMLocation
(new MMSearch (new MMSearchFilter('client_id','eq',46)),
16) );
Our sample database of addresses in Great Britain includes the following record:
| client_id | name | street | town | pc |
|---|---|---|---|---|
| 46 | SS Great Britain | Gas Ferry Road | BRISTOL | BS1 6TY |
Multimap stores this location as a record in a table of addresses, with separate fields for name, street, town and postal (or ZIP) code: other fields (not shown in this example) contain each record's geographic coordinates, which have been geocoded by Multimap. The record also contains a field called "client_id", which has a unique value.
The Searching module 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">
startSearchRequest, endSearchRequest
If you view this in your browser you should see a Multimap draggable map initially centered as a result of a search for an address in the city of Bristol, UK, at zoom factor 15, which is automatically generated using the record's "client_id" field as a parameter.
|
|
There are three parts to the code below. The first is the line that links to the Multimap 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.
<script type="text/javascript" src="http://clients.multimap.com/API/maps/1.2/demo"></script>
Sorry, JavaScript required...
Sorry, JavaScript required...
Sorry, JavaScript required...
For more information on the subject of Multimap API JavaScript code, please read the API documentation at: http://clients.multimap.com/share/documentation/api/1.2/classes/.
The Multimap API allows you to upload your store data via Multimap's Client Zone extranet and test it in a preview environment before making the data live. To view your preview data on a web page similar to this one, specify
<script type="text/javascript" src="http://preview.multimap.com/API/maps/1.2/demo">
instead of
<script type="text/javascript" src="http://clients.multimap.com/API/maps/1.2/demo">
in the <HEAD> section of your web page.
For further details of your preview and live environments, please see Multimap's Client Zone documentation.
If you require further help with your Multimap service implementation, additional Multimap services or general account enquiries, please contact Multimap:
| Sales: | +44 (0)20 7632 7800 |
| Customer Support: | +44 (0)20 7632 7777 |
| email: | mminform@microsoft.com |