directionsService.route不会返回绑定div的数据

时间:2012-09-19 05:28:33

标签: javascript google-maps-api-3

我正在做一些js来获取asp.net的指示面板

<!-- language: lang-js -->

var directionsDisplay;
var directionsService = new google.maps.DirectionsService();
var map;

function initialize() {
    directionsDisplay = new google.maps.DirectionsRenderer();
    var chicago = new google.maps.LatLng(41.850033, -87.6500523);
    var mapOptions = {
        zoom:7,
        mapTypeId: google.maps.MapTypeId.ROADMAP,
        center: chicago
    }
    map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
    directionsDisplay.setMap(map);
    directionsDisplay.setPanel(document.getElementById("directionsPanel"));
}


function calcRoute(lat,lan) {
    var InitialOrigin =  document.getElementById('ctl00_ContentPlaceHolder1_FESearchListingControl1_txtHide').value;
    //var InitialOrigin = document.getElementById("txtHide").Value;
    var technopark = new google.maps.LatLng(8.5572357 ,76.87649310000006 );

    var split = InitialOrigin.split(',');
    var latFrom = parseFloat(split[0]);
    var lanFrom = parseFloat(split[1]);
    InitialOrigin= new google.maps.LatLng(latFrom,lanFrom);
    var to = new google.maps.LatLng(lat,lan);
    //  var start = document.getElementById("start").value;
    //  var end = document.getElementById("end").value;
    var request = {
        origin:InitialOrigin,
        destination:to,
        travelMode: google.maps.TravelMode.DRIVING
    };
    directionsService.route(request, function(response, status) {
        if (status == google.maps.DirectionsStatus.OK) {
            directionsDisplay.setDirections(response);
        }
        else
        {
            console.log('something went wrong',status);
        }
    });
}

我使用crome浏览器进行了调试,可以找到该行

directionsService.route(request, function(response, status) {

没有返回任何内容,调试器只是跳到了最后一个结束括号。 调试器从未输入此if语句

if (status == google.maps.DirectionsStatus.OK) {
    directionsDisplay.setDirections(response);
}
else
{
    console.log('something went wrong',status);
}

这之前有用,而且我之前收到了指示小组,谷歌是否有一些限制?

0 个答案:

没有答案