mirror of
https://github.com/protomaps/PMTiles.git
synced 2026-02-04 10:51:07 +00:00
app: viewer improvements [#49] * show missing id when feature id is undefined instead of 0 * improve point symbology for dense point tilesets * show lon,lat in popup * better wrapping for long popup value strings
55 lines
1.6 KiB
TypeScript
55 lines
1.6 KiB
TypeScript
import { For, Show } from "solid-js";
|
|
|
|
export interface InspectableFeature {
|
|
layerName: string;
|
|
type: number;
|
|
id: number | undefined;
|
|
properties: { [key: string]: string | number | boolean };
|
|
}
|
|
|
|
const intToGeomType = (n: number) => {
|
|
if (n === 1) return "Point";
|
|
if (n === 2) return "LineString";
|
|
return "Polygon";
|
|
};
|
|
|
|
export const FeatureTable = (props: { features: InspectableFeature[] }) => {
|
|
return (
|
|
<div class="max-h-120 overflow-y-scroll max-w-200 divide-y app-divide">
|
|
<For each={props.features}>
|
|
{(f) => (
|
|
<div class="p-2">
|
|
<div>
|
|
{f.layerName}{" "}
|
|
<span class="app-text-light">{intToGeomType(f.type)}</span>
|
|
</div>
|
|
<div class="text-xs font-mono app-text-light">
|
|
<Show when={f.id !== undefined} fallback={"missing ID"}>
|
|
ID {f.id}
|
|
</Show>
|
|
</div>
|
|
<table class="font-mono table-auto border-separate border-spacing-x-2">
|
|
<tbody>
|
|
<For each={Object.entries(f.properties)}>
|
|
{([key, value]) => (
|
|
<tr>
|
|
<td class="text-right app-text-light break-keep">
|
|
{key}
|
|
</td>
|
|
<td class="break-all">
|
|
{typeof value === "boolean"
|
|
? JSON.stringify(value)
|
|
: value.toString()}
|
|
</td>
|
|
</tr>
|
|
)}
|
|
</For>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
)}
|
|
</For>
|
|
</div>
|
|
);
|
|
};
|