如何在 React Native MapView 中选择默认的 Google Maps 标记?或者,您如何不显示默认的 Google 地图标记?

问题描述

我有一个地图视图,其中渲染了三种类型的标记:访问、书签和喜欢。

                <MapView 
                    style={styles.map} 
                    provider={PROVIDER_GOOGLE}
                    initialRegion={region}
                    showsUserLocation={true}
                    ref={mapRef}
                >
                    {/* <View style={{ paddingLeft: '5%',paddingBottom: '1%',height: '18%',width: '100%',flexDirection: 'row',justifyContent: 'flex-start',alignItems: 'flex-end' }}> */}
                    <View style={{ paddingLeft: '5%',flexDirection: 'column'}}>
                        <View style={{ flexDirection: 'row',paddingTop: '24%' }}>
                            {profileUser && followers.length > 0 && <FollowerPicture user={profileUser} /> }     
                            {followers.map(follower => {
                                return (
                                    <FollowerPicture key={follower.profileUri}  user={follower} />
                                )
                            })}
                        </View>                   
                        {data && <TouchableOpacity onPress={filter} style={{ 
                            shadowColor: '#000000',shadowOffset: {
                                width: 0,height: 3
                            },shadowRadius: 5,shadowOpacity: 0.3,alignSelf: 'flex-end',marginTop: '3%',marginRight: '5%',backgroundColor: colors.white1,height: 40,width: 40,borderRadius: 40,justifyContent: 'center',alignItems: 'center'
                        }}>
                            <FontAwesome name="filter" size={24} color={colors.black2} />
                        </TouchableOpacity>}
                    </View>
                    {visits.map(visit => {
                        const restaurant = visit.restaurant;
                        return(
                            <MapView.Marker
                                key={restaurant.id.toString().concat(restaurant.__typename)}
                                coordinate={{ latitude: restaurant.latitude,longitude: restaurant.longitude }}
                                title={restaurant.name}
                                pinColor={colors.green1}
                                onPress={(e) => {
                                    pressMarker(e,restaurant.id)
                                }}

                            />
                        )
                    })}
                    {bookmarks.map(bookmark => {
                        const restaurant = bookmark.restaurant;
                        return(
                            <MapView.Marker
                                key={restaurant.id.toString().concat(restaurant.__typename)}
                                coordinate={{ latitude: restaurant.latitude,longitude: restaurant.longitude }}
                                title={restaurant.name}
                                pinColor={colors.blue2}
                                onPress={(e) => {
                                    pressMarker(e,restaurant.id)
                                }}
                            />
                        )
                    })}
                    {likes.map(like => {
                        const restaurant = like.restaurant;
                        return(
                            <MapView.Marker
                                key={restaurant.id.toString().concat(restaurant.__typename)}
                                coordinate={{ latitude: restaurant.latitude,longitude: restaurant.longitude }}
                                title={restaurant.name}
                                pinColor={colors.red1}
                                onPress={(e) => {
                                    pressMarker(e,restaurant.id)
                                }}
                            />
                        )
                    })}
                </MapView>

但是,在地图中,其他标记也是可见的。这些标记是 Google 地图显示标记。地图放大得越多,出现的这些标记就越多。

这就是地图的样子。红色和蓝色标记是我的标记。代表 IHOP、Veselka、Veniero's Pasticceria & Caffe 等的标记是 Google 地图的标记

我的问题有两个:

  1. 如何选择这些认的 Google 地图标记?我尝试使用像 onPress 或 onMarkerSelect 这样的 MapView 方法,但是当我点击标记时没有事件触发器。
  2. 如何删除这些认的 Google 地图标记

非常感谢!!

enter image description here

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...