Skip to content

Commit e43e2a1

Browse files
committed
Custom protomap
1 parent 25fd627 commit e43e2a1

File tree

4 files changed

+4903
-4
lines changed

4 files changed

+4903
-4
lines changed

frontend/src/screens/App/screens/MapPane/components/MainMap/MapLibreMap.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { useHistory, useLocation, useRouteMatch } from 'react-router-dom';
55
import classnames from 'classnames';
66
import * as maplibregl from 'maplibre-gl';
77
import 'maplibre-gl/dist/maplibre-gl.css';
8+
import { Protocol as PmTilesProtocol } from 'pmtiles';
89

910
import { MapInterface, MapProps } from './MapInterface';
1011
import * as overlays from './overlays';
@@ -14,10 +15,13 @@ export { OverlayId } from './overlays';
1415
import { RouteComponentProps } from 'react-router';
1516
import stylesheet from './MainMap.less';
1617

17-
const MAPLIBRE_STYLE = 'https://tiles.openfreemap.org/styles/liberty';
18+
import mapStyleUrl from './fourties.protomaps.style.json';
1819

1920
const PHOTO_LAYER = 'photos-1940s';
2021

22+
const pmtilesProtocol = new PmTilesProtocol();
23+
maplibregl.addProtocol('pmtiles', pmtilesProtocol.tile);
24+
2125
type PropsWithRouter = MapProps & RouteComponentProps<{ identifier?: string }>;
2226

2327
class MapLibreMap
@@ -28,9 +32,10 @@ class MapLibreMap
2832
private map: maplibregl.Map;
2933

3034
componentDidMount(): void {
35+
console.log(mapStyleUrl);
3136
const map: maplibregl.Map = new maplibregl.Map({
3237
container: this.mapContainer,
33-
style: MAPLIBRE_STYLE,
38+
style: mapStyleUrl as unknown as string,
3439
center: [-73.99397, 40.7093],
3540
zoom: 13.69,
3641
maxBounds: [
@@ -41,6 +46,8 @@ class MapLibreMap
4146
});
4247
this.map = map;
4348

49+
map.addControl(new maplibregl.AttributionControl());
50+
4451
map.on('click', PHOTO_LAYER, (e) => {
4552
const { panOnClick } = this.props;
4653
if (panOnClick) map.panTo(e.lngLat);

0 commit comments

Comments
 (0)