Reputation: 891
i have a state like this:
this.state = {
width : Dimensions.get('window').width,
height : Dimensions.get('window').height,
initialPosition: {
latitiude: 48.866667,
longitude: 2.333333,
latitudeDelta:LATITUDE_DELTA,
longitudeDelta: LONGITUDE_DELTA
},
markerIcons: {},
markers: [],
};
In markerIcon i have different .png like this:
An din markers i have another object where appears different information and categories of traders :
I define my Markers as this in my render:
{Object.keys(this.state.markers).map((marker, key) => (
<Marker
key={key}
coordinate={this.state.markers[marker].coordinate}
title={this.state.markers[marker].title}
description={this.state.markers[marker].address}
image={......}
/>
))}
</MapView>
</View>
I would like the source of my images to match the categories of my traders.
The names are the same in both objects but how do I do it in my marker??
How can can i set my image source of my marker ??
thanks for your help ;)
Upvotes: 0
Views: 1391
Reputation: 22209
You can access the object of the marker icon
like this
Assuming that your marker icon object is stored in MarkerIcon
this.state.markerIcons[this.state.markers[marker].category]
This will give you the object {icon: '', label: ''}
for the same
Upvotes: 0