diff --git a/app/src/Inspector.tsx b/app/src/Inspector.tsx index 75bc289..093ac4f 100644 --- a/app/src/Inspector.tsx +++ b/app/src/Inspector.tsx @@ -25,7 +25,7 @@ const Pane = styled("div", { justifyContent: "center", backgroundSize: "20px 20px", backgroundImage: - "linear-gradient(to right, #222 1px, transparent 1px),linear-gradient(to bottom, #222 1px, transparent 1px);", + "linear-gradient(to right, #111 1px, transparent 1px),linear-gradient(to bottom, #111 1px, transparent 1px);", }); const TableRow = styled( @@ -141,7 +141,8 @@ const StyledFeatureProperties = styled("div", { position: "absolute", right: 0, bottom: 0, - backgroundColor: "red", + backgroundColor: "$black", + padding: "$1" }); const FeatureProperties = (props: { feature: Feature }) => { @@ -302,6 +303,7 @@ function Inspector(props: { file: PMTiles }) { y offset length + is directory {rows} diff --git a/app/src/Loader.tsx b/app/src/Loader.tsx index 462a441..78b326d 100644 --- a/app/src/Loader.tsx +++ b/app/src/Loader.tsx @@ -50,7 +50,7 @@ const StyledLink = styled( justifyContent: "center", alignItems: "center", }, - { "&:hover": { backgroundColor: "transparent", cursor: "pointer" } } + { "&:hover": { backgroundColor: "$hover", color:"$white", cursor: "pointer" } } ); const StyledToggleGroup = styled(ToolbarPrimitive.ToggleGroup, { @@ -63,10 +63,18 @@ const StyledToggleItem = styled(ToolbarPrimitive.ToggleItem, { boxShadow: 0, backgroundColor: "white", marginLeft: 2, + cursor: "pointer", "&:first-child": { marginLeft: 0 }, - "&[data-state=on]": { backgroundColor: "$primary", color: "white" }, + "&[data-state=on]": { backgroundColor: "$primary", color: "$primaryText" }, }); +const MetadataButton = styled(DialogPrimitive.Trigger, { + backgroundColor:"$primary", + color:"$primaryText", + padding:"$1", + cursor: "pointer" +}) + const StyledOverlay = styled(DialogPrimitive.Overlay, { backgroundColor: "black", position: "fixed", @@ -76,18 +84,36 @@ const StyledOverlay = styled(DialogPrimitive.Overlay, { }); const StyledContent = styled(DialogPrimitive.Content, { - backgroundColor: "$black", + backgroundColor: "#222", + padding:"$1", borderRadius: 6, position: "fixed", top: "50%", left: "50%", transform: "translate(-50%, -50%)", width: "90vw", - maxWidth: "80vh", zIndex: 4, "&:focus": { outline: "none" }, }); +const MetadataTable = styled("table", { + tableLayout:"fixed", + width:"100%" +}); + +const MetadataKey = styled("td", { + padding: "0 $1" +}); + +const MetadataValue = styled("td", { + fontFamily:"monospace", +}); + +const JsonValue = styled(MetadataValue, { + overflowX:"scroll" +}) + + export const introspectTileType = async (file: PMTiles): Promise => { let magic = await file.source.getBytes(512000, 4); let b0 = magic.getUint8(0); @@ -139,12 +165,13 @@ function Loader(props: { file: PMTiles }) { fetchData(); }, [props.file]); - const metadataRows = metadata.map((d, i) => ( - - {d[0]} - {d[1]} + const metadataRows = metadata.map((d, i) => { + let Cls = (d[0] === 'json') ? JsonValue : MetadataValue + return + {d[0]} + {d[1]} - )); + }); const closeModal = () => { setModalOpen(false); @@ -174,9 +201,9 @@ function Loader(props: { file: PMTiles }) { {props.file.source.getKey()} - setModalOpen(true)}> + setModalOpen(true)}> Metadata - + - + @@ -193,7 +220,7 @@ function Loader(props: { file: PMTiles }) { {metadataRows} -
key
+
diff --git a/app/src/MaplibreMap.tsx b/app/src/MaplibreMap.tsx index 97ef6b7..8f8fd2e 100644 --- a/app/src/MaplibreMap.tsx +++ b/app/src/MaplibreMap.tsx @@ -115,6 +115,12 @@ function MaplibreMap(props: { file: PMTiles }) { useEffect(() => { let initStyle = async () => { if (map) { + let metadata = await props.file.metadata(); + let bounds = metadata.bounds.split(','); + map.fitBounds([ + [+bounds[0], +bounds[1]], + [+bounds[2], +bounds[3]], + ]); let tileType = await introspectTileType(props.file); let style: any; // TODO maplibre types (not any) if (tileType === TileType.PNG || tileType == TileType.JPG) { diff --git a/app/src/Start.tsx b/app/src/Start.tsx index 67b1d36..4499706 100644 --- a/app/src/Start.tsx +++ b/app/src/Start.tsx @@ -45,6 +45,7 @@ const Container = styled("div", { const Button = styled("button", { padding: "$1 $2", + marginBottom:"$1", borderRadius: "$2", cursor: "pointer", variants: { @@ -79,7 +80,7 @@ const Example = styled("div", { borderBottom: "1px solid $white", }, "&:hover": { - backgroundColor: "$white", + backgroundColor: "$hover", }, variants: { selected: { @@ -142,7 +143,7 @@ function Start(props: { onChange={onRemoteUrlChangeHandler} > diff --git a/app/src/stitches.config.ts b/app/src/stitches.config.ts index 15f425a..04b1a71 100644 --- a/app/src/stitches.config.ts +++ b/app/src/stitches.config.ts @@ -7,6 +7,7 @@ export const { styled } = createStitches({ white: "rgba(236, 237, 238)", hover: "#7180B9", primary: "#3423A6", + primaryText: "white" }, fonts: { sans: "Inter, sans-serif",