我正在尝试使用 DirectionsRenderer 来显示没有路线列表的 DirectionsResult。根据 API 版本 3 文档,DirectionsRendererOptions 对象有一个“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>