在 Ionic 3 上使用 MapQuest 方向路由时出现运行时异常
Getting a Runtime Exception when using MapQuest direction routing on Ionic 3
我正在使用 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"/>
我正在使用 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"/>