-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How do you use bounds / CollectionBoundsMixin? #74
Comments
This is how I got it work but there may be a better way. var markerCollectionLayer = EmberLeaflet.MarkerCollectionLayer.extend(
EmberLeaflet.CollectionBoundsMixin, {
contentBinding: 'controller',
didCreateLayer: function() {
this._super();
this.get('parentLayer').get('layer').fitBounds(this.get('bounds'));
}
});
App.MyMap = EmberLeaflet.MapView.extend({
childLayers: [
EmberLeaflet.DefaultTileLayer,
markerCollectionLayer
]
}); |
Thanks! This worked great for my regular layer, but the slightly weird collection-as-individual-object layer (see #72 ) gives The code:
If I take out the Incidentally, I have a computed property on |
Btw, I discovered that's it's probably better to use get when referencing the layer and parentLayer. this.get('parentLayer').get('layer').fitBounds(this.get('bounds')); |
My goal is to have all of the markers that appear frame the bounds of the map. I did this pretty easily on the Rails side via the
leaflet-rails
gem while calculating the bounds on the fly, but doing something similar, with a computed propertybounds
, like this:tells me that
fitBounds
is undefined. (or, at least, that's what's underlined in the Inspector)I see that there's a
CollectionBoundsMixin
inember-leaflet
, which I think providesgeometry.get('bounds')
, so I can save having to calculate it myself.But I still don't know how to set up the auto-zooming/panning that
fitBounds
provides, and/or don't know whyfitBounds
gives an error. When I comment that line out, the markers appear as expected, and I've even tried sendingfitBounds
an artificial L.latLngBounds, to see if that's the problem.Thanks!
The text was updated successfully, but these errors were encountered: