removed unused prop (files in AppToolbar)

fixed TypeScript errors
This commit is contained in:
prusswan
2025-01-24 12:18:11 +08:00
parent 0fbda5dc84
commit cdfe88ffc0
3 changed files with 11 additions and 7 deletions
+3 -2
View File
@@ -131,6 +131,7 @@ type AppState = {
debug: boolean debug: boolean
} }
fileHandle: FileSystemFileHandle | null fileHandle: FileSystemFileHandle | null
file: PMTiles | null
} }
export default class App extends React.Component<any, AppState> { export default class App extends React.Component<any, AppState> {
@@ -287,6 +288,7 @@ export default class App extends React.Component<any, AppState> {
debugToolbox: false, debugToolbox: false,
}, },
fileHandle: null, fileHandle: null,
file: null
} }
this.layerWatcher = new LayerWatcher({ this.layerWatcher = new LayerWatcher({
@@ -882,7 +884,7 @@ export default class App extends React.Component<any, AppState> {
}); });
} }
onFileSelected = (e) => { onFileSelected = (e: File[]) => {
var file = e[0]; var file = e[0];
var pmt = new PMTiles(new FileSource(file)); var pmt = new PMTiles(new FileSource(file));
console.log("App.onFileSelected", pmt); console.log("App.onFileSelected", pmt);
@@ -905,7 +907,6 @@ export default class App extends React.Component<any, AppState> {
onStyleOpen={this.onStyleChanged} onStyleOpen={this.onStyleChanged}
onSetMapState={this.setMapState} onSetMapState={this.setMapState}
onToggleModal={this.toggleModal.bind(this)} onToggleModal={this.toggleModal.bind(this)}
files={this.state.files}
onFileSelected={this.onFileSelected} onFileSelected={this.onFileSelected}
/> />
+1
View File
@@ -105,6 +105,7 @@ type AppToolbarInternalProps = {
onSetMapState(mapState: MapState): unknown onSetMapState(mapState: MapState): unknown
mapState?: MapState mapState?: MapState
renderer?: string renderer?: string
onFileSelected(...args: unknown[]): unknown
} & WithTranslation; } & WithTranslation;
class AppToolbarInternal extends React.Component<AppToolbarInternalProps> { class AppToolbarInternal extends React.Component<AppToolbarInternalProps> {
+7 -5
View File
@@ -15,7 +15,7 @@ import MaplibreGeocoder, { MaplibreGeocoderApi, MaplibreGeocoderApiConfig } from
import '@maplibre/maplibre-gl-geocoder/dist/maplibre-gl-geocoder.css'; import '@maplibre/maplibre-gl-geocoder/dist/maplibre-gl-geocoder.css';
import { withTranslation, WithTranslation } from 'react-i18next' import { withTranslation, WithTranslation } from 'react-i18next'
import i18next from 'i18next' import i18next from 'i18next'
import { Protocol } from "pmtiles"; import { PMTiles, Protocol } from "pmtiles";
function renderPopup(popup: JSX.Element, mountNode: ReactDOM.Container): HTMLElement { function renderPopup(popup: JSX.Element, mountNode: ReactDOM.Container): HTMLElement {
ReactDOM.render(popup, mountNode); ReactDOM.render(popup, mountNode);
@@ -66,6 +66,7 @@ type MapMaplibreGlInternalProps = {
} }
replaceAccessTokens(mapStyle: StyleSpecification): StyleSpecification replaceAccessTokens(mapStyle: StyleSpecification): StyleSpecification
onChange(value: {center: LngLat, zoom: number}): unknown onChange(value: {center: LngLat, zoom: number}): unknown
file: PMTiles | null;
} & WithTranslation; } & WithTranslation;
type MapMaplibreGlState = { type MapMaplibreGlState = {
@@ -74,6 +75,7 @@ type MapMaplibreGlState = {
geocoder: MaplibreGeocoder | null; geocoder: MaplibreGeocoder | null;
zoomControl: ZoomControl | null; zoomControl: ZoomControl | null;
zoom?: number; zoom?: number;
protocol: Protocol | null;
}; };
class MapMaplibreGlInternal extends React.Component<MapMaplibreGlInternalProps, MapMaplibreGlState> { class MapMaplibreGlInternal extends React.Component<MapMaplibreGlInternalProps, MapMaplibreGlState> {
@@ -138,11 +140,11 @@ class MapMaplibreGlInternal extends React.Component<MapMaplibreGlInternalProps,
if (this.props.file) { if (this.props.file) {
let file = this.props.file; let file = this.props.file;
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) { if (map) {
file.getMetadata().then((metadata) => { file.getMetadata().then((metadata: any) => {
let layerNames = metadata.vector_layers.map((e) => e.id); let layerNames = metadata.vector_layers.map((e: LayerSpecification) => e.id);
map.style.sourceCaches["source"]._source.vectorLayerIds = layerNames; map.style.sourceCaches["source"]._source.vectorLayerIds = layerNames;
console.log("layerNames for inspect:", layerNames); console.log("layerNames for inspect:", layerNames);
@@ -165,7 +167,7 @@ class MapMaplibreGlInternal extends React.Component<MapMaplibreGlInternalProps,
} satisfies MapOptions; } satisfies MapOptions;
let protocol = this.state.protocol; let protocol = this.state.protocol;
MapLibreGl.addProtocol("pmtiles",protocol.tile); MapLibreGl.addProtocol("pmtiles", protocol!.tile);
const map = new MapLibreGl.Map(mapOpts); const map = new MapLibreGl.Map(mapOpts);