VIAMICHELIN JAVASCRIPT API


Quickstart

Loading of APIJS

To load the APIJS ViaMichelin , use the script tag on the following example, on the head tag of your HTML code, with your Key number and the language used.

<script src="http://apijsv2.viamichelin.com/apijsv2/api/js?key=KEY&lang=LANG" type="text/javascript"> </script>                       

For more details about KEY and LANG, refer to the loading of the APIJS.

Geocoding component

This example shows how a geocoding component is implemented, on an unique field address.

Configuration of the component

For a single search, you have to use the « singleFieldSearch » property

 

var conf = {
  singleFieldSearch : "88 cours de l'ile seguin, 92100 Boulogne-billancourt"
};               

Declaration of the callback

To get the result of the search, you have to design your method within the onSuccess event function of the callbacks variable

var callbacks = {
  onSuccess : function (result) {
    var coords = result[0].coords;
    console.log("Longitude : ", coords.lon);
    console.log("Latitude : ", coords.lat);
  }
};               

The launch of the search

“ViaMichelin.Api.Geocoding” is the name of the geocoding component. It works with the VMLaunch function and set by two parameters, call and callbacks.

VMLaunch("ViaMichelin.Api.Geocoding", conf, callbacks);  

The result on the console

Longitude :  2.23354
Latitude :  48.82696

Demonstration

To check the result, consult the page demonstration