-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrenderMarkers.js
More file actions
59 lines (50 loc) · 1.73 KB
/
renderMarkers.js
File metadata and controls
59 lines (50 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import React, { Component } from "react";
import { View } from "react-native";
import { Marker, Geojson } from "react-native-maps";
const services = require("./assets/services.json");
const parkings = require("./assets/parkings.json");
const kiwi = require("./assets/kiwi.json");
const ewings = require("./assets/ewings.json");
const parkingIcon = require("./assets/parking.png");
const serviceIcon = require("./assets/service.png");
class RenderMarker extends Component {
constructor(props) {
super(props),
this.state = {
services: false,
parking: false,
kiwi: false,
ewings: false,
}
}
showMarkers(geojson, icon)
{
return geojson.features.map((element, index) => (
<Marker
coordinate={{ latitude: element.geometry.coordinates[1], longitude: element.geometry.coordinates[0]} }
icon={icon}
key={index}
/>
))
}
setRenderMarkers(s)
{
this.setState(s);
}
render() {
return (
<View initialRegion={{
latitude: 52.5,
longitude: 19.2,
latitudeDelta: 8.5,
longitudeDelta: 8.5,
}}>
{ this.state.parking && this.showMarkers(parkings, parkingIcon) }
{ this.state.services && this.showMarkers(services, serviceIcon) }
{ this.state.ewings && <Geojson geojson={ewings} lineDashPattern={[1]} fillColor="rgba(48, 235, 45, 0.49)"/> }
{ this.state.kiwi && <Geojson geojson={kiwi} lineDashPattern={[1]} fillColor="rgba(48, 235, 45, 0.49)"/> }
</View>
)
}
}
export default RenderMarker;