ember-leaflet
ember-leaflet copied to clipboard
Manipulating the Map from the page controller
Hi guys,
I used your awesome addon to do add a Map into an EmberApp => https://github.com/wwoof/webapp => https://app.wwoof.fr/hosts
I ran into a couple issues so I wanted to share them with you. I wanted to use the Leaflet API to manage my map from the controller. However I was not able to access the map from the controller. Therefore I had to override an init method in the EmberLeaflet.MapView to forward the map Layer to the page controller:
export default EmberLeaflet.MapView.extend({
[...]
didCreateLayer: function () {
// Get map init parameters from controller
this._layer.setView(L.latLng(this.controller.get('lat'), this.controller.get('lon')), this.controller.get('mapZoom'), false);
this.controller.set('mapLayer', this._layer);
// declare moveEnd action sender
this.moveend = function () {
this.controller.send("mapChanged");
};
// continue Init
this._super();
}
});
Is there a better way of doing that? I think it's important to allow Map/Layer manipulation from a controller.
Also, if you want you could add a link to our App as an usage example of this addon.
Maybe a more specific example of the intended implementation would be helpful. IMHO you shouldn't access the map from the controller but bind it to controller values. Why not have a map component that has values and/or actions bound to correspondening controller values/actions? This package is currently being refactored into a component (provided as ember-cli-addon).