如何在react-native上汇总标记图? (RN-vs:0.59)

时间:2019-09-02 13:58:35

标签: android google-maps react-native react-native-android

我尝试在react-native上累积maps标记。.但是我没有在我的android上获得更改标记。.在我编写类似波纹管的代码后,该应用始终会强制关闭。.请帮助..谢谢。

render() {

        return (
            // <View style={styles.container}>
            <MapView
                ref={ref => myMap = ref}
                style={{
                    flex: 1
                }}
                region={this.props.region}
                showsUserLocation={true}
            >
                {
                    this.state.data.map((value, key) => {
                        return (

                            <MapView.Marker
                                coordinate={{ latitude: value.region.latitude, longitude: value.region.longitude }}
                                key={key}
                                title={value.title}
                                description={value.desc}
                                image={require('../../../Assets/Ruko.png')}
                                onPress={() => {
                                    myMap.fitToCoordinates([{ latitude: value.region.latitude, longitude: value.region.longitude }], {
                                        edgePadding: { top: 10, bottom: 10, left: 10, right: 10 },
                                        animated: true
                                    });
                                    this.clickDetail(value.id);
                                }}>

                            </MapView.Marker>
                        )
                    })
                }
            </MapView>
            // </View>
        );

1 个答案:

答案 0 :(得分:0)

将图像添加到标记道具。

                          <MapView.Marker
                                coordinate={{ latitude: value.region.latitude, longitude: value.region.longitude }}
                                key={key}
                                title={value.title}
                                description={value.desc}
                                onPress={() => {
                                    myMap.fitToCoordinates([{ latitude: value.region.latitude, longitude: value.region.longitude }], {
                                        edgePadding: { top: 10, bottom: 10, left: 10, right: 10 },
                                        animated: true
                                    });
                                    this.clickDetail(value.id);
                                }}>
                            <Image source={require('../../../Assets/Ruko.png')} 
                                     style={{height: 35, width:35 }} />
                            </MapView.Marker>