문제

DirectionSrenderer를 사용하여 경로 목록이없는 DirectionStult를 표시하려고합니다. API 버전 3 문서에 따르면, DirectionSrenderOptions 객체의 "HideroutEList"속성이있어 True로 설정할 때 경로 목록을 숨겨야합니다. 나는 그것을 작동시킬 수 없다. 이것은 버그입니까 아니면 내가 이것을 올바르게 코딩하지 않습니까? 다음은 내 코드입니다.

<html>
<head>
<title>Driving Directions</title>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false">    </script>
<script type="text/javascript">
<!--
function initialize() {
    var dirService = new google.maps.DirectionsService();
    var dirRequest = {
          origin: "350 5th Ave, New York, NY, 10118",
          destination: "1 Wall St, New York, NY",
          travelMode: google.maps.DirectionsTravelMode.DRIVING,
          unitSystem: google.maps.DirectionsUnitSystem.IMPERIAL,
          provideTripAlternatives: true
    };
    dirService.route(dirRequest, showDirections);
}

function showDirections(dirResult, dirStatus) {
    if (dirStatus != google.maps.DirectionsStatus.OK) {
        alert('Directions failed: ' + dirStatus);
        return;
    }
    var rendererOptions = {
        hideRouteList: true
    };
    var dirRenderer = new google.maps.DirectionsRenderer(rendererOptions);  
    dirRenderer.setPanel(document.getElementById('dir-container'));
    dirRenderer.setDirections(dirResult);
}
-->
</script>
</head>
<body onLoad="initialize();">
<div id="dir-container"></div>
</body>
</html>
도움이 되었습니까?

해결책

이것을 시도했습니다 그리고 나는 당신이 잘못하고 있다고 생각하지 않습니다. 이 옵션이 고장난 것 같습니다. 나는 그것을 찾을 수 없었다 알려진 문제, 그래서 나는 이것이 새로운 것이라고 생각합니다. 기회가 생기면 쓸 것입니다.

다른 팁

나는 당신이 문서를 오해하고 있다고 생각하거나 아마도 당신의 질문을 오해하고 있다고 생각합니다!

HIDEROUTELIST : Route Markup이 아닌 True Hides Route 옵션. 이것은 제공 한 요청 객체에서 PrudiderOuteAlternatives를 설정하는 것과 함께 적용됩니다.

아래는 빠른 테스트입니다. 아래 경로 마크 업의 차이점을 확인하려면 HideroutEList를 True/False로 설정하십시오. 제 경우에는 경로 옵션이 없지만 마크 업이 다릅니다.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>Driving Directions example.</title>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">


    $(function () {
        MySite.MapAdmin.init();
    });


    var MySite = {};

    MySite.MapAdmin = {
        mapOptions: {
            zoom: 14,
            mapTypeId: google.maps.MapTypeId.ROADMAP,
            center: new google.maps.LatLng(46.51257, -84.336609)
        },
        mapRendererOptions: {
            draggable: true,
            panel: document.getElementById('map-directions'),
            hideRouteList: false
        },
        directionDisplay: null,
        directionsService: null,
        map: null,
        init: function () {

            this.map = new google.maps.Map(document.getElementById("map"), this.mapOptions);            
            this.directionsService = new google.maps.DirectionsService();
            this.directionsDisplay = new google.maps.DirectionsRenderer(this.mapRendererOptions);           
            this.directionsDisplay.setMap(this.map);

            this.plotRoute();

        },
        plotRoute: function () {

            var selectedMode = "DRIVING"; // DRIVING, WALKING, BICYCLING

            var request = {
                origin: new google.maps.LatLng(46.51257, -84.336609),
                destination: new google.maps.LatLng(46.61257, -84.336609),
                travelMode: google.maps.DirectionsTravelMode[selectedMode],
                provideRouteAlternatives: true
            };

            MySite.MapAdmin.directionsService.route(request, function (response, status) {
                if (status == google.maps.DirectionsStatus.OK) {
                    MySite.MapAdmin.directionsDisplay.setPanel(document.getElementById('map-directions'));
                    MySite.MapAdmin.directionsDisplay.setDirections(response);
                }
            });

        }
    };


</script>

</head>
<body>
    <div id="map" style="width: 800px; height: 600px;"></div>
    <div id="map-directions"></div>
</body>
</html>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top