Google Maps widget with traffic

@bastiaan_van_h, could you maybe make your widget to reload on own selected number?
I think every 10s is quite often. And as free tier of 20000 requests for advanced distance matrix is quickly used up and you’ll have to pay for it after that per month.
I mean, every 5 minutes would be great and still pretty accurate.

Hello together,

I configured the widget and got the api. But the widget just shows the map without route and without data in the small box on the top left.

The api I configured that also direction request are allowed. On the google api page it shows that there are direction requests but that all of them are faulty.

Any idea what could be the reason?

Regards
Stefan

Within the maps.html file, the reload time is already set to 5 minutes.

You can change it by setting the last number in this code block in miliseconds:

window.setInterval(function(){
			console.log("Updating Google Maps traffic and travel time");
			reloadTiles();
			if (gm_travel == 'true') {
				directionsDisplay.set('directions', null);
				calculateAndDisplayRoute();
			}
		}, 300000);

Hello together,

Got the widget working now.
Needed to get an additional API:

  • Directions API
  • Maps JavaScript API

Regards
Stefan

Hmm, could be that my habpanel page is loaded every 10s and fires the MAp every 10s?
Oh well, I disabled it anyways and call for it when needed via rules instead without graphics.

I just got this working. Billing is only used if you go over your monthly quota. Pretty easy to stay under those #s

Hello everybody,
did anybody tried this in OH3?
I have installed both transformation und build the items:

String	GoogleMaps_Arbeit_distance				"Entfernung zur Arbeit [%s]"				(gGoogleMaps)	{ http="<[https://maps.googleapis.com/maps/api/distancematrix/json?origins=An+der+Bringenburg+8,+49504+Lotte&destinations=Elastogranstraße+60,+49448+Lemförde&language=DE&departure_time=now&traffic_model=best_guess&mode=driving&key=MYapiKEY:300000:JSONPATH($.rows[0].elements[0].distance.text)]" }
String	GoogleMaps_Arbeit_duration				"Fahrtzeit zur Arbeit [%s]"					(gGoogleMaps)	{ http="<[https://maps.googleapis.com/maps/api/distancematrix/json?origins=An+der+Bringenburg+8,+49504+Lotte&destinations=Elastogranstraße+60,+49448+Lemförde&language=DE&departure_time=now&traffic_model=best_guess&mode=driving&key=MYapiKEY:300000:JSONPATH($.rows[0].elements[0].duration.text)]" }
String	GoogleMaps_Arbeit_duration_traffic		"Fahrzeit mit Verkehr zur Arbeit [%s]"		(gGoogleMaps)	{ http="<[https://maps.googleapis.com/maps/api/distancematrix/json?origins=An+der+Bringenburg+8,+49504+Lotte&destinations=Elastogranstraße+60,+49448+Lemförde&language=DE&departure_time=now&traffic_model=best_guess&mode=driving&key=MYapiKEY:300000:JSONPATH($.rows[0].elements[0].duration_in_traffic.text)

But I didn’t get any results:

OH3 shows:

At the logs I cant find that the item gut a value.
If I put it into webbrowser deritly I get a result:
GoogleMaps browser

It does work, but you have to use the new openhab3 http Binding. You can define the channels and items with the UI.

Hey,
thanks for the answer.
I’m not the best with such things.
Do you have an example for me?

Hi, I wrote you a pn.

Hallo All,
I‘m not a programmer and I’m learning by doing. With OH3 many things changed again and so I getting a bit lost.
I have the API key and he is working well. But the question is can I translate the widget somehow into yaml so I can use it along with the overview page? Or get the widget on a other way running?

Thanks for your help in advance.

Marcel

Hello All,

I’m also using OH3 now since a half year and I was also not able to get the Distance Label to work.

I’ve completely filled out the Widget config with

Origin
Destination
Distance
Average

Also I’ve created an Google Maps API Key.

The Map is working but no label is shown like in Readme of Widget Descrpiton (see picture below):

2021-09-04_15h25_00

The only thing what I see in my map is a small rectangle instead the label without any content.

Also Map is showing “For development purposes only”.

What am I doing wrong?

Could somebody support here please?

Thanks in advance

Hi @frest ,
can you also please let me know what you have to differently in OH3 http binding?
Tnak you.

1 Like