繁体   English   中英

如何在一个 map 中显示 3 个纬度和经度(标记)?

[英]how to display 3 latitude & longitude (Marker) in one map?

我想根据我的经度和纬度数据在谷歌 map 中显示一些位置。

这是我的数据:

const result= [[112.30021, 5.5680028],[113.30021, 4.5680028],[114.30021, 3.5680028]]

这里可以看到我有 3 个纬度和经度。

我想在谷歌 map 中显示一个屏幕中的所有位置。

我在我的项目中使用了 react-native-map 库。 那么,任何人都可以帮助我如何为此做标记?

我试图让一个位置显示在 map 中,这对我来说也不起作用。

请帮我显示在map。

感谢您的尝试!

  return (
        <View style={styles.container}>
            <MapView
                style={styles.map}
                initialRegion={{
                    latitude: 5.54678,
                    longitude: 116.9087,
                    latitudeDelta: 0.0922,
                    longitudeDelta: 0.0421,
                }}>
                <Marker coordinate={{

                    longitude: result[0][0],
                    latitude: result[0][1],
                }} />
            </MapView>
        </View>
    );

使用map可以解决这个问题,我已经自己解决了。 在这种情况下:

return (
        <View style={styles.container}>
            <MapView
                style={styles.map}
                initialRegion={{
                    latitude: 5.54678,
                    longitude: 116.9087,
                    latitudeDelta: 0.0922,
                    longitudeDelta: 0.0421,
                }}>{
              result.map((m,id)=>
              <Marker 
              key={id}
              coordinate={{

                    longitude: m[0],
                    latitude: m[1],
                }} />}
                
            </MapView>
        </View>
    );

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM