J'ai écris une fonction Javascrispt qui permet de tracer un itinéraire à partir d'un ensemble d'adresses mais je suis confronté à un problème. le problème c'est que je ne peux pas dépasser dix (10) adresses. Au secours! la fonction est la suivante: //string en tableau function stringSplit(ch) { var reg=new RegExp("[#]+", "g"); //document.write("Chaîne d'origine : " + ch+ "<BR>"); var tab=new Array(); var tableau=ch.split(reg); tab=ch.split(reg); return tab; } function route() { var i; /*var reg=new RegExp("[#]+", "g"); var tableau=chaine.split(reg);*/ function destinationtAd(_adress) { this.adresse = _adress; } // déclaration des variables var chaine=document.getElementById('Adr').value; var tableau=stringSplit(chaine); //appel fonction split var destinationCoord=new Array; for (i=0; i<tableau.length ; i++) { destinationCoord[i] = new destinationtAd(tableau[i]); } var lat = new Array; var lng = new Array; for(i = 0 ; i < tableau.length ; i++) { //var Coord = var geo=geolocalise(destinationCoord[i].adresse); pausecomp( alert("longitude :"),2000); lat[i] = latitude; lng[i] = longitude; }
if (origin == null) { origin = new google.maps.LatLng(lat[0], lng[0]); addMarker(origin); } if (destination == null) { destination = new google.maps.LatLng(lat[1], lng[1]); addMarker(destination); } i = 2; do{ waypoints.push({ location: destination, stopover: false}); destination = new google.maps.LatLng(lat[i],lng[i]); addMarker(destination); i++; }while(i < tableau.length); if (origin == null) { alert("Click on the map to add a start point"); return; } if (destination == null) { alert("Click on the map to add an end point"); return; } var request = { origin: origin, destination: destination, waypoints: waypoints, travelMode: google.maps.DirectionsTravelMode.DRIVING, optimizeWaypoints: document.getElementById('optimize').checked, avoidHighways: document.getElementById('highways').checked, avoidTolls: document.getElementById('tolls').checked }; directionsService.route(request, function(response, status) { if (status == google.maps.DirectionsStatus.OK) { directionsDisplay.setDirections(response); } }); clearMarkers(); directionsVisible = true; } function pausecomp(millis) { var date = new Date(); var curDate = null; do { curDate = new Date(); } while(curDate-date < millis); } function geolocalise(addr) { geocoder.geocode({'address': addr }, function (results, status) { /* Si g?ocalisation r?sie */ if (status == google.maps.GeocoderStatus.OK) { /* R?p?tion des coordonn? */ latitude = results[0].geometry.location.lat(); longitude = results[0].geometry.location.lng(); } }); } function addMarker(latlng) { markers.push(new google.maps.Marker({ position: latlng, map: map, clickable: true, icon:new google.maps.MarkerImage('bus.png') })); } Prière de jeter un coup d'oeil. Merci pour votre aide. -- You received this message because you are subscribed to the Google Groups "Google Maps JavaScript API v3" group. To view this discussion on the web visit https://groups.google.com/d/msg/google-maps-js-api-v3/-/aAfRmjViu54J. To post to this group, send email to google-maps-js-api-v3@googlegroups.com. To unsubscribe from this group, send email to google-maps-js-api-v3+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-maps-js-api-v3?hl=en.