Google Maps with traffic info



  • Unfortunately I can’t write (understand) softwarecode so I hope someone will help me.

    There are some traffic modules but they only give you information from A to B. Is it possible to create and show a map (Google?) which shows a region of a country with traffic jams?

    In Google Maps it is possible to show a (fullscreen) map with a traffic layer, see https://www.google.nl/maps/@52.0357403,4.8328404,9.25z/data=!5m1!1e1

    It doesn’t have to be a fullscreen map. It would be nice if you can zoom in a particular area of a country.



  • You could add the map using the iframe module (https://github.com/desertblade/iFrame). Provide the URL you linked to in your post in the configuration; or any other Google Maps URL.



  • I was able to achieve this with MMM-iFrameReload and an html file in that folder… It looks something like this.

    {
    module: ‘MMM-iFrameReload’,
    header:‘Traffic Map’,
    position: ‘top_right’, // This can be any of the regions.
    config: {
    // See ‘Configuration options’ for more information.
    url: “http://localhost:8080/modules/MMM-iFrameReload/nameofhtmlfile.html”,
    width: “580px”, // Optional. Default: 400px
    height: “1100px”, // Optional. Default: 800px
    refreshInterval: 600 //Optional. Default: 3600 = 1 hour
    }
    },

    with this code below to make the map and save the html in the iframe folder

    https://developers.google.com/maps/documentation/javascript/examples/layer-traffic



  • @onetwankyfive

    Hi 1twanky5,

    Thanks for helping me out :)

    Tried it, does’nt work unfortunately. Created an HTML.file (Randstad.html) and punt in the folder MagicMirror/modules/MMM-iFrameReload. See below the lines in my config file.

    	{
    		module: 'MMM-iFrameReload',
    		position: 'middle_center', 
    		config: {
    			url: '/home/pi/MagicMirror/modules/MMM-iFrameReload/Randstad.html',
    			height: '800px',
    			width: '600px', 
    			refreshInterval: 600 //Optional. Default: 3600 = 1 hour
    			}
    	},
    

    Tried the URL in a browser and that worked. But when I start MagicMirror , the screen turns black. Am I doing something wrong?

    Thanks in advance.



  • @Leliekevertje

    I think your url needs to be:

    url: 'http://localhost:8080/modules/MMM-iFrameReload/Randstad.html',
    

    That’s certainly how it works for me.

    A great addition to the MagicMirror.



  • Hi Honzup,

    Lost in lots of “try and error” situations but now I’m on the right path. Thanks it works great!

    If anyone have any suggestions to make te screen gray in stead of the default colors from Google, I love to hear it!



  • @Leliekevertje
    Google Maps API provides styling capabilities: https://developers.google.com/maps/documentation/javascript/styling

    There is a quite extensive collection of styles you can utilize here: https://snazzymaps.com/explore. Just copy the given JSON from snazzymaps into the styles parameter of GMaps API.



  • Thanks for all the help, I really appriciate this!

    I could not get rid of the (in my opinion ugly) green color which marks highways (with no traffic) with the Google styling as mentioned in the reply of bradyemerson.

    I’ve found another solution within the MM Forum so I’ve copy/pasted it. Don’t know if this code is properly correct but it works for me and maybe others can benefit from it.

    In the module MMM-iFrameReload i’ve changed te line:
    iframe.style = “border:0”

    in:
    iframe.style = “border:0;-webkit-filter: grayscale(100%);filter: grayscale(100%);”


Log in to reply
 

Looks like your connection to MagicMirror Forum was lost, please wait while we try to reconnect.