Skip to content
Discussion options

You must be logged in to vote

The extra_javascript section is included after the JavaScript of Material for MkDocs and after the content, so I think the problem might be related to your JavaScript running before the Leaflet library is available. Other than that, your code looks correct.

Running your code after the document has been fully loaded by awaiting for DOMContentLoaded might do the trick:

<div id="map"></div>

<script type="text/javascript">
  document.addEventListener("DOMContentLoaded", function() {
    var mymap = L.map('map').setView([51.505, -0.09], 13);

    L.tileLayer('https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token={accessToken}', {
      attribution: 'Map data &copy; <a href="htt…

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
4 replies
@AyrtonB
Comment options

@squidfunk
Comment options

@squidfunk
Comment options

@AyrtonB
Comment options

Answer selected by AyrtonB
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants