我有一个使用API v3的谷歌地图,它可以获取从一个位置到另一个位置的路线.该应用程序运行良好,但获取方向的窗口是地图上的叠加.我喜欢它,所以当这个窗口关闭时,方向将从地图上移除,但其他标记仍然存在.
我尝试过以下方法:
$('#content .close').live('click', function() {
$('#content').hide();
directionDisplay = new google.maps.DirectionsRenderer();
directionDisplay.suppressMarkers = true;
directionDisplay.setMap(map);
return false;
});
Run Code Online (Sandbox Code Playgroud)
这似乎隐藏了预期的窗口,但没有做任何关于从地图中删除方向的问题.
任何帮助深表感谢.
戴夫.
要从地图中删除普通标记,我理解您只需调用marker.setMap(null),但在实施Google Maps路线服务时,它会自动将标记A和B添加到地图上(计算从A点到B点的方向) .我无法控制这些标记,所以我无法以正常方式删除它们.那么如何删除这些标记(我在地图上有自定义标记)?
我在角度应用程序中使用ng-map.在我的地图我使用方向,但我不需要A和B点.请帮我隐藏这些标记.我有一个解决方案, 但它没有帮助ng-map.那是我怎么说的.
<ng-map zoom="14"
center="1135 Karamea-Kohaihai Rd, Kahurangi National Park, Tasman"
style="height:90%" >
<directions
draggable="true"
panel="p2"
travel-mode="DRIVING"
origin="1135 Karamea-Kohaihai Rd, Kahurangi National Park, Tasman"
destination="Pier St, Jackson Bay, West Coast, New Zeland" suppressMarkers='true'>
</directions>
<custom-marker id="start"
position="1135 Karamea-Kohaihai Rd, Kahurangi National Park, Tasman">
<div> Start point </div>
</custom-marker>
<custom-marker id="end"
position="Pier St, Jackson Bay, West Coast, New Zeland">
<div> Ends point </div>
</custom-marker>
</ng-map>
Run Code Online (Sandbox Code Playgroud)
或者我可能没有正确使用它.检查这个plunker.救命
我有一个谷歌地图,我可以在源地和目的地路线之间添加多个点/站点(航路点).
创建路径(google.maps.DirectionsService)并放在地图上(google.maps.DirectionsRenderer)后,您可以拖动路线中间点以根据需要调整路线 - 在构造函数中设置draggable = true DirectionsRenderer.
directionsDisplay = new google.maps.DirectionsRenderer({
suppressMarkers: true,
draggable:true
});
Run Code Online (Sandbox Code Playgroud)
问题是当我通过拖动改变两个停靠点之间的路线时,我再次想要通过拖动相同的改变的路线点来改变路线,它不允许我.
但是,如果我设置suppressMarkers: false,那么它运作良好.因为我必须放置自定义标记我不能标记suppressMarkers为true.
任何帮助将受到高度赞赏.
javascript google-maps google-maps-api-3 google-maps-markers