如何使用 mapquest 在传单上获取方向?
我尝试让这段代码正常工作已经有一段时间了,但没有成功。这里的目标是显示两点之间的路线,但未显示路线,我宁愿在控制台中出现此错误:
L.mapquest.key = "HmPt0Wv0aL5Bdx5Dt9U0wGH4mEQWOIG9";
let map = L.mapquest.map("map", {
center: [39.750307, -104.999472],
layers: L.mapquest.tileLayer("map"),
zoom: 14,
});
var directions = L.mapquest.directions();
directions.route({
start: "350 5th Ave, New York, NY 10118",
end: "One Liberty Plaza, New York, NY 10006",
options: {
timeOverage: 25,
maxRoutes: 3,
},
});
#map {
height: 100vh;
width: 100%;
position: relative;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Map Route</title>
<!-- LEAFLET -->
<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>
<!-- MAP QUEST -->
<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"
/>
</head>
<body style="border: 0px; margin: 0px">
<div id="map"></div>
</body>
</html>
答案 0 :(得分:0)
地图是否显示但路线未显示或根本不显示?