icon-offset from feature property #3501
Replies: 10 comments
-
Have you tried casting the property to a number, e.g.:
|
Beta Was this translation helpful? Give feedback.
-
The icon-offset is actually of type [number, number], but i have tried separating x and y to own properties:
but then I get error |
Beta Was this translation helpful? Give feedback.
-
Ah, I believe In your original question, MapLibre is indeed complaining that the iconOffset property is a string. Are you able to change the data so that it is a |
Beta Was this translation helpful? Give feedback.
-
I found this old mapbox issue that looks very pertinent, but it seems the problem was never solved... |
Beta Was this translation helpful? Give feedback.
-
I made reproduction of this issue to codepen and actually it seems that its queryRenderedFeatures that triggers the warnings. If i just make a layer use iconOffset maplibre is perfectly happy until I try to query that feature from map. https://codepen.io/jarkkosky/pen/XWOvQVZ |
Beta Was this translation helpful? Give feedback.
-
I think I found the answer to my problem in documentation of queryRenderedFeatures (https://maplibre.org/maplibre-gl-js/docs/API/classes/maplibregl.Map/#queryrenderedfeatures)
I still think this validation when retrieving the rendered features seems odd and unneccesary but as its documented behavior I guess I will try to think of another solution. If I use |
Beta Was this translation helpful? Give feedback.
-
Strange behavior indeed... |
Beta Was this translation helpful? Give feedback.
-
What do you guys think should I open an issue about this? |
Beta Was this translation helpful? Give feedback.
-
Sure, it won't hurt to have an issue open, but if you truly want this fixed your best approach would be to create a PR to solve this. |
Beta Was this translation helpful? Give feedback.
-
I created an issue #3502 if someone has insight on how this should be fixed I can try to do a PR possibly |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
We want to set iconOffset individually for each feature in our source and we calculate that value to be included in the feature "properties", so our source looks something like this:
and then we use it in layer layout with the following
'icon-offset': ['get', 'iconOffset']
Now begins the problem: This seems to be working fine, the offset is applied correctly but our console gets filled with
Expected value to be of type array<number, 2>, but found string instead.
Im guessing this is because the data is stored as strings in properties. I have tried every variant of expressions but no luck converting it back to number pair.Any suggestions?
Beta Was this translation helpful? Give feedback.
All reactions