【发布时间】:2014-11-06 15:34:30
【问题描述】:
我在我的项目中使用传单地图。
Suppose I have two markers in my map say A and B
then how can i show direction from A to B place using leaflet.
任何与此相关的示例? 或者我可以使用的任何其他开源地图?
【问题讨论】:
标签: javascript leaflet
我在我的项目中使用传单地图。
Suppose I have two markers in my map say A and B
then how can i show direction from A to B place using leaflet.
任何与此相关的示例? 或者我可以使用的任何其他开源地图?
【问题讨论】:
标签: javascript leaflet
您可以使用Leaflet Routing Machine 插件,如link 所示。您只需要包含适当的 css 和 js 文件:
<link rel="stylesheet" href="leaflet-routing-machine.css" />
<script src="leaflet-routing-machine.min.js"></script>
然后做这样的事情:
var map = L.map('map');
L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);
L.Routing.control({
waypoints: [
L.latLng(57.74, 11.94), //first marker position
L.latLng(57.6792, 11.949) //second marker position
]
}).addTo(map);
【讨论】: