1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
| <!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<title>VEMap.Geocode Method</title>
<meta name="Author" content="NoSmoking">
<script src="http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=5"></script>
<style>
html, body {
padding: 0;
margin: 0;
font: 1em/1.25em Verdana,Arial,sans-serif;
letter-spacing: 0.015em;
}
#page{
width:60em;
margin:auto;
}
#page h1 {
color: #006699;
}
#myMap{
margin:0 auto;
border:1px solid #AAF;
}
.myMapContainer{
position:relative; /* impératif */
width:42em;
height:38em;
margin:auto;
}
</style>
<script>
var map = null;
function getURLParameter(name){
if(name=(new RegExp('[?&]'+encodeURIComponent(name)+'=([^&]*)')).exec(location.search))
return decodeURIComponent(name[1]);
}
function GetMap(){
// objet option carte
var oCarte = {
'centre': new VELatLong(46.80, 1.70),
'zoom' : 6,
'unit' : VEDistanceUnit.Kilometers
}
// récup. de l'adresse
var adresse = getURLParameter('adresse') || '13 rue du dragon paris';
// masque la div au départ
var oDivMap = document.getElementById('myMap');
oDivMap.style.visibility = 'hidden';
// création de la map
map = new VEMap('myMap');
// charge la map
map.LoadMap( oCarte.centre, oCarte.zoom);
map.SetScaleBarDistanceUnit( oCarte.unit);
// lance la recherche
map.Geocode( adresse, function( shapeLayer, findResults, places, moreResults, errorMsg){
if( !errorMsg && places[0]){
var location = places[0].LatLong;
var shape = new VEShape( VEShapeType.Pushpin, location);
map.AddShape( shape);
}
else{
alert( errorMsg);
}
// affiche la map au retour
oDivMap.style.visibility = 'visible';
});
}
</script>
</head>
<body onload='GetMap();'>
<div id="page">
<h1>VEMap.Geocode Method</h1>
<div id='myMap' class="myMapContainer"></div>
</div>
</body>
</html> |
Partager