-
Notifications
You must be signed in to change notification settings - Fork 41
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
Add possibility to define custom layer properties #349
base: master
Are you sure you want to change the base?
Conversation
Hi Sebastien, a good addition. Lines 89 to 105 in 63591aa
, ...lConf.customLayerProperties at the end should do the trick (untested).More from me in a couple of weeks when I hopefully have a bit more time, Felix |
Just another idea: Would it be nicer declaring those custom properties without a wrapping |
Hi @fschmenger, Thanks for the fast reaction and good to hear some news from you ! What you propose is exactly in relation to what I thought at first and I agree 100% doing this would be better in the LayerFactory than patching after layer creation as I eventually did. In fact, both solutions can work but result in different approaches at the beginning: With your solution, each layer should define a So on one side, you can define a custom object on each layer but no control is done on its content. On the other side, you define a list of properties to be considered as valid then layer definitions can be done as it's already done with all other modules. However, using my approach, including those properties inside the LayerFactory is not possible without refactoring it in its entirety because for now, the LayerFactory is in fact a collection of functions with the main one being So two questions here I think should be discussed:
Edit: Another option for question 1, obviously, is NOT to define a |
Hi team, Just thought again a little bit about all this, here's my personal view about this:
Just tell me what you think about it and give your personal opinions, Sebastien |
Hi Sebastien. My bad, sorry for misreading the code. I should have taken some time to check what it is doing before giving some recommendations. :) I'm not sure whether it is a good feature to use a global Otherwise if we decide to use the Cheers, |
Hi Sebastien and Felix, I personally like the dynamic behavior of JS and JSON at least for frontend development. So I really like the approach of the modules by just silently forwarding every config property. According to this and to keep things a bit harmonized in the app-config JSON and the later on interpretation of it I guess I would favor an approach without a "customLayerProperties". Refactoring the I am not deciding, how to proceed with this. We should find a consent/compromise as a community. Further opinions? Or is someone willing to take over the implementation of a possible refactoring of the |
Hi team, As said, before, I don't think neither that the However, if you are all O.K. with this, it's not a problem to remove it completely and "just" refactor the Cheers, |
Thanks @chrismayer and @sronveaux for the ongoing work and the useful input.
|
Hi team, I made a quick test last Friday to keep refactoring as minimal as possible and here is how I thought this can be achieved: In the LayerFactory object,
The idea is to extract the properties needed for the layer type (+name and attributions I will explain afterwards) and assign all the remaining ones to the layer directly. If we take a close look at the whole file, all the parameters have the same name inside the config file than what they are assigned to afterwards... except Here's another example for completeness:
With current implementation, undefined properties are not added inside the layer objects as they are for now inside This can also be "upgraded" to take into account the idea of a "blacklist" given by @fschmenger, which I really think is great, however, what if the user do want to redefine some So, just tell me what you think about this draft example of refactoring and please give your opinion about those two points:
Thanks in advance, |
Apologies team, typed too fast, hit the tab key and finished publishing an unfinished comment and closing the PR which was not what I wanted for sure... |
Hi Sebastien, great you got working on this again.
I think a blacklist is probably required, as nothing good will happen if you e.g. override Cheers, |
Thank you @sronveaux for your ongoing work and your input @fschmenger. I like the proposal of @sronveaux in general. Here are some thoughts:
If I got it right "the black list" should contain layer properties, which we want to avoid being set by the application config JSON, right? So these should be mainly props with non-serializable property values, which cannot be formalized in the JSON. So possible candidates for the black list are props awaiting OpenLayers object instances or functions. One could argue that if a user sets the
As far as I remember the config options are |
You`re right, sorry for not checking the code. :) This was required for localization. |
Hi team and thanks for the fast comments on this one. I totally agree with both of you on these which unfortunately leads me to some more questions and thinkings... At first, good to hear @chrismayer that the general proposal is O.K. for you. I'll continue in that direction then. To summarize for the rest:
Perfect to note that explicit forwarding is not needed. However, I think I'll keep such a function to extract the ones to be renamed (
As stated earlier, I really like the idea of the "black list" but the more I think about it, the more I think the effort to maintain it correctly will be bigger than expected. As stated by @chrismayer, to be useful, it should contain functions and other non-serializable properties of all classes linked to a layer type which means a lot (almost 30 items just for the Thanks again for the ideas and opinions on this one and hope we'll find the best option all together shortly ! Cheers, |
Hi Sebastien, sorry for being quiet for so long. If a blacklist is to cumbersome to maintain, then maybe we have been trying to pull things up from the wrong side. So e.g. something along these lines:
Do you think this would be more futureproof /easier to handle? |
Hi Felix, no problem and thanks for coming back to it, I'm myself a bit out of time for now and will concentrate on your comments on the other PRs first then your request for review before coming back to this one... The idea seems interesting for sure and would be way easier to maintain in the end. I have to take some time to refresh everything on this one as the elapsed time made me forget all the details... which is a good thing for this one! I'd like to get back to OL internals with "fresh eyes" now before considering all the possibilities we have... as soon as I'll have a little time for this, I'll post some new thoughts about it! Cheers, |
Hi team,
When new modules are added, we often have to add new properties on layers, for example,
hoverable
andhoverAttribute
in theHoverController
orcolumnMapping
in theAttributeTable
.This is also true with custom modules a user could potentially add in its own app.
However (but correct me if I'm wrong) there is no easy way now to add custom layer properties through the config file as unknown properties are not taken into account (which is great by the way !).
If such attributes must be added now and we don't want to touch the code inside
src
, we have to add a function that re-parses the config file and add those attributes to the layers on the map or find other subtle ways to do it.What I propose here is to add an optional global configuration property
customLayerProperties
which is an array that contains the names of properties a user could declare as usable inside themapLayers
.Addition is very short, tests are included, the hardest is to explain its usage concisely inside the documentation.
Hope you'll find this simple addition useful!
Cheers