Map UI Default center/zoom?

I was wondering if there is a way to set a default center point and zoom level for the map ui? I have most of my zones near where I live, but one other far away. It looks like it defaults to include all and I’d rather just have my main ones zoomed in. Any ideas besides dropping the one zone?

3 Likes

I’ve the same issue. Any solutions?

None at the moment, guessing it wouldn’t be hard to add an override center and override zoom level to the map component though, might look into it if I have time.

I believe the map component uses gmplot https://github.com/vgm64/gmplot

I didn’t find the default map all that useful, so I wrote a python script that generates my own personal one. You can change the default/centering etc and draw whatever you want on it, fairly simple. I just make a custom panel pointed at the HTML file my script generates. My map plots the last 24 hours of movement, last month of movement as heatmap, and draws my zones and position etc.

Ah cool, care to share the script?
Also does it live update when a user moves, or do you update via some polling etc.

Not sure it would be any use to you, I am pulling the historical data out of my own MySQL database. The actual mapping part is straight forward - see the examples on the gmplot page.

But yes I’m just running it through crontab every few minutes, the map it generates is static

Here’s an example getting a state from Hass and plotting a list of GPS points (in this case Bike Share stations)

import homeassistant.remote as remote
import citybikes

api = remote.API('HASS.IO', 'PASS')
print(remote.validate_api(api))

brad = remote.get_state(api, 'device_tracker.brad_nodered')
bradGPS = [brad.attributes['latitude'],brad.attributes['longitude']]

# CITYBIKES
networkuid = 'ford-gobike'

client = citybikes.Client()
network = citybikes.Network(client, uid=networkuid)
network = network['stations']

gbikeLat = []
gbikeLon = []
rbikeLat = []
rbikeLon = []
for station in network:
        availBikes = int(((station['free_bikes']/float((station['free_bikes'] + station['empty_slots'])))*100))
        if availBikes > 30:
                gbikeLat.append(station['latitude'])
                gbikeLon.append(station['longitude'])
        else:
                rbikeLat.append(station['latitude'])
                rbikeLon.append(station['longitude'])

# Generate map
import gmplot
gmap = gmplot.GoogleMapPlotter(brad.attributes['latitude'],brad.attributes['longitude'], 15,apikey='APIKEY')

gmap.circle(brad.attributes['latitude'],brad.attributes['longitude'],15,color='blue')
gmap.scatter(gbikeLat, gbikeLon, 'green', size=50, marker=False)
gmap.scatter(rbikeLat, rbikeLon, 'red', size=50, marker=False)


gmap.draw("/var/www/public_html/custommap.html")

So you can see… very easy to combine a lot of other information on the map also with states from Hass. This
gmap = gmplot.GoogleMapPlotter(brad.attributes['latitude'],brad.attributes['longitude'], 15,apikey='APIKEY')

Centers the map on my position and sets the zoom to 15.

1 Like

There hasn’t been any conversation on this thread in a long time…

Is there a way to add more control to the default state of the MAP? its a pain to have to zoom in every time I open the MAP to check where the family is. I would rather use the MAP than cards for this task. Can we get the MAP some love?

3 Likes

Also looking for this functionality, apologies for the necro

The map card does that.
Having a map card in panel mode becomes kind of the same as the map, but better in my opinion.