Skip to content

Commit

Permalink
make it clearer that the added protocol is for PMTiles only
Browse files Browse the repository at this point in the history
  • Loading branch information
prusswan committed Jan 24, 2025
1 parent 7693217 commit a2809a9
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/components/MapMaplibreGl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ type MapMaplibreGlState = {
geocoder: MaplibreGeocoder | null;
zoomControl: ZoomControl | null;
zoom?: number;
protocol: Protocol | null;
pmtilesProtocol: Protocol | null;
};

class MapMaplibreGlInternal extends React.Component<MapMaplibreGlInternalProps, MapMaplibreGlState> {
Expand All @@ -95,7 +95,7 @@ class MapMaplibreGlInternal extends React.Component<MapMaplibreGlInternalProps,
inspect: null,
geocoder: null,
zoomControl: null,
protocol: new Protocol({metadata: true})
pmtilesProtocol: new Protocol({metadata: true})
}
i18next.on('languageChanged', () => {
this.forceUpdate();
Expand Down Expand Up @@ -140,7 +140,7 @@ class MapMaplibreGlInternal extends React.Component<MapMaplibreGlInternalProps,

if (this.props.localPMTiles) {
const file = this.props.localPMTiles;
this.state.protocol!.add(file); // this is necessary for non-HTTP sources
this.state.pmtilesProtocol!.add(file); // this is necessary for non-HTTP sources

if (map) {
file.getMetadata().then((metadata: any) => {
Expand All @@ -166,8 +166,7 @@ class MapMaplibreGlInternal extends React.Component<MapMaplibreGlInternalProps,
localIdeographFontFamily: false
} satisfies MapOptions;

const protocol = this.state.protocol;
MapLibreGl.addProtocol("pmtiles", protocol!.tile);
MapLibreGl.addProtocol("pmtiles", this.state.pmtilesProtocol!.tile);

const map = new MapLibreGl.Map(mapOpts);

Expand Down

0 comments on commit a2809a9

Please # to comment.