-
-
Notifications
You must be signed in to change notification settings - Fork 403
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 data-driven styling #161
Add data-driven styling #161
Conversation
Builds off of the ZoomSpecField component with separate options for handling data-driven properties. Reuses most of the zoom field functionality with tweaks that I tried to keep as small as possible, and the layout is based off of comments on the existing issue.
It looks like default is not supported in this version of the style spec, so pending the PR to update it I'm removing it as an input.
Hey @pjsier thanks for the pull request. I'm a little busy at the moment, but will try and review over the next couple of days. With regards to
If you're working on a project currently, could you give the branch in PR #124 a test, then we can get that merged in as well. |
@orangemug thanks for the reply! We've actually been using the updates from that PR (along with these changes) to use the |
Thats perfect thanks! |
@pjsier I took a quick look at http://eviction-lab-maputnik.s3-website-us-east-1.amazonaws.com. First off I think it looks great, congrats this is a big step forwards for maputnik. I think I've found a bug. I believe the background layer shouldn't support data driven styling, or at least it errors when you try to enable it |
@chriswhong, @muesliq would you care to take a look at this PR also? |
@orangemug great to hear that branch is merged! I pulled it into this PR and re-added the |
Hi @pjsier sorry for taking a fews days to get back to you, I've found another issue It looks like you're trying to set Another 'nice to have' modification would be to swap the order of 'zoom function' and 'data function' buttons. A lot more fields have 'zoom function' support and looks a little cleaner in the UI. |
Checking the Mapbox style spec properties to see whether or not exponential should be allowed as the property type, defaulting to categorical which appears to work for either type. Also re-orders zoom and data function buttons, aligning zoom right if data not supplied.
@orangemug switching the order of the zoom function and data function buttons was pretty easy, so I updated that. And thanks for catching that bug with the I updated the component to restrict the available I didn't include |
Hey thanks @pjsier, that seems to be working now. Another minor issue I guess If you have the time and any ideas of a good name, a rename would be appreciated. Otherwise I think it looks good to merge. The failing tests are just issues with node v4, so I'll ignore them (I might just remove node v4 from the CI in future). |
@orangemug great! And I was actually thinking the same thing. Based off of some of the language Mapbox uses in the style spec, maybe |
@pjsier |
@pjsier ok so I reviewed this pull request again this morning and noticed another issue. Sorry my mistake I'm pretty new to this data function stuff. The default field seems to be autocompleting to the field name. To see this turn on the data function for a field, focus the 'default field' then lose focus on that field. If you try this on 'Icon layout properties -> Size' the 'default' field' will end up being set to 'icon-size'. Annoyingly the only way to reset the value is to edit with the JSON, but I think that is to do with our error handling generally rather than an issue with this pull request. Note: I'll hold off merging #167 until this is merged, so you don't have to deal with the conflicts. |
@orangemug ah thanks for catching that. It looks like it was mostly a typo (I was only handling one function parameter but |
const dataProps = { | ||
label: "Data value", | ||
value: dataLevel, | ||
onChange: newData => this.changeStop(idx, { zoom: zoomLevel, value: newData }, value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pjsier I think you mean zoomLevel
here, idx
is undefined
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@orangemug actually, I think I was accidentally doing some fancy scoping, because it does need to access the idx
of the parent to change the stop. About to update that by removing the getDataInput
and moving that conditional into the loop so it's more explicit
@pjsier I've added a comment, in the code. Also noticed that some of the properties are throwing errors, updating We've now got a new error, modifying data function values causes the error |
@orangemug I updated |
@pjsier I can't seem to reproduce the issue now. Ok this looks great, there are a couple of UI things I think we could improve
However we can pick those things up later on in new tickets. Congrats on the feature, this is a big step forward! |
I'm working on a project where we've been using Maputnik, and it's been great overall, but we make heavy use of data-driven styles. After looking through issue #96, I took a stab at adding that functionality here. I tried to base the design off of the conversation on that issue, and initially added the default property referenced in #132, but it looks like that may be contingent on updating the style spec.
I don't have a lot of experience with React, so feedback is more than welcome and I'm happy to make any changes