Skip to content

Commit

Permalink
fix viewer app build [#287]
Browse files Browse the repository at this point in the history
  • Loading branch information
bdon committed Jan 30, 2024
1 parent 5bd7108 commit 0e82323
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
21 changes: 11 additions & 10 deletions app/src/MaplibreMap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,13 @@ interface LayerVisibility {
visible: boolean;
}

interface PMTilesMetadata {
name?: string;
type?: string;
tilestats?: unknown;
vector_layers: LayerSpecification[];
}

const LayersVisibilityController = (props: {
layers: LayerVisibility[];
onChange: (layers: LayerVisibility[]) => void;
Expand Down Expand Up @@ -181,7 +188,7 @@ const LayersVisibilityController = (props: {

const rasterStyle = async (file: PMTiles): Promise<StyleSpecification> => {
let header = await file.getHeader();
let metadata = await file.getMetadata();
let metadata= await file.getMetadata() as PMTilesMetadata;
let layers: LayerSpecification[] = [];

if (metadata.type !== "baselayer") {
Expand Down Expand Up @@ -222,7 +229,7 @@ const vectorStyle = async (
layersVisibility: LayerVisibility[];
}> => {
let header = await file.getHeader();
let metadata = await file.getMetadata();
let metadata = await file.getMetadata() as PMTilesMetadata;
let layers: LayerSpecification[] = [];
let baseOpacity = 0.35;

Expand All @@ -233,14 +240,8 @@ const vectorStyle = async (

var tilestats: any;
var vector_layers: LayerSpecification[];
if (metadata.json) {
let j = JSON.parse(metadata.json);
tilestats = j.tilestats;
vector_layers = j.vector_layers;
} else {
tilestats = metadata.tilestats;
vector_layers = metadata.vector_layers;
}
tilestats = metadata.tilestats;
vector_layers = metadata.vector_layers;

if (vector_layers) {
for (let [i, layer] of vector_layers.entries()) {
Expand Down
4 changes: 2 additions & 2 deletions app/src/Start.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useState, Dispatch, SetStateAction, useCallback } from "react";
import maplibregl from "maplibre-gl";
import { PMTiles, FileAPISource } from "../../js/index";
import { PMTiles, FileApiSource } from "../../js/index";
import { styled } from "./stitches.config";
import { useDropzone } from "react-dropzone";

Expand Down Expand Up @@ -108,7 +108,7 @@ function Start(props: {
setFile: Dispatch<SetStateAction<PMTiles | undefined>>;
}) {
const onDrop = useCallback((acceptedFiles: File[]) => {
props.setFile(new PMTiles(new FileAPISource(acceptedFiles[0])));
props.setFile(new PMTiles(new FileApiSource(acceptedFiles[0])));
}, []);

const { acceptedFiles, getRootProps, getInputProps } = useDropzone({
Expand Down

0 comments on commit 0e82323

Please # to comment.