Leaflet and Mapquest: Uncaught (in promise) TypeError: Cannot read property 'min' of undefined

392 views Asked by At

How to get direction on leaflet with mapquest?

It's been a while I try to make this code work without success. The objective here is to display the route between two points but the route is not displayed and I rather have this error in console:

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/[email protected]/dist/leaflet.css"
      integrity="sha512-xodZBNTC5n17Xt2atTPuE1HxjVMSvLVW9ocqUKLsCC5CXdbqCmblAshOMAS6/keqq/sMZMZ19scR4PsZChSR7A=="
      crossorigin=""
    />

    <script
      src="https://unpkg.com/[email protected]/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>

1

There are 1 answers

8
MQBrian On

Does the map show up but the route does not get displayed or does the not show up at all?