MagicMirror Forum
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • 3rd-Party-Modules
    • Donate
    • Discord
    • Register
    • Login
    1. Home
    2. nickwax
    3. Posts
    A New Chapter for MagicMirror: The Community Takes the Lead
    Read the statement by Michael Teeuw here.
    N
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 0
    • Posts 1
    • Groups 0

    Posts

    Recent Best Controversial
    • RE: Can't load script correctly

      You can get leaflet to work in magic mirror quite easily. When you are creating your getDom function take the example from the tutorial as follows:

      var mymap = L.map('mapid').setView([51.505, -0.09], 13);
      L.tileLayer('https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={accessToken}', {
                  attribution: 'Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="http://mapbox.com">Mapbox</a>',
                  maxZoom: 18,
                  id: 'mapbox.streets',
                  accessToken: Your Access token
              }).addTo(this.mymap);
      

      You will also need specify the size of the of the map window in your css file

      .Your_Module_Name #mapid {
          height: 500px;
          width: 500px;
      }
      

      There is a bit of a bug with some of the map not loading, this can be fixed by listening for the DOM_OBJECTS_CREATED notification like so:

      notificationReceived: function (notification, payload, sender) {
              if (notification === "DOM_OBJECTS_CREATED") {
                  this.mymap.invalidateSize();
              }
          },
      

      This forces a redraw of the map.

      posted in Development
      N
      nickwax
    • 1 / 1