@@ -5,6 +5,7 @@ import { useHistory, useLocation, useRouteMatch } from 'react-router-dom';
55import classnames from 'classnames' ;
66import * as maplibregl from 'maplibre-gl' ;
77import 'maplibre-gl/dist/maplibre-gl.css' ;
8+ import { Protocol as PmTilesProtocol } from 'pmtiles' ;
89
910import { MapInterface , MapProps } from './MapInterface' ;
1011import * as overlays from './overlays' ;
@@ -14,10 +15,13 @@ export { OverlayId } from './overlays';
1415import { RouteComponentProps } from 'react-router' ;
1516import stylesheet from './MainMap.less' ;
1617
17- const MAPLIBRE_STYLE = 'https://tiles.openfreemap.org/styles/liberty ';
18+ import mapStyleUrl from './fourties.protomaps.style.json ';
1819
1920const PHOTO_LAYER = 'photos-1940s' ;
2021
22+ const pmtilesProtocol = new PmTilesProtocol ( ) ;
23+ maplibregl . addProtocol ( 'pmtiles' , pmtilesProtocol . tile ) ;
24+
2125type PropsWithRouter = MapProps & RouteComponentProps < { identifier ?: string } > ;
2226
2327class 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