React-native-maps: Not able to add both text and image to map marker

Created on 20 Mar 2017  路  3Comments  路  Source: react-native-maps/react-native-maps

Not able to add both text and image to map marker #832

How to add index=1 and count =0

{data.map((obj, index) =>
                    {
                      return (
                             <MapView.Marker identifier="Marker1" key={index} coordinate={obj.coordinate} image={require( '../../images/dummy.png')}>
                                <MapView.Callout style={styles.callout}>
                                    <View>
                                        <Text>{obj.number}</Text>
                                        <Text>{obj.city}</Text>
                                    </View>
                                </MapView.Callout>
                                        <Text>{obj.number}</Text>
                            </MapView.Marker>
                        )
                     })
                }

longscreenshot_2017-03-20-13-00-46

Most helpful comment

It was solved by moving <Text>{obj.number}</Text> top of callout.

{data.map((obj, index) =>
                    {
                      return (
                             <MapView.Marker identifier="Marker1" key={index} coordinate={obj.coordinate} image={require( '../../images/dummy.png')}>
                                 <Text>{obj.number}</Text>
                                <MapView.Callout style={styles.callout}>
                                    <View>
                                        <Text>{obj.number}</Text>
                                        <Text>{obj.city}</Text>
                                    </View>
                                </MapView.Callout>

                            </MapView.Marker>
                        )
                     })
                }

All 3 comments

Without callout its working ..!
(below piece of code)

How to use this with callouts.
```
{data.map((obj, index) =>
{
return (
{obj.number}

)
})
}

It was solved by moving <Text>{obj.number}</Text> top of callout.

{data.map((obj, index) =>
                    {
                      return (
                             <MapView.Marker identifier="Marker1" key={index} coordinate={obj.coordinate} image={require( '../../images/dummy.png')}>
                                 <Text>{obj.number}</Text>
                                <MapView.Callout style={styles.callout}>
                                    <View>
                                        <Text>{obj.number}</Text>
                                        <Text>{obj.city}</Text>
                                    </View>
                                </MapView.Callout>

                            </MapView.Marker>
                        )
                     })
                }

@iiitmahesh that actually fixed it.. sometimes it's just that stupid I guess... Thanks a lot

Was this page helpful?
0 / 5 - 0 ratings