Add markers to map
This commit is contained in:
parent
f8ab9702b6
commit
75ab8fe7b0
2 changed files with 54 additions and 40 deletions
|
@ -1,6 +1,6 @@
|
||||||
import React, {useEffect, useState} from 'react';
|
import React, {useEffect, useState} from 'react';
|
||||||
import {Image, SafeAreaView, ScrollView, StatusBar, StyleSheet, Switch, View} from 'react-native';
|
import {Image, SafeAreaView, ScrollView, StatusBar, StyleSheet, Switch, View, Dimensions} from 'react-native';
|
||||||
import Mapbox, {MapView} from "@rnmapbox/maps";
|
import Mapbox, {Callout, Camera, MapView, PointAnnotation} from "@rnmapbox/maps";
|
||||||
|
|
||||||
Mapbox.setAccessToken("pk.eyJ1IjoibWFhcnRlbnZyOTgiLCJhIjoiY2x6ZDFqMGp1MGVyejJrczhqcXpvYm9iYiJ9.XvYcL62dWiJQiFmG6mOoug");
|
Mapbox.setAccessToken("pk.eyJ1IjoibWFhcnRlbnZyOTgiLCJhIjoiY2x6ZDFqMGp1MGVyejJrczhqcXpvYm9iYiJ9.XvYcL62dWiJQiFmG6mOoug");
|
||||||
|
|
||||||
|
@ -12,7 +12,6 @@ import List from '@/components/List';
|
||||||
import {Request} from '@/services/request';
|
import {Request} from '@/services/request';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export default function MapScreen() {
|
export default function MapScreen() {
|
||||||
const colorScheme = useColorScheme() ?? 'light';
|
const colorScheme = useColorScheme() ?? 'light';
|
||||||
|
|
||||||
|
@ -75,7 +74,7 @@ export default function MapScreen() {
|
||||||
return (
|
return (
|
||||||
<SafeAreaView style={{flex: 1, backgroundColor: Colors[colorScheme].background}}>
|
<SafeAreaView style={{flex: 1, backgroundColor: Colors[colorScheme].background}}>
|
||||||
<ThemedView style={styles.container}>
|
<ThemedView style={styles.container}>
|
||||||
<ScrollView>
|
<ThemedView>
|
||||||
<ThemedView style={styles.titleContainer}>
|
<ThemedView style={styles.titleContainer}>
|
||||||
<ThemedText type="title">Afvalcontainers</ThemedText>
|
<ThemedText type="title">Afvalcontainers</ThemedText>
|
||||||
</ThemedView>
|
</ThemedView>
|
||||||
|
@ -87,24 +86,33 @@ export default function MapScreen() {
|
||||||
<ThemedView style={styles.mapContainer}>
|
<ThemedView style={styles.mapContainer}>
|
||||||
<MapView
|
<MapView
|
||||||
style={styles.map}
|
style={styles.map}
|
||||||
|
logoEnabled={false}
|
||||||
|
scaleBarEnabled={false}
|
||||||
|
attributionEnabled={false}
|
||||||
>
|
>
|
||||||
{/*{activeMarkers().map((marker: any, index: any) => (*/}
|
<Camera
|
||||||
{/* <Marker*/}
|
centerCoordinate={[5.630960, 52.043420]}
|
||||||
{/* key={index}*/}
|
zoomLevel={13}
|
||||||
{/* tracksViewChanges={false}*/}
|
animationMode={'none'}
|
||||||
{/* coordinate={{*/}
|
/>
|
||||||
{/* latitude: parseFloat(marker.latitude),*/}
|
{activeMarkers().map((marker: any, index: any) => (
|
||||||
{/* longitude: parseFloat(marker.longitude),*/}
|
<PointAnnotation
|
||||||
{/* }}*/}
|
key={marker.id.toString()}
|
||||||
{/* title={marker.number}*/}
|
id={marker.id.toString()}
|
||||||
{/* description={marker.description}*/}
|
coordinate={marker.coordinate}
|
||||||
{/* pinColor={marker.marker_color}*/}
|
>
|
||||||
{/* />*/}
|
<Callout title={marker.number}>
|
||||||
{/*))}*/}
|
<ThemedView style={styles.callout}>
|
||||||
|
<ThemedText>{marker.description + ' - ' + marker.street}</ThemedText>
|
||||||
|
</ThemedView>
|
||||||
|
</Callout>
|
||||||
|
</PointAnnotation>
|
||||||
|
))}
|
||||||
</MapView>
|
</MapView>
|
||||||
</ThemedView>
|
</ThemedView>
|
||||||
|
</ThemedView>
|
||||||
|
|
||||||
<ThemedView style={styles.listContainer}>
|
<ScrollView style={styles.listContainer}>
|
||||||
<List
|
<List
|
||||||
data={types}
|
data={types}
|
||||||
renderItem={(item: any, index: any) => (
|
renderItem={(item: any, index: any) => (
|
||||||
|
@ -122,7 +130,6 @@ export default function MapScreen() {
|
||||||
/>
|
/>
|
||||||
</ThemedView>
|
</ThemedView>
|
||||||
)}/>
|
)}/>
|
||||||
</ThemedView>
|
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
</ThemedView>
|
</ThemedView>
|
||||||
</SafeAreaView>
|
</SafeAreaView>
|
||||||
|
@ -133,6 +140,7 @@ const styles = StyleSheet.create({
|
||||||
container: {
|
container: {
|
||||||
marginTop: StatusBar.currentHeight,
|
marginTop: StatusBar.currentHeight,
|
||||||
paddingTop: 25,
|
paddingTop: 25,
|
||||||
|
flex: 1,
|
||||||
},
|
},
|
||||||
titleContainer: {
|
titleContainer: {
|
||||||
paddingLeft: 25,
|
paddingLeft: 25,
|
||||||
|
@ -144,14 +152,16 @@ const styles = StyleSheet.create({
|
||||||
},
|
},
|
||||||
mapContainer: {
|
mapContainer: {
|
||||||
marginTop: 15,
|
marginTop: 15,
|
||||||
|
height: 400,
|
||||||
},
|
},
|
||||||
map: {
|
map: {
|
||||||
width: '100%',
|
width: Dimensions.get('window').width,
|
||||||
height: 500,
|
height: 400,
|
||||||
flex: 1,
|
flex: 1,
|
||||||
},
|
},
|
||||||
listContainer: {
|
listContainer: {
|
||||||
marginTop: 10,
|
flex: 1,
|
||||||
|
marginTop: 20,
|
||||||
paddingLeft: 25,
|
paddingLeft: 25,
|
||||||
paddingRight: 25,
|
paddingRight: 25,
|
||||||
},
|
},
|
||||||
|
@ -176,5 +186,9 @@ const styles = StyleSheet.create({
|
||||||
height: 30,
|
height: 30,
|
||||||
borderRadius: 5,
|
borderRadius: 5,
|
||||||
marginRight: 8,
|
marginRight: 8,
|
||||||
}
|
},
|
||||||
|
callout: {
|
||||||
|
width: 200,
|
||||||
|
padding: 5,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -2,7 +2,7 @@ import axios from 'axios';
|
||||||
|
|
||||||
const API_URL = 'https://kliko.maartenvr98.nl/api/v1/';
|
const API_URL = 'https://kliko.maartenvr98.nl/api/v1/';
|
||||||
const CONFIG = {
|
const CONFIG = {
|
||||||
timeout: 3000,
|
timeout: 30000,
|
||||||
};
|
};
|
||||||
|
|
||||||
export class Request {
|
export class Request {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue