Closed smcclstocks closed 9 years ago
It's in purpose that it does not adjust. It is supposed to adjust only after the first load. I think it is a bad user experience if you move the map, click somewhere to add a marker, and then without noticing you the map moves again and scales, loosing your previous move.
So this might be added as another feature, like alwaysAutoFitBounds
, being false
by default.
Not a feature that should be the default based on what you said but in my app for instance it's a nice to have so I like the opt-in approach you mentioned. Would you do it with an observer like I did or something else?
No, there is already an observer for that feature, I'll just let it run all the time and not remove the objserver in the case that flag is set.
@smcclstocks this is done, not yet documented (@ohizkiya got time for that?). Just get the latest (0.0.20
) and set alwaysAutoFitBounds
to true
when using the component in the template. All the rest remains unchanged.
For the life of me I can't get the map to adjust it's zoom automatically when adding new markers, removing markers, or altering existing lat/lng of a marker in the markers array. All of the changes to the markers array that I just mentioned are updated on the map (meaning new ones appear, deleted ones disappear, etc) but the zoom never adjusts.
I did something really horrible probably in your google-map component & it fixed it:
foo: function() { console.log('xxx here'); this.fitBoundsToContain(); }.observes('_markers.@each'),
I'm sure this a terrible idea but you got any advice on how I'd get the zoom to adjust? My hbs looks like:
google-map autoFitBounds=autoFitBounds lat=lat lng=lng markers=markers gopt_panControl=false gopt_zoomControl=false zoom=zoom markerViewClass="client/map"
I set zoom, lat, lng to sane defaults if markers is an empty array in my controller.