Search code examples
react-nativeandroid-mapview

how to set marker in center of the circle


i tried to set marker in the center of the circle in MapView ,i using the same coordinate of the map and the circle but the image of marker not centralised this is the code :

<MapView
                    ref={(ref) => this.map = ref}
                    provider={MapView.PROVIDER_GOOGLE}
                    style={styles.map}
                    region={{
                        latitude: this.props.user.pos.lat,
                        longitude: this.props.user.pos.lng,
                        latitudeDelta: 0.015,
                        longitudeDelta: 0.0121,
                    }}>

                    <MapView.Circle
                        center={{latitude: 33.941582,
                            longitude: 10.066695, }}
                        radius={1000}
                        fillColor="#fed42855"
                        strokeColor="#fed42855" >

                        </MapView.Circle>
                        <MapView.Marker
                        coordinate={{
                            latitude: 33.941582,
                            longitude: 10.066695,
                        }}
                        title={"title"}
                        description={"description"}                          

            image{require('../../../../../assets/navigation.png')}

                    /> 

                </MapView>

enter image description here


Solution

  • A MapView marker is displayed just above the given coordinate, since by default markers are displayed as pins and the bottom of the pin needle corresponds to the coordinate.

    You can use the anchor and centerOffset props to reposition the marker according your needs. You can find the documentation here!