Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display service request details in map popup #1011

Merged
merged 7 commits into from
Mar 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 66 additions & 38 deletions client/components/Map/Map.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ import RequestDetail from './RequestDetail';

const styles = theme => ({
root: {
height: '100%',
position: 'absolute',
top: 0,
bottom: 0,
width: '100%',
margin: '0 auto',
'& canvas.mapboxgl-canvas:focus': {
outline: 'none',
Expand All @@ -49,6 +52,32 @@ const styles = theme => ({
'& .mapboxgl-control-container': {
display: 'none',
},
'& .mapboxgl-popup-content': {
backgroundColor: theme.palette.primary.main,
borderRadius: 5,
padding: 10,
},
'& .mapboxgl-popup-close-button': {
fontSize: 24,
color: 'white',
padding: 0,
marginTop: 5,
marginRight: 5,
},
'& .mapboxgl-popup': {
'&-anchor-bottom .mapboxgl-popup-tip': {
borderTopColor: theme.palette.primary.main,
},
'&-anchor-top .mapboxgl-popup-tip': {
borderBottomColor: theme.palette.primary.main,
},
'&-anchor-left .mapboxgl-popup-tip': {
borderRightColor: theme.palette.primary.main,
},
'&-anchor-right .mapboxgl-popup-tip': {
borderLeftColor: theme.palette.primary.main,
},
},
},
})

Expand Down Expand Up @@ -123,7 +152,6 @@ class Map extends React.Component {
}
}

// requestsLayer requires requestTypes for circle-color
if (this.props.requestTypes != prevProps.requestTypes) {
this.requestsLayer.init({
map: this.map,
Expand Down Expand Up @@ -230,25 +258,25 @@ class Map extends React.Component {
}
};

reset = () => {
this.zoomOut();
this.addressLayer.setCenter(null);
this.ncLayer.clearSelectedRegion();
this.ccLayer.clearSelectedRegion();
this.removePopup();

this.setState({
locationInfo: INITIAL_LOCATION,
canReset: false,
});

this.map.once('zoomend', () => {
this.setState({
filterGeo: null,
canReset: true,
});
});
};
// reset = () => {
// this.zoomOut();
// this.addressLayer.setCenter(null);
// this.ncLayer.clearSelectedRegion();
// this.ccLayer.clearSelectedRegion();
// this.removePopup();

// this.setState({
// locationInfo: INITIAL_LOCATION,
// canReset: false,
// });

// this.map.once('zoomend', () => {
// this.setState({
// filterGeo: null,
// canReset: true,
// });
// });
// };

onClick = e => {
const masks = [
Expand Down Expand Up @@ -287,8 +315,8 @@ class Map extends React.Component {

if (feature.layer.id === 'request-circles') {
const { coordinates } = feature.geometry;
const { id } = feature.properties;
return this.addPopup(coordinates, id);
const { requestId, typeId } = feature.properties;
return this.addPopup(coordinates, requestId);
}
}
};
Expand Down Expand Up @@ -331,23 +359,23 @@ class Map extends React.Component {
console.log(this.map.getCanvas().toDataURL());
};

setSelectedTypes = selectedTypes => {
this.setState({ selectedTypes });
};
// setSelectedTypes = selectedTypes => {
// this.setState({ selectedTypes });
// };

setActiveRequestsLayer = layerName => {
this.setState({ activeRequestsLayer: layerName });
};
// setActiveRequestsLayer = layerName => {
// this.setState({ activeRequestsLayer: layerName });
// };

setMapStyle = mapStyle => {
this.setState({ mapStyle });
this.map.setStyle(MAP_STYLES[mapStyle]);
this.map.once('styledata', () => this.initLayers(false));
};
// setMapStyle = mapStyle => {
// this.setState({ mapStyle });
// this.map.setStyle(MAP_STYLES[mapStyle]);
// this.map.once('styledata', () => this.initLayers(false));
// };

setColorScheme = scheme => {
this.setState({ colorScheme: scheme });
};
// setColorScheme = scheme => {
// this.setState({ colorScheme: scheme });
// };

getDistrictCounts = (geoFilterType, filterGeo, selectedTypes) => {
const { ncCounts, ccCounts } = this.props;
Expand Down Expand Up @@ -469,7 +497,7 @@ class Map extends React.Component {
boundaryStyle={mapStyle === 'dark' ? 'light' : 'dark'}
/>
<div ref={el => this.requestDetail = el}>
<RequestDetail srnumber={selectedRequestId} />
<RequestDetail requestId={selectedRequestId} />
</div>
{ this.state.mapReady && (
<>
Expand Down
Loading