1

我正在做一些 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);
}

这是以前的工作,我之前得到了方向面板,谷歌有一些限制吗?

4

0 回答 0