tengo una base de datos con las coordenadas del punto y el nombre. en mi codigo muestro como le paso las coordenadas. y siquiera tambien pasarle el nombre asi al hacerle click sobre el punto me sale el nombre y no la ruta donde se encuentra.
muchas gracias
Código:
<?php $location = "{location: '(-25.285176773048878, -57.621145924072266)'},{location: '(-25.2847499309663, -57.587972362976075)'} "; ?> <html> <head> <title>google mapss</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <link rel="shortcut icon" type="image/x-icon" href="images/titulo.png"/> <script src="js/jquery-1.3.1.min.js" type="text/javascript"></script> <script src="js/jquery.functions.js" type="text/javascript"></script> <link href="http://code.google.com/apis/maps/documentation/javascript/examples/standard.css" rel="stylesheet" type="text/css" /> <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false&language=es"></script> <script type="text/javascript"> var rendererOptions = { draggable: true }; var directionsDisplay = new google.maps.DirectionsRenderer(rendererOptions);; var directionsService = new google.maps.DirectionsService(); var map; var asuncion = new google.maps.LatLng<?php include"posicion_empresa.txt"; ?>; function initialize() { var myOptions = { zoom: 7, mapTypeId: google.maps.MapTypeId.ROADMAP, center: asuncion }; map = new google.maps.Map(document.getElementById("map_canva s"), myOptions); directionsDisplay.setMap(map); directionsDisplay.setPanel(document.getElementById ("directionsPanel")); google.maps.event.addListener(directionsDisplay, 'directions_changed', function() { computeTotalDistance(directionsDisplay.directions) ; }); calcRoute(); //flightPath.setMap(map); } function calcRoute() { var request = { origin: "(-25.26445379695485, -57.552996357421875)", destination: "(-25.26445379695485, -57.552996357421875)", waypoints:[<?php echo $location; ?>], travelMode: google.maps.DirectionsTravelMode.DRIVING }; directionsService.route(request, function(response, status) { if (status == google.maps.DirectionsStatus.OK) { directionsDisplay.setDirections(response); } }); } function computeTotalDistance(result) { var total = 0; var myroute = result.routes[0]; for (i = 0; i < myroute.legs.length; i++) { total += myroute.legs[i].distance.value; } total = total / 1000. //document.getElementById("total").innerHTML = total + " km"; //document.getElementById('km').value = total; } function cerrarVentana(){ var ventana = window.self; ventana.opener = window.self; ventana.close(); } </script> </head> <body onLoad="initialize()"> <div id="map_canvas" style="float:right;width:70%; height:100%"></div> <div id="directionsPanel" style="float:left;width:30%;height:100%;overflow:a uto"> <p> <span id="total"></span></p> </div> </div>