【问题标题】:LeafLet to show between placesLeafLet 在地方之间显示
【发布时间】: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.

任何与此相关的示例? 或者我可以使用的任何其他开源地图?

【问题讨论】:

  • 如果我错了,有人纠正我,但我不认为 Leaflet 可以做到这一点。如果你想做一些事情,你可以使用MapQuestrouting

标签: javascript leaflet


【解决方案1】:

您可以使用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: '&copy; <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);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-06-25
    • 2023-02-05
    • 1970-01-01
    • 2021-08-18
    • 2021-07-11
    • 2020-10-07
    • 1970-01-01
    • 2017-01-16
    相关资源
    最近更新 更多