Search code examples
javascriptgoogle-mapsreactjsreact-nativereact-native-maps

Using react-native-maps to Change pinColor of MapView.Marker


The color of MapView.Marker does not seem to change from the default red color even after assigning a color to pinColor.

Is something wrong?

{ this.state.markers.map(marker => {
    return (
        <MapView.Marker 
            coordinate={{latitude: marker.latitude, longitude: marker.longitude}}
            key={marker.key}
            pinColor='#000000'
        />
    )
})}

Screen cap from Android Emulator

enter image description here


Solution

  • You missed the curly braces. Everything else is fine and it will work or better define the color as const and pass that like this.

    const pinColor = '#000000';

    and then pass it like..

    pinColor = {pinColor}