Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Android runtime style API bug with filters & numbers #6040

Closed
incanus opened this issue Aug 16, 2016 · 5 comments
Closed

Android runtime style API bug with filters & numbers #6040

incanus opened this issue Aug 16, 2016 · 5 comments
Assignees
Labels
Android Mapbox Maps SDK for Android bug runtime styling

Comments

@incanus
Copy link
Contributor

incanus commented Aug 16, 2016

Per extended chat with @ivovandongen—writing this up so we have a concrete place for it on which to hang commits and eventually mark it resolved.

Here is a sample data file:

https://gist.github.com/incanus/0607dccb035cd9b55ff95faa1b60cf8c

I've added this to a basic Mapbox Studio style at mapbox://styles/justin/cirnit09r000bg1mb4kxqmvwi.

Each segment of the data file is addressable by a uniqid numeric field, e.g. 10191020. Something like this should be possible:

LineLayer segments = mapboxMap.getLayerAs("segments");
        segments.setFilter(eq("uniqid", 10191020));
        segments.setProperties(lineColor(Color.GREEN),
                lineWidth(10f),
                lineOpacity(0.5f));

This is the analog to doing it via the GUI in Studio:

screen shot 2016-08-11 at 5 29 53 pm

However, all segments will get their style changed, not just the single one of the ~20 with that uniqid. The filter seems to be ignored.

Numeric comparison, either types or precision, seems to be at fault. @ivovandongen tried a fix at ddf0d25 but it still doesn't seem to do it.

I will also test c34130a and see why it might be working but my example isn't. Is it maybe the size of the number in my data field?

/cc @frederoni just for when we might hit this on iOS filters.

@incanus incanus added bug Android Mapbox Maps SDK for Android runtime styling labels Aug 16, 2016
@incanus incanus added this to the android-v4.2.0 milestone Aug 16, 2016
@incanus
Copy link
Contributor Author

incanus commented Aug 16, 2016

Confirmed that I am seeing the parks example in c34130a work just fine in my setup, so it's something more unique about my data set.

@ivovandongen
Copy link
Contributor

@incanus I've tried out your json and code snippets by working it into the test app and it just seems to work. Can't say what's going wrong with your example based on the information you provided. See the patch here for more information: https://gist.github.com/ivovandongen/f6ac2d5edd66844f853126759134bc82

segments

Hope that helps you.

@ivovandongen ivovandongen removed their assignment Aug 17, 2016
@ivovandongen ivovandongen removed the bug label Aug 17, 2016
@incanus
Copy link
Contributor Author

incanus commented Aug 17, 2016

@ivovandongen You are adding a new layer rather than changing an existing one in Studio. See my original code in #6040 (comment):

LineLayer segments = mapboxMap.getLayerAs("segments");
        segments.setFilter(eq("uniqid", 10191020));
        segments.setProperties(lineColor(Color.GREEN),
                lineWidth(10f),
                lineOpacity(0.5f));

This is finding the style layer which was created in Studio server-side from the source GeoJSON, not in the app. It uses getLayerAs() rather than your example of new LineLayer(). We should be able to query this existing layer, then change its properties.

Try this patch exactly to reproduce the problem:

https://gist.github.com/incanus/b89e1b07bdbcc921b4ae928901584e93

What should happen is a styling similar to what's seen in Studio above, but what actually happens is that the whole of the segments layer is styled green.

@incanus
Copy link
Contributor Author

incanus commented Aug 18, 2016

This may actually be rendering related, not filter. See #5701.

@incanus
Copy link
Contributor Author

incanus commented Aug 18, 2016

That's exactly what we're seeing here.

anigif-1471550047

I've confirmed that things work with both the primitive as the value as well as an Integer. Closing here and picking up in #5701. Thanks for your work @ivovandongen!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Android Mapbox Maps SDK for Android bug runtime styling
Projects
None yet
Development

No branches or pull requests

2 participants