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

2

5

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

Zola answered 13/12, 2016 at 17:36 Comment(0)
L
6

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}

Leenaleeper answered 13/12, 2016 at 21:29 Comment(0)
G
10

Allowed colors for Marker are: red, tomato, orange, yellow, green, gold, wheat, linen, tan, blue, aqua, teal, violet, purple, indigo, turquoise, navy and plum.

Like:

<MapView.Marker
    pinColor={'green'}
/>
Godfearing answered 14/8, 2019 at 3:34 Comment(0)
L
6

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}

Leenaleeper answered 13/12, 2016 at 21:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.