Skip to content

Commit

Permalink
removed unused prop (files in AppToolbar)
Browse files Browse the repository at this point in the history
fixed TypeScript errors
  • Loading branch information
prusswan committed Jan 24, 2025
1 parent 0fbda5d commit cdfe88f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
5 changes: 3 additions & 2 deletions src/components/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ type AppState = {
debug: boolean
}
fileHandle: FileSystemFileHandle | null
file: PMTiles | null
}

export default class App extends React.Component<any, AppState> {
Expand Down Expand Up @@ -287,6 +288,7 @@ export default class App extends React.Component<any, AppState> {
debugToolbox: false,
},
fileHandle: null,
file: null
}

this.layerWatcher = new LayerWatcher({
Expand Down Expand Up @@ -882,7 +884,7 @@ export default class App extends React.Component<any, AppState> {
});
}

onFileSelected = (e) => {
onFileSelected = (e: File[]) => {
var file = e[0];

Check failure on line 888 in src/components/App.tsx

View workflow job for this annotation

GitHub Actions / build on ubuntu-latest

Unexpected var, use let or const instead

Check failure on line 888 in src/components/App.tsx

View workflow job for this annotation

GitHub Actions / build on windows-latest

Unexpected var, use let or const instead

Check failure on line 888 in src/components/App.tsx

View workflow job for this annotation

GitHub Actions / build on macos-latest

Unexpected var, use let or const instead
var pmt = new PMTiles(new FileSource(file));

Check failure on line 889 in src/components/App.tsx

View workflow job for this annotation

GitHub Actions / build on ubuntu-latest

Unexpected var, use let or const instead

Check failure on line 889 in src/components/App.tsx

View workflow job for this annotation

GitHub Actions / build on windows-latest

Unexpected var, use let or const instead

Check failure on line 889 in src/components/App.tsx

View workflow job for this annotation

GitHub Actions / build on macos-latest

Unexpected var, use let or const instead
console.log("App.onFileSelected", pmt);
Expand All @@ -905,7 +907,6 @@ export default class App extends React.Component<any, AppState> {
onStyleOpen={this.onStyleChanged}
onSetMapState={this.setMapState}
onToggleModal={this.toggleModal.bind(this)}
files={this.state.files}
onFileSelected={this.onFileSelected}
/>

Expand Down
1 change: 1 addition & 0 deletions src/components/AppToolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ type AppToolbarInternalProps = {
onSetMapState(mapState: MapState): unknown
mapState?: MapState
renderer?: string
onFileSelected(...args: unknown[]): unknown
} & WithTranslation;

class AppToolbarInternal extends React.Component<AppToolbarInternalProps> {
Expand Down
12 changes: 7 additions & 5 deletions src/components/MapMaplibreGl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import MaplibreGeocoder, { MaplibreGeocoderApi, MaplibreGeocoderApiConfig } from
import '@maplibre/maplibre-gl-geocoder/dist/maplibre-gl-geocoder.css';
import { withTranslation, WithTranslation } from 'react-i18next'
import i18next from 'i18next'
import { Protocol } from "pmtiles";
import { PMTiles, Protocol } from "pmtiles";

function renderPopup(popup: JSX.Element, mountNode: ReactDOM.Container): HTMLElement {
ReactDOM.render(popup, mountNode);
Expand Down Expand Up @@ -66,6 +66,7 @@ type MapMaplibreGlInternalProps = {
}
replaceAccessTokens(mapStyle: StyleSpecification): StyleSpecification
onChange(value: {center: LngLat, zoom: number}): unknown
file: PMTiles | null;
} & WithTranslation;

type MapMaplibreGlState = {
Expand All @@ -74,6 +75,7 @@ type MapMaplibreGlState = {
geocoder: MaplibreGeocoder | null;
zoomControl: ZoomControl | null;
zoom?: number;
protocol: Protocol | null;
};

class MapMaplibreGlInternal extends React.Component<MapMaplibreGlInternalProps, MapMaplibreGlState> {
Expand Down Expand Up @@ -138,11 +140,11 @@ class MapMaplibreGlInternal extends React.Component<MapMaplibreGlInternalProps,

if (this.props.file) {
let file = this.props.file;

Check failure on line 142 in src/components/MapMaplibreGl.tsx

View workflow job for this annotation

GitHub Actions / build on ubuntu-latest

'file' is never reassigned. Use 'const' instead

Check failure on line 142 in src/components/MapMaplibreGl.tsx

View workflow job for this annotation

GitHub Actions / build on windows-latest

'file' is never reassigned. Use 'const' instead

Check failure on line 142 in src/components/MapMaplibreGl.tsx

View workflow job for this annotation

GitHub Actions / build on macos-latest

'file' is never reassigned. Use 'const' instead
this.state.protocol.add(file); // this is necessary for non-HTTP sources
this.state.protocol!.add(file); // this is necessary for non-HTTP sources

if (map) {
file.getMetadata().then((metadata) => {
let layerNames = metadata.vector_layers.map((e) => e.id);
file.getMetadata().then((metadata: any) => {
let layerNames = metadata.vector_layers.map((e: LayerSpecification) => e.id);

Check failure on line 147 in src/components/MapMaplibreGl.tsx

View workflow job for this annotation

GitHub Actions / build on ubuntu-latest

'layerNames' is never reassigned. Use 'const' instead

Check failure on line 147 in src/components/MapMaplibreGl.tsx

View workflow job for this annotation

GitHub Actions / build on windows-latest

'layerNames' is never reassigned. Use 'const' instead

Check failure on line 147 in src/components/MapMaplibreGl.tsx

View workflow job for this annotation

GitHub Actions / build on macos-latest

'layerNames' is never reassigned. Use 'const' instead

map.style.sourceCaches["source"]._source.vectorLayerIds = layerNames;
console.log("layerNames for inspect:", layerNames);
Expand All @@ -165,7 +167,7 @@ class MapMaplibreGlInternal extends React.Component<MapMaplibreGlInternalProps,
} satisfies MapOptions;

let protocol = this.state.protocol;

Check failure on line 169 in src/components/MapMaplibreGl.tsx

View workflow job for this annotation

GitHub Actions / build on ubuntu-latest

'protocol' is never reassigned. Use 'const' instead

Check failure on line 169 in src/components/MapMaplibreGl.tsx

View workflow job for this annotation

GitHub Actions / build on windows-latest

'protocol' is never reassigned. Use 'const' instead

Check failure on line 169 in src/components/MapMaplibreGl.tsx

View workflow job for this annotation

GitHub Actions / build on macos-latest

'protocol' is never reassigned. Use 'const' instead
MapLibreGl.addProtocol("pmtiles",protocol.tile);
MapLibreGl.addProtocol("pmtiles", protocol!.tile);

const map = new MapLibreGl.Map(mapOpts);

Expand Down

0 comments on commit cdfe88f

Please sign in to comment.