Rich, that’s brilliant! Thank you so much, The google maps wiidget on a wall mounted tablet was the single most used part of our home openhab set-up so this iis really really helpful!
Is there something special I need to do to prep my OH for it? I’m getting an error message trying to install it.
I wasn’t sure about the last gm_travel value (Y, N, 1, 0, Yes, No or some other value??) and whether I’d need to add all the other variables into the URL such as origin, destination etc even though I don’t want the travel times. You’re probably gonna tell me (I’m sure) that I need to add all the variables in
You probably have to add all of them but I’m not an expert in that map.html file. It works differently from what my widget does.
it should work now. I love having a log reader built in to MainUI. I messed up the marketplace post by not tagging the code fence with YAML.
If you didn’t want traffic for a path, you may want to change the URL in the widget. The Google Maps API has several different modes and the widget uses the directions mode.
and then delete the props you are not using any more (you can edit the widget under developer tools → widgets → rlk_google. Then you can add and configure it as a card on a layout page.
I don’t know how to show traffic though. That might not be possible through this approach.
It might make sense to explore Waze as an alternative. * didn’t think that needs an api key.
Hi Rich, whatever ‘tagging the code fence with YAML’ means has worked, at least it allows me to install the widget so more progress.
I’m now getting a different error. I’ve created a new API for this widget and restricted it to the Maps JavaScriipt API (which I assume is what this uses?) and I get an API key error. There’s no issue with my Google Cloud account as I’m well under my quota usage, I even tried taking out the Maps JavaScriipt API restriction but this hasn’t helped. Maybe it’s something specific in the Google Cloud console I need to set?
I’ve tried using the API key that the fully functioning HabPanel widget uses (rather than the new one) but get the same result.
Happy to try going down the long URL route but it’s really the local traffic info that’s useful for us rather than a particular route / travel time. The HabPanel widget does this perfectly
The error is something to do with your API key. I can’t help with any more than that. I’m not a Google API expert. Maybe there’s something in the logs on the Google side. Beyond that
Hi Rich, I do appreciate you’re not a Google API expert and your efforts to get it this far have been fantastic and very much appreciated.
So I managed to get it working by enabling more than just the JavaScript API. There’s a whole host of different Map APIs offered these days it seems.
Through a process of trial and error I found out that:
The old HabPanel widget seems to use the Maps JavaScript API and stops working if I disable it.
Your widget seems to need the Maps Embed API and stops working if I disable it.
It also seems there’s a whole raft of API pricing changes coming from Google on 1st March 25 so anyone using this best take a look at put some quotas in place to avoid being charged for API usage over the free thresholds.
The only difference between your new MainUI widget and the old HabPanel widget, is that the old widget shows traffic information on the entire map area, and your widget only shows it on route between the 2 destinations.
Having the traffic overview for the entire map area and not just the travel route was the key thing that the old HabPanel widget gave us.
It appears only the JavaScript API supports showing traffic. I don’t want to require a separate file to be installed to install a marketplace widget so that widget probably will never show to traffic conditions.
However, Waze’s live map supports embedded maps and it doesn’t require an API key. It’s pretty much the same approach as the widget I already posted consisting of a webview and a URL with arguments. If I get a few minutes later today I’ll make a go at a Waze version.
In the mean time, to get traffic from Google Maps you have to use the map.html file.
So far it looks like it might. It’s free and doesn’t require an API key. Waze tends to be more details and faster to update than Google Maps. The traffic info from Google Maps in fact comes from Waze. Both are owned by Google though.
Waze is much less capable compared to even the Google Maps embedded URL API but it does show live traffic. It works basically the same way. You can mess with the parameters passed on the URL if you need to (e.g. delete the “&pin=1” to remove the pin icon.
I also added a rule template that uses Waze to calculate the time and distance between two points given traffic conditions. The idea (for me at least) is to get an alert in the morning when traffic is backing up because there’s yet another accident on the interstate.
Again this is using the Waze API so there’s no charge. But don’t abuse it or your IP will be banned.