Import is responsible for displaying imported geo data as markers, polylines and polygons on a map. Launched via VMLaunch().

ImportConfig parameter object

Constant prefix: ViaMichelin.Api.Constants.Import

map {container: DOMElement, focus: boolean} DOM element containing the map to plot the imported objects. focus specifies if the map should be redrawn to fit all contained graphics objects (including newly imported objects). N/A
source string It can be either a XML string or a JSON string, or a URL.
To use URL option, source value must begin with http:// substring and file must on the same domain as your application.
typeImport TYPE.IMPORT Input format of the imported file.TYPEIMPORT has one of the following values:

See conversion rules applied.


Response object in onSuccess

A ComplexLayer object type.


Main dedicated examples

Import geodata (geoJSON)

Launch this example (div2.htm)

function fLoadMap(){
 VMLaunch("ViaMichelin.Api.Map",{//Service parameters
   container : $_id("dMapContainer"),
  //Initializes map center with data from another service called in the onSuccess callback
  center : ViaMichelin.Api.Constants.Map.DELAY_LOADING,
   mapTypeControl : true
   onSuccess: function(){
    VMLaunch("ViaMichelin.Api.Import",{//Service parameters
     //Input data type
     typeImport: ViaMichelin.Api.Constants.Import.TYPE.GEOJSON,
     //'source' can also be a XML or JSON string
     source: window.location.href.replace('htm', 'json'),
     //Map container (DOM element)
     map:{container: $_id("dMapContainer"), focus:true}
      onSuccess: function(geojsonLayer){
       $_id("dStatus").innerHTML = "" + geojsonLayer.getNumberOfLayers() + " objects have been imported.";
      onError: function(error){
       alert('Whoops Import cannot be done: ' + error.errorMsg);
   onInitError: function(){
    alert('Whoops Map cannot be loaded!');

Launch this example (div2.htm)

Back to top