Skip to content
Advertisement

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

I want to display in google map some location based on my data of longitude and latitude.

here is my data:

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

here can see I’ve 3 latitude and longitude.

i want to display in google map all the location in one secreen.

I’m using react-native-map libraries in my project. So, anyone can help me how to the Marker for this?

i was tried to get one location to display in map which is as well not works for me.

please help me to display it in map.

Thanks for your Trying!

  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>
    );

Advertisement

Answer

Using map can be solve that problem, i already solve it myself. In this case:

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>
    );
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement