typescript - 在 Ionic 3 上使用 MapQuest 方向路由时出现运行时异常
问题描述
我正在使用 Ionic 3 框架,我可以成功生成地图,但在使用该L.mapquest.directions().route()
函数时收到运行时错误。
这些是进口:
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.7.1/dist/leaflet.css"
integrity="sha512-xodZBNTC5n17Xt2atTPuE1HxjVMSvLVW9ocqUKLsCC5CXdbqCmblAshOMAS6/keqq/sMZMZ19scR4PsZChSR7A=="
crossorigin=""/>
<script src="https://unpkg.com/leaflet@1.7.1/dist/leaflet.js"
integrity="sha512-XQoYMqMTK8LvdxXYG3nZ448hOEQiglfqkJs1NOQV44cWnUrBc8PkAOcXy20w0vlaXaVUearIOBhiXZ5V3ynxwA=="
crossorigin=""></script>
<script src="https://api.mqcdn.com/sdk/mapquest-js/v1.3.2/mapquest-core.js"></script>
<link type="text/css" rel="stylesheet" href="https://api.mqcdn.com/sdk/mapquest-js/v1.3.2/mapquest-core.css"/>
这些是代码:
L.mapquest.key = MapQuestKey;
this.map = L.mapquest.map('map', {
center: [lat, lng],
layers: L.mapquest.tileLayer('map'),
zoom: 13
});
L.mapquest.directions().route({
start: '350 5th Ave, New York, NY 10118',
end: 'One Liberty Plaza, New York, NY 10006',
});
错误如下所示:
ERROR Error: Uncaught (in promise):
TypeError: this._rawPxBounds is undefined _updateBounds@https://unpkg.com/leaflet@1.7.1/dist/leaflet.js:5:79584
setStyle@https://unpkg.com/leaflet@1.7.1/dist/leaflet.js:5:75174
setPathStyle@https://api.mqcdn.com/sdk/mapquest-js/v1.3.2/mapquest-core.js:6:161888
updateRibbonWidth@https://api.mqcdn.com/sdk/mapquest-js/v1.3.2/mapquest-core.js:6:163063
Mapquest 的新手,所以不确定出了什么问题。有任何想法吗?
解决方案
我从 Leaflet@1.7.1 和 mapquest-core@1.3.2 中删除了导入,只导入了 mapquest.js@1.3.2。它现在可以正常运行。
<script src="https://api.mqcdn.com/sdk/mapquest-js/v1.3.2/mapquest.js"></script>
<link type="text/css" rel="stylesheet" href="https://api.mqcdn.com/sdk/mapquest-js/v1.3.2/mapquest.css"/>
推荐阅读
- typescript - 使用 Firebase 实时数据库,在触发器中创建条目
- python - 我使用 ExcelWriter 编写了几个数据框到 excel 工作簿。但我不知道他们保存到哪里
- c++ - 除了运行时,有没有办法测量代码的性能?
- bi-publisher - 如何使用BI发布者添加每组帐号的金额
- audio - 使用编解码器 Racal 录音机将 ASF 文件转换为 wav
- codeeffects - 是否可以检查集合是否包含字段值?
- python - 如何在 macOS 中重置 Python
- javascript - 将 blob 转换为 axios 的图像
- oop - 显式和隐式变异点的含义
- python - 函数与循环的结果