setDirectionsPanel
- paramètres spécifiques :
- id <chaîne> Id de la balise <div/> servant à l'affichage de l'itinéraie sous une forme textuelle.
- Résultat du callback : DirectionsRenderer
$('#maCarte').gmap3(
{
action:'getRoute',
options:{
origin:'rue Bretonneau 37000 Tours, FR',
destination:'Névache, FR',
travelMode: google.maps.DirectionsTravelMode.DRIVING
},
callback: function(results){
if (!results) return;
$(this).gmap3(
{
action:'init',
zoom: 5,
mapTypeId: google.maps.MapTypeId.ROADMAP,
streetViewControl: true,
center: [47, 2]
},
{
action:'addDirectionsRenderer',
//panelId: 'test-panel',
options:{
preserveViewport: true,
draggable: true,
directions:results
}
}
);
}
}
);
$('#bouton-test').click(function(){
$('#maCarte').gmap3({
action:'setDirectionsPanel',
id: 'test-panel'
});
});
Carte avec setDirectionsPanel
Code complet avec setDirectionsPanel
<!DOCTYPE html>
<html lang="fr">
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no"/>
<meta charset="UTF-8"/>
<title>Votre titre de page</title>
<style type="text/css">
html{height:100%}
body{height:100%;margin:0px;padding:0px}
#maCarte{height: 100%;}
</style>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
<script type="text/javascript" src="http://www.votredomaine.fr/js/gmap3.js"></script>
<script type="text/javascript">
$(function(){
$('#maCarte').gmap3(
{
action:'getRoute',
options:{
origin:'rue Bretonneau 37000 Tours, FR',
destination:'Névache, FR',
travelMode: google.maps.DirectionsTravelMode.DRIVING
},
callback: function(results){
if (!results) return;
$(this).gmap3(
{
action:'init',
zoom: 5,
mapTypeId: google.maps.MapTypeId.ROADMAP,
streetViewControl: true,
center: [47, 2]
},
{
action:'addDirectionsRenderer',
//panelId: 'test-panel',
options:{
preserveViewport: true,
draggable: true,
directions:results
}
}
);
}
}
);
$('#bouton-test').click(function(){
$('#maCarte').gmap3({
action:'setDirectionsPanel',
id: 'test-panel'
});
});
});
</script>
</head>
<body>
<div class="tools">
<input id="bouton-test" type="button" value="Afficher le texte de l'itinéraire" class="hidden"/>
<div id="test-panel"></div>
</div>
<div id="maCarte"></div>
</body>
</html>