quentinlampin / ngx-openlayers

Angular2+ components for Openlayers 4.x
Mozilla Public License 2.0
137 stars 98 forks source link

Source format implementation #41

Closed achimha closed 7 years ago

achimha commented 7 years ago

I have a semi-working implementation of ol.source.VectorTile which requires the parameter format in its constructor (unfortunately no setFormat available). The format can be something like ol.format.MVT which means we would desire this:

<aol-source-vectortile>
    <aol-format-mvt></aol-format-mvt>
</aol-source-vectortile>

Now this has a chicken and egg problem. In ngOnInit, we create the OL3 objects but at this point the child components are not created yet and also they generally assume they can call the parent.

Any suggestion how to model this case?

achimha commented 7 years ago

Same is true for the tileGrid -- has to be set at object creation time: http://openlayers.org/en/latest/apidoc/ol.source.VectorTile.html

quentinlampin commented 7 years ago

I believe the key to your issue is that Angular2 components are created in a top-down manner, meaning containers first. In your case, you need a child component instance to create the container instance.

The afterContent/View hooks should address this need: https://angular.io/docs/ts/latest/guide/lifecycle-hooks.html#!#aftercontent.

Keep me updated, in case I can help (not much spare time at the moment though).

From: Achim Hasenmueller notifications@github.com Reply-To: quentin-ol/angular2-openlayers reply@reply.github.com Date: Friday, 10 February 2017 at 13:00 To: quentin-ol/angular2-openlayers angular2-openlayers@noreply.github.com Cc: Subscribed subscribed@noreply.github.com Subject: [quentin-ol/angular2-openlayers] Source format implementation (#41)

I have a semi-working implementation of ol.source.VectorTile which requires the parameter format in its constructor (unfortunately no setFormat available). The format can be something like ol.format.MVT which means we would desire this:

   

Now this has a chicken and egg problem. In ngOnInit, we create the OL3 objects but at this point the child components are not created yet and also they generally assume they can call the parent.

Any suggestion how to model this case?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

achimha commented 7 years ago

Yes, using afterContentInit solves the problem. See my latest PR, I've used that approach.