使用Google Directions API的动态路线:点击路线

时间:2014-11-26 06:09:35

标签: javascript google-maps

点击目的地时未生成路线路径。

function calcRoute() {
    var request = {
        origin: geolocate,
        destination: destLoc,
            travelMode: google.maps.TravelMode["Driving"]
        };
        directionsService.route(request, function(response, status) {
            if (status == google.maps.DirectionsStatus.OK) {
                directionsDisplay.setDirections(response);
            }
        });
    }
}

小提琴:http://jsfiddle.net/Wrishi/w8n7p7sf/

请帮我确定问题。

2 个答案:

答案 0 :(得分:0)

您在travelMode的定义中有错误的值。这是一个正确的:google.maps.TravelMode.DRIVING

正确的请求如下:

  var request = {
    origin: geolocate,
    destination: destLoc,
    travelMode: google.maps.TravelMode.DRIVING
  };

working fiddle

答案 1 :(得分:0)

<?php


include "db.php";
$SQL = "Select Name, Email, Department, Cellphone, Extension  from contacts";
$header = '';
$result ='';
$exportData = mysql_query ($SQL ) or die ( "Sql error : " . mysql_error( ) );

$fields = mysql_num_fields ( $exportData );

for ( $i = 0; $i < $fields; $i++ )
{
$header .= mysql_field_name( $exportData , $i ) . "\t";
}

while( $row = mysql_fetch_row( $exportData ) )
{
$line = '';
foreach( $row as $value )
{
    if ( ( !isset( $value ) ) || ( $value == "" ) )
    {
        $value = "\t";
    }
    else
    {
        $value = str_replace( '"' , '""' , $value );
        $value = '"' . $value . '"' . "\t";
    }
    $line .= $value;
}
$result .= trim( $line ) . "\n";
}
$result = str_replace( "\r" , "" , $result );

if ( $result == "" )
{
$result = "\nNo Record(s) Found!\n";
}

header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=Telephone List.xls");
header("Pragma: no-cache");
header("Expires: 0");
print "$header\n$result";

?>