aboutsummaryrefslogtreecommitdiff
path: root/modern/src/MainMap.js
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2018-09-07 16:09:01 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2018-09-07 16:09:01 +1200
commit72aa50650203d6db0b17de59bfd98c9d5b06e3e7 (patch)
tree0cdd9aced5356f8e32d23069cd0bec2b5c8ef484 /modern/src/MainMap.js
parent06c4ee387669b1ccb5aa3928fbaa7c3650bfb7fa (diff)
downloadtrackermap-web-72aa50650203d6db0b17de59bfd98c9d5b06e3e7.tar.gz
trackermap-web-72aa50650203d6db0b17de59bfd98c9d5b06e3e7.tar.bz2
trackermap-web-72aa50650203d6db0b17de59bfd98c9d5b06e3e7.zip
Add redux and load positions
Diffstat (limited to 'modern/src/MainMap.js')
-rw-r--r--modern/src/MainMap.js28
1 files changed, 19 insertions, 9 deletions
diff --git a/modern/src/MainMap.js b/modern/src/MainMap.js
index 3388d670..0e93ddba 100644
--- a/modern/src/MainMap.js
+++ b/modern/src/MainMap.js
@@ -1,28 +1,38 @@
import React, { Component } from 'react';
import { Map, TileLayer, Marker, Popup } from 'react-leaflet';
+import { connect } from 'react-redux'
+
+const mapStateToProps = state => ({
+ positions: state.positions
+});
class MainMap extends Component {
state = {
- lat: 51.505,
- lng: -0.09,
- zoom: 13,
+ lat: 0,
+ lng: 0,
+ zoom: 3,
}
render() {
const position = [this.state.lat, this.state.lng]
+
+ const markers = this.props.positions.map((position) =>
+ <Marker key={position.id.toString()} position={{ lat: position.latitude, lng: position.longitude }}>
+ <Popup>
+ A pretty CSS3 popup. <br /> Easily customizable.
+ </Popup>
+ </Marker>
+ );
+
return (
<Map style={{height: this.props.height, width: this.props.width}} center={position} zoom={this.state.zoom}>
<TileLayer
attribution='&copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors, &copy; <a href="https://carto.com/attributions">CARTO</a>'
url="https://cartodb-basemaps-a.global.ssl.fastly.net/light_all/{z}/{x}/{y}.png" />
- <Marker position={position}>
- <Popup>
- A pretty CSS3 popup. <br /> Easily customizable.
- </Popup>
- </Marker>
+ {markers}
</Map>
)
}
}
-export default MainMap;
+export default connect(mapStateToProps)(MainMap);