1
2
3
4
5
6
7
8
9import { MapView } from "mapgpu";
10import { RasterTileLayer } from "mapgpu/layers";
11import { RenderEngine } from "mapgpu/render";
12import { MilSymbolLayer } from "mapgpu/milsymbol";
13
14import type { RunResultObject } from "@/components/examples/ExampleCanvas";
15
16
17
18
19const DATA = {
20 type: "FeatureCollection" as const,
21 features: [
22
23 { type: "Feature" as const, properties: { sidc: "100310000012110000000000000000" }, geometry: { type: "Point" as const, coordinates: [32.80, 39.95] } },
24 { type: "Feature" as const, properties: { sidc: "100310000012120000000000000000" }, geometry: { type: "Point" as const, coordinates: [32.86, 39.96] } },
25 { type: "Feature" as const, properties: { sidc: "100310000012130000000000000000" }, geometry: { type: "Point" as const, coordinates: [32.92, 39.93] } },
26 { type: "Feature" as const, properties: { sidc: "100310000012140000000000000000" }, geometry: { type: "Point" as const, coordinates: [32.98, 39.94] } },
27 { type: "Feature" as const, properties: { sidc: "100310000012150000000000000000" }, geometry: { type: "Point" as const, coordinates: [33.04, 39.92] } },
28 { type: "Feature" as const, properties: { sidc: "100310000012160000000000000000" }, geometry: { type: "Point" as const, coordinates: [32.84, 39.88] } },
29 { type: "Feature" as const, properties: { sidc: "100310000012180000000000000000" }, geometry: { type: "Point" as const, coordinates: [32.90, 39.86] } },
30
31 { type: "Feature" as const, properties: { sidc: "100301000012010200000000000000" }, geometry: { type: "Point" as const, coordinates: [32.76, 40.02] } },
32
33 { type: "Feature" as const, properties: { sidc: "100610000012110000000000000000" }, geometry: { type: "Point" as const, coordinates: [33.15, 40.05] } },
34 { type: "Feature" as const, properties: { sidc: "100610000012120000000000000000" }, geometry: { type: "Point" as const, coordinates: [33.22, 40.02] } },
35 { type: "Feature" as const, properties: { sidc: "100610000012130000000000000000" }, geometry: { type: "Point" as const, coordinates: [33.28, 39.98] } },
36
37 { type: "Feature" as const, properties: { sidc: "100410000012110000000000000000" }, geometry: { type: "Point" as const, coordinates: [32.70, 40.05] } },
38 { type: "Feature" as const, properties: { sidc: "100110000012110000000000000000" }, geometry: { type: "Point" as const, coordinates: [32.68, 39.88] } },
39 ],
40};
41
42export async function run(container: HTMLElement): Promise<RunResultObject> {
43 const view = new MapView({
44 container,
45 renderEngine: new RenderEngine(),
46 mode: "2d",
47 center: [33.0, 39.95],
48 zoom: 9,
49 minZoom: 4,
50 maxZoom: 18,
51 backgroundColor: "transparent",
52 });
53
54 view.map.add(
55 new RasterTileLayer({
56 id: "osm",
57 urlTemplate: "https://tile.openstreetmap.org/{z}/{x}/{y}.png",
58 maxZoom: 19,
59 attribution: "© OpenStreetMap contributors",
60 }),
61 );
62
63 const mil = new MilSymbolLayer({ id: "milsym", data: DATA, size: 56 });
64 await mil.attachTo(view as unknown as MapView);
65 view.map.add(mil.layer);
66
67 await view.when();
68
69 return {
70 dispose: () => view.destroy(),
71 controls: [],
72 };
73}