Hello,
NEW 2018-02-27: Added distance and travel time calculation between two locations. It calculates the avarage travel time, and with current traffic conditions. Import the new widget and get the new ‘maps.html’ file.
I’ve created another widget for HABpanel. For me it’s handy to check the current traffic conditions prior to go to work. Therefore I created an widget that uses Google Maps API and displays the current traffic on the map. It auto reloads the traffic on 10 seconds interval.
I’ve also used the Night color schema so it better fits the default theme of HABpanel.
Screenshot:
Widget:
googlemaps.json.widget
Get your Goolge Maps API key here.
Installation
- Import the downloaded widget to your HABpanel.
- Place the map.html file within your /conf/html/google-maps/ folder.
- In the settings of the widget:
- Set ServerPath to the location of your map.html (/static/google-maps/map.html).
- Set to your preferred zoom level.
- Set to your position in latitude and longitude.
- Set your desired height, the width is auto filling from widget frame.
- If you would like travel time calculation, Enable Travel time check.
- For travel time, install HTTP binding.
- For travel time, set origin. Replace spaces with ‘+’ plus sign.
- For travel time, set destination. Replace spaces with ‘+’ plus sign.
- Set your Google Maps API key.
Travel time widget
If you wan’t, you can get google Maps travel times ext. in a Item and display it in Dummy widgets.
- Install HTTP binding thru PaperUi / Add-Ons
- Install JSONPath transformation thru PaperUi / Add-Ons
Create a ‘googlemaps.items’ file in ‘/conf/items’. Change the value’s in the URL to your liking.
String GoogleMaps_me_distance "Distance [%s]" (gGoogleMaps) { http="<[https://maps.googleapis.com/maps/api/distancematrix/json?origins=Amsterdam&destinations=Rotterdam&language=NL&departure_time=now&traffic_model=best_guess&mode=driving&key=YOUR_API_KEY:3600000:JSONPATH($.rows[0].elements[0].distance.text)]" }
String GoogleMaps_me_duration "Duration [%s]" (gGoogleMaps) { http="<[https://maps.googleapis.com/maps/api/distancematrix/json?origins=Amsterdam&destinations=Rotterdam&language=NL&departure_time=now&traffic_model=best_guess&mode=driving&key=YOUR_API_KEY:3600000:JSONPATH($.rows[0].elements[0].duration.text)]" }
String GoogleMaps_me_duration_traffic "Duration [%s]" (gGoogleMaps) { http="<[https://maps.googleapis.com/maps/api/distancematrix/json?origins=Amsterdam&destinations=Rotterdam&language=NL&departure_time=now&traffic_model=best_guess&mode=driving&key=YOUR_API_KEY:3600000:JSONPATH($.rows[0].elements[0].duration_in_traffic.text)]" }
String GoogleMaps_wife_distance "Distance [%s]" (gGoogleMaps) { http="<[https://maps.googleapis.com/maps/api/distancematrix/json?origins=Amsterdam&destinations=Haarlem&language=NL&departure_time=now&traffic_model=best_guess&mode=driving&key=YOUR_API_KEY:3600000:JSONPATH($.rows[0].elements[0].distance.text)]" }
String GoogleMaps_wife_duration "Duration [%s]" (gGoogleMaps) { http="<[https://maps.googleapis.com/maps/api/distancematrix/json?origins=Amsterdam&destinations=Haarlem&language=NL&departure_time=now&traffic_model=best_guess&mode=driving&key=YOUR_API_KEY:3600000:JSONPATH($.rows[0].elements[0].duration.text)]" }
String GoogleMaps_wife_duration_traffic "Duration [%s]" (gGoogleMaps) { http="<[https://maps.googleapis.com/maps/api/distancematrix/json?origins=Amsterdam&destinations=Haarlem&language=NL&departure_time=now&traffic_model=best_guess&mode=driving&key=YOUR_API_KEY:3600000:JSONPATH($.rows[0].elements[0].duration_in_traffic.text)]" }
3600000 in milliseconds = update every hour. Please be aware of your API usage so you stay in the free zone. This is your own responsibility.
More Google Maps API options here.
Add a Dummy widget for every String. You can set it up like this:
I’m not going to build a custom widget as it’s just plain simple displaying strings.