Exemples divers
Insérer un logo sur des coordonnées géographiques
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>ViaMichelin Maps & Drive API</title>
<script src="http://api.viamichelin.com/apijs/js/api.js"
type="text/javascript"></script>
<script type="text/javascript">
VMAPI.registerKey("JSBS20070201123465789");
VMAPI.setLanguage("fra");
function initialise_adresse_et_carte(){
var map = new VMMap(document.getElementById("yourmapdiv"));
var localisation_entreprise = new VMLonLat(2.24344,48.83381);
map.drawMap(localisation_entreprise, 15);
var image = new VMIcon('http://dev.viamichelin.fr/wswebsite/fra/img/petit_bib.gif',-12,-12);
var coucheImage = new VMIconLayer(
localisation_entreprise,
image,
"Via Michelin"
);
map.addLayer(coucheImage);
map.showMapTools();
}
</script>
</head>
<body onload="initialise_adresse_et_carte();">
<h1>ViaMichelin - Exemple de logo</h1>
<p>Insérer un logo sur une carte</p>
<div id="yourmapdiv" style="width:400px; height:320px"></div>
</body>
</html>
Documentation associée
Lire les coordonnées actuelles de la carte
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>ViaMichelin Maps & Drive API</title>
<script src="http://api.viamichelin.com/apijs/js/api.js"
type="text/javascript"></script>
<script type="text/javascript">
VMAPI.registerKey("JSBS20070201123465789");
VMAPI.setLanguage("fra");
var map;
function initialise_adresse_et_carte(){
map = new VMMap(document.getElementById("yourmapdiv"));
map.drawMap(new VMLonLat(2.24344,48.83381), 15);
map.showMapTools();
}
function coordonnees(){
alert(map.getCenter());
}
</script>
</head>
<body onload="initialise_adresse_et_carte();">
<div id="yourmapdiv" style="width: 500px; height: 500px"></div>
<input type="button" value="Calcul des coordonnées"
onclick="coordonnees()" />
</body>
</html>
Documentation associée
Réaliser un export GPS
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>ViaMichelin Maps & Drive API</title>
<script src="http://api.viamichelin.com/apijs/js/api.js"
type="text/javascript"></script>
<script type="text/javascript">
VMAPI.registerKey("JSBS20070201123465789");
VMAPI.setLanguage("fra");
function geocoder_search(){
geocoder = new VMGeocoder();
myaddress = new VMAddress();
var elements_formulaire =
document.forms['geocoder_form'].elements;
myaddress.address = elements_formulaire['form_address'].value;
myaddress.zipCode = elements_formulaire['form_CP'].value;
myaddress.city = elements_formulaire['form_city'].value;
myaddress.countryVMCode = elements_formulaire['country'].value;
geocoder.addEventHandler("onCallBack",export_function);
geocoder.search(myaddress);
}
function load_country(){
VMCountryUtil.addEventHandler(
"onCallBack",
function(){
document.getElementById("div_country").innerHTML
= VMCountryUtil.getSelectHTMLString("country","FRA");
}
);
VMCountryUtil.loadCountryLabels();
}
function export_function(){
myexport = new VMExportAsXVM();
myexport.exportXVM(geocoder.result,"export_file");
}
</script>
</head>
<body onload="load_country();">
<h1>ViaMichelin - Exemple d'export</h1>
<p>Exporter des coordonnées pour votre GPS</p>
<form name="geocoder_form">
<label for="form_address">Adresse :</label>
<input type="text" value="Place des Carmes-Déchaux"
name="form_address" id="form_adress" />
<br />
<label for="form_CP">Code Postal :</label>
<input type="text" value="63040" name="form_CP"
id="form_CP" />
<br />
<label for="form_city">Ville :</label>
<input type="text" value="CLERMONT-FERRAND"
name="form_city" id="form_city" />
<br />
<label for="form_country">Pays :</label>
<div id="div_country"></div>
<br />
<input type="button" value="Tester" onclick="geocoder_search();">
</form>
</body>
</html>
Documentation associée