diff options
author | ditoaugusta <dt_ap@ymail.com> | 2020-03-24 15:04:52 +0700 |
---|---|---|
committer | ditoaugusta <dt_ap@ymail.com> | 2020-03-24 15:04:52 +0700 |
commit | 2f8ae58f4f5cde892b4b6981a83a37edc1422a2c (patch) | |
tree | f9354abc103d4dde4f98effbdf46739fefe4ac1f /modern/src/MainMap.js | |
parent | 78d69f50595e058a08f3eaaa47fd7c3745fa1266 (diff) | |
download | trackermap-web-2f8ae58f4f5cde892b4b6981a83a37edc1422a2c.tar.gz trackermap-web-2f8ae58f4f5cde892b4b6981a83a37edc1422a2c.tar.bz2 trackermap-web-2f8ae58f4f5cde892b4b6981a83a37edc1422a2c.zip |
experiment: redux toolkit
Diffstat (limited to 'modern/src/MainMap.js')
-rw-r--r-- | modern/src/MainMap.js | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/modern/src/MainMap.js b/modern/src/MainMap.js index 35b933b4..01230da9 100644 --- a/modern/src/MainMap.js +++ b/modern/src/MainMap.js @@ -4,8 +4,8 @@ import { connect } from 'react-redux'; import mapboxgl from 'mapbox-gl'; const calculateMapCenter = (state) => { - if (state.selectedDevice) { - const position = state.positions.get(state.selectedDevice); + if (state.devices.selectedId) { + const position = state.positions.items[state.devices.selectedId] || null; if (position) { return [position.longitude, position.latitude]; } @@ -14,8 +14,9 @@ const calculateMapCenter = (state) => { } const mapFeatureProperties = (state, position) => { + const device = state.devices.items[position.deviceId] || null; return { - name: state.devices.get(position.deviceId).name + name: device ? device.name : '' } } @@ -23,7 +24,7 @@ const mapStateToProps = state => ({ mapCenter: calculateMapCenter(state), data: { type: 'FeatureCollection', - features: Array.from(state.positions.values()).map(position => ({ + features: Object.values(state.positions.items).map(position => ({ type: 'Feature', geometry: { type: 'Point', |