colouring-montreal/app/src/frontend/map/layers/housing-boundary-layer.tsx

27 lines
1.3 KiB
TypeScript
Raw Normal View History

2022-12-05 19:04:03 -05:00
import { GeoJsonObject } from 'geojson';
import React, { useEffect, useState } from 'react';
import { GeoJSON } from 'react-leaflet';
import { apiGet } from '../../apiHelpers';
import { useDisplayPreferences } from '../../displayPreferences-context';
2022-12-05 19:04:03 -05:00
export function HousingBoundaryLayer() {
2022-12-05 19:04:03 -05:00
const [boundaryGeojson, setBoundaryGeojson] = useState<GeoJsonObject>(null);
const { housing } = useDisplayPreferences();
2022-12-05 19:04:03 -05:00
useEffect(() => {
apiGet('/geometries/housing_zones.geojson')
.then(data => setBoundaryGeojson(data as GeoJsonObject));
}, []);
if(housing == "enabled") {
2022-12-05 19:04:03 -05:00
return boundaryGeojson &&
<GeoJSON
attribution="Housing Zones from <a href=https://data.london.gov.uk/dataset/housing_zones>London Datastore</a>. The boundaries are based on Ordnance Survey mapping and the data is published under Ordnance Survey's 'presumption to publish'. Contains OS data © Crown copyright and database rights 2019. Greater London Authority - Contains public sector information licensed under the <a href=https://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/>Open Government Licence v3.0</a>'"
data={boundaryGeojson}
2022-12-06 11:02:19 -05:00
style={{color: '#FF8000', fill: true, weight: 1, opacity: 0.6}}
2022-12-05 19:04:03 -05:00
/>;
} else if (housing == "disabled") {
2022-12-05 19:04:03 -05:00
return <div></div>
}
}