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

    Posts

    Recent Best Controversial
    • RE: Trafficmaps

      @tyho @alexyak

      Wow guys thanks! I was a few steps behind tyho trying to get the google maps traffic option to work. I searched every few weeks for this and finally came upon this thread. I have a traffic map on my magic mirror now!!!

      For any super beginners (like myself) here are a few notes to add this to my magic mirror page.

      • Create a dir in your modules dir (ex: MagicMirror/modules/maproute/
      • Create a file called maproute.js (ex: MagicMirror/modules/maproute/maproute.js) This is where you copy in the code above that alexyak posted
      • Edit your config.js file to add the module to your page:
        I don’t think position and config are required but I stuck them in there and it works ok.
      {
                            module: 'maproute',
                            position: 'top_right',
                            config: {}
                      },
      
      

      Restart your pi or restart the magic mirror service and you should be all set!

      If I missed anything or anything is wrong, please let me know

      The map is cut off in my screenshot but I haven’t changed the sizing or anything yet.

      0_1473042805581_magicmirror-bingtraffic.jpg

      posted in Development
      W
      wscheer
    • RE: Trafficmaps

      @strawberry-3-141 Ding! Ding! Ding! That was it! THANK YOU!

      Also thanks again to @alexyak and @tyho for their input.

      I’ll post the code for anyone who wants Bing Traffic maps on their Magic Mirror.

      It’s a little hackish but maybe someone will come along and write it the correct way. Basically I’m taking the pushpin (pp) parameter and just assigning two random numbers to it. Math.random() creates a number between 0 and 1. So the map never shows the pushpin on the area I’m at. This causes the information to be “new” so when updateDom() is called, the info has changed.

      For any beginners, here is my file structure setup:
      The code below is located: /var/www/html/MagicMirror/modules/maproute/maproute.js

      Module.register("maproute", {
              defaults: {
                      latitude: '40.4406', // City latitude. Use google to get these coordinates
                      longitude: '-79.9959', // City longitude
                      map_zoom: '12', // 1 - 21
                      map_layer: 'TrafficFlow', 
                      map_size: '500', // Using this for both length and width
                      api_key: '123456789', // Your Bing maps api key
                      updateInterval: 300000 // 5 min refresh
              },
              getDom: function() {
                      var wrapper = '';
                      wrapper = document.createElement("img");
                      // The Math.random() calls are to place a random pushpin on the map and make the updateDom() call refresh
                      wrapper.src = "http://dev.virtualearth.net/REST/v1/Imagery/Map/Road/" + this.config.latitude + "," + this.config.longitude + "/" + this.config.map_zoom + "?mapSize=" + this.config.map_size + "," + this.config.map_size + "&pp=" + Math.random() + "," + Math.random() + "&ml=" + this.config.map_layer + "&key=" + this.config.map_key;
                      return wrapper;
              },
      	start: function() {
      		var self = this;
      		setInterval(function() {
      			self.updateDom(5000); // I set a 5 second refresh here for testing.
      		}, this.config.updateInterval);
      	},
      });
      
      posted in Development
      W
      wscheer
    • 1 / 1