nitaliano / react-native-mapbox-gl

A Mapbox GL react native module for creating custom maps
Other
2.16k stars 699 forks source link

SymbolLayer, using '{token}' as iconRotate style prop #1592

Closed ksulia closed 5 years ago

ksulia commented 5 years ago

I have a Symbol Layer with 126 symbols in the layer, each passed through the ShapeSource as a featurecollection. Each feature in the featureCollection has its own unique set of variables, including an icon, e.g.,

featureCollection: MapboxGL.geoUtils.addToFeatureCollection( this.state.featureCollection, MapboxGL.geoUtils.makeFeature({type: 'Point', coordinates: location}, { icon: icon, key: key, data: nm, wdir: wdir, relh: relh, temp: temp, pres: pres, stid: stid }) ), All of the properties (icon, key, wdir, etc) get passed as '{tokens}'. My question is, how can I pass the featureCollection property that I define as 'wdir' to iconRotate just as I do for iconImage: '{icon}' or textField: '{temp}'? At the moment is does not seem the iconRotate processes the information similarly to the iconImage and textField props (requires an actual value, not a token).

Thank you!

jruddell commented 5 years ago

@ksulia you should be able to use the identity function to accomplish this. Meaning iconRotate: MapboxGL.StyleSheet.identity('wdir')

ksulia commented 5 years ago

@jruddell thank you!!! works perfectly!!