【发布时间】:2020-10-20 04:59:33
【问题描述】:
我可以在传单地图中使用 Open Route Service api 吗?我找不到工作示例来展示如何在地图上集成 api 密钥。现在我正在使用graphhopper,它工作完美,但现在它最多只能使用5个点。
当我尝试通过开放路线服务制作航点时,我显示此错误:Uncaught TypeError: L.Routing.openrouteservice is not a constructor
我的代码:
var mymap = L.map('mapid').setView([50.27264, 7.26469], 13);
L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '© OpenStreetMap contributors and ORS'
}).addTo(this.mymap);
var control = L.Routing.control({
waypoints: [
L.latLng(3.102739, 101.598077),
L.latLng(3.101861, 101.599037)
],
router: new L.Routing.openrouteservice('5b3ce3597851110001cf6248e3cd48b3c44c4e529f8fac67408d4257')
// routeWhileDragging: true
}).addTo(this.mymap);
【问题讨论】:
-
您的项目中确实包含了来自lrm-openrouteservice 的
L.Routing.OpenRouteService.js文件? -
我用 npm 安装了它,但它不起作用。我找不到其他 CDN 库可以尝试
-
你是怎么带进来的?带有
import声明?您还可以将source code 复制到项目中的文件中,并在 html 标头中链接该文件 -
我现在尝试使用源代码,但它给出了同样的错误。我还包含了所有 js 库 - 传单、路由机,但看不到有什么问题......