@geolonia/maps-core 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +135 -0
- package/dist/index.cjs +1881 -0
- package/dist/index.d.cts +206 -0
- package/dist/index.d.ts +206 -0
- package/dist/index.js +1841 -0
- package/package.json +54 -0
- package/src/assets/style.css +166 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import maplibregl, { IControl, ControlPosition, Map, MapOptions, ExpiryData, StyleSpecification, StyleSwapOptions, StyleOptions, GetResourceResponse, MarkerOptions } from 'maplibre-gl';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Custom Attribution Control using Shadow DOM.
|
|
5
|
+
* Based on maplibre-gl-js's AttributionControl.
|
|
6
|
+
* https://github.com/maplibre/maplibre-gl-js/blob/main/src/ui/control/attribution_control.ts
|
|
7
|
+
*
|
|
8
|
+
* Uses Shadow DOM to isolate attribution styles from the host page,
|
|
9
|
+
* preventing style conflicts. Collapses to an "i" icon on small maps.
|
|
10
|
+
*/
|
|
11
|
+
interface CustomAttributionControlOptions {
|
|
12
|
+
compact?: boolean;
|
|
13
|
+
customAttribution?: string | string[];
|
|
14
|
+
}
|
|
15
|
+
interface StyleDataEvent {
|
|
16
|
+
sourceDataType?: string;
|
|
17
|
+
dataType?: string;
|
|
18
|
+
type?: string;
|
|
19
|
+
}
|
|
20
|
+
declare class CustomAttributionControl implements IControl {
|
|
21
|
+
private options;
|
|
22
|
+
private _map;
|
|
23
|
+
private _compact;
|
|
24
|
+
private _container;
|
|
25
|
+
private _shadowContainer;
|
|
26
|
+
private _innerContainer;
|
|
27
|
+
private _compactButton;
|
|
28
|
+
private _editLink;
|
|
29
|
+
private _attribHTML;
|
|
30
|
+
private styleId;
|
|
31
|
+
private styleOwner;
|
|
32
|
+
private printQuery;
|
|
33
|
+
private onMediaPrintChange;
|
|
34
|
+
constructor(options?: CustomAttributionControlOptions);
|
|
35
|
+
getDefaultPosition(): ControlPosition;
|
|
36
|
+
onAdd(map: Map): HTMLDivElement;
|
|
37
|
+
onRemove(): void;
|
|
38
|
+
_setElementTitle(element: HTMLElement, title: string): void;
|
|
39
|
+
_toggleAttribution(): void;
|
|
40
|
+
_updateData(e: StyleDataEvent): void;
|
|
41
|
+
_updateAttributions(): void;
|
|
42
|
+
_updateCompact(): void;
|
|
43
|
+
_updateCompactMinimize(): void;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
declare class GeoloniaControl implements IControl {
|
|
47
|
+
private container;
|
|
48
|
+
onAdd(): HTMLDivElement;
|
|
49
|
+
onRemove(): void;
|
|
50
|
+
getDefaultPosition(): ControlPosition;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
type GeoloniaMapOptions = MapOptions & {
|
|
54
|
+
/** Geolonia API key */
|
|
55
|
+
apiKey?: string;
|
|
56
|
+
/** API stage (e.g. 'dev', 'v1') */
|
|
57
|
+
stage?: string;
|
|
58
|
+
/** Map style name or URL. Default: 'geolonia/basic-v2' */
|
|
59
|
+
style?: string;
|
|
60
|
+
/** Language for style labels. Default: 'auto' */
|
|
61
|
+
lang?: "ja" | "en" | "auto";
|
|
62
|
+
/** Show default marker at center */
|
|
63
|
+
marker?: boolean;
|
|
64
|
+
/** Marker color (CSS color string) */
|
|
65
|
+
markerColor?: string;
|
|
66
|
+
/** Automatically open marker popup on load */
|
|
67
|
+
openPopup?: boolean;
|
|
68
|
+
/** CSS selector for a custom marker element */
|
|
69
|
+
customMarker?: string;
|
|
70
|
+
/** Offset for custom marker as [x, y] */
|
|
71
|
+
customMarkerOffset?: [number, number];
|
|
72
|
+
/** Show loader animation during map load */
|
|
73
|
+
loader?: boolean;
|
|
74
|
+
/** Enable gesture handling for scroll pages */
|
|
75
|
+
gestureHandling?: boolean;
|
|
76
|
+
/** Navigation control. true, false, or a position string */
|
|
77
|
+
navigationControl?: boolean | ControlPosition;
|
|
78
|
+
/** Geolocate control */
|
|
79
|
+
geolocateControl?: boolean | ControlPosition;
|
|
80
|
+
/** Fullscreen control */
|
|
81
|
+
fullscreenControl?: boolean | ControlPosition;
|
|
82
|
+
/** Scale control */
|
|
83
|
+
scaleControl?: boolean | ControlPosition;
|
|
84
|
+
/** Geolonia logo control */
|
|
85
|
+
geoloniaControl?: boolean | ControlPosition;
|
|
86
|
+
/** GeoJSON URL or object for SimpleStyle */
|
|
87
|
+
geojson?: string | GeoJSON.GeoJSON;
|
|
88
|
+
/** Enable clustering for GeoJSON points */
|
|
89
|
+
cluster?: boolean;
|
|
90
|
+
/** Cluster marker color */
|
|
91
|
+
clusterColor?: string;
|
|
92
|
+
/** Simple vector tile URL */
|
|
93
|
+
simpleVector?: string;
|
|
94
|
+
/** Enable 3D mode */
|
|
95
|
+
"3d"?: boolean;
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
type GetImageCallback = (error?: Error | null, image?: HTMLImageElement | ImageBitmap | null, expiry?: ExpiryData | null) => void;
|
|
99
|
+
declare function isGeoloniaTilesHost(url: string | URL): boolean;
|
|
100
|
+
/**
|
|
101
|
+
* Resolve style name or URL to a full style URL.
|
|
102
|
+
*/
|
|
103
|
+
declare function getStyle(style: string, options: {
|
|
104
|
+
lang?: string;
|
|
105
|
+
apiKey?: string;
|
|
106
|
+
}): string;
|
|
107
|
+
/**
|
|
108
|
+
* Detect browser language.
|
|
109
|
+
*/
|
|
110
|
+
declare function getLang(): "ja" | "en";
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Geolonia Map - extends MapLibre GL Map with Geolonia-specific features.
|
|
114
|
+
* Accepts a GeoloniaMapOptions object directly (no DOM attribute parsing).
|
|
115
|
+
*/
|
|
116
|
+
declare class GeoloniaMap extends maplibregl.Map {
|
|
117
|
+
private geoloniaSourcesUrl;
|
|
118
|
+
private __styleExtensionLoadRequired;
|
|
119
|
+
constructor(options: GeoloniaMapOptions);
|
|
120
|
+
setStyle(style: string | StyleSpecification, options?: StyleSwapOptions & StyleOptions): this;
|
|
121
|
+
remove(): void;
|
|
122
|
+
loadImage(url: string, callback: GetImageCallback): void;
|
|
123
|
+
loadImage(url: string): Promise<GetResourceResponse<HTMLImageElement | ImageBitmap>>;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
declare class GeoloniaMarker extends maplibregl.Marker {
|
|
127
|
+
constructor(options?: MarkerOptions);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
declare class Keyring {
|
|
131
|
+
#private;
|
|
132
|
+
get apiKey(): string;
|
|
133
|
+
get stage(): string;
|
|
134
|
+
get isGeoloniaStyle(): boolean;
|
|
135
|
+
set isGeoloniaStyle(value: boolean);
|
|
136
|
+
setApiKey(key: string): void;
|
|
137
|
+
setStage(stage: string): void;
|
|
138
|
+
reset(): void;
|
|
139
|
+
/**
|
|
140
|
+
* Check if the given style is a Geolonia style (requires API key)
|
|
141
|
+
*/
|
|
142
|
+
isGeoloniaStyleCheck(style: string): boolean;
|
|
143
|
+
}
|
|
144
|
+
declare const keyring: Keyring;
|
|
145
|
+
|
|
146
|
+
declare class SimpleStyle {
|
|
147
|
+
_loadingPromise: Promise<unknown> | undefined;
|
|
148
|
+
private callFitBounds;
|
|
149
|
+
private geojson;
|
|
150
|
+
private map;
|
|
151
|
+
private options;
|
|
152
|
+
private _eventHandlers;
|
|
153
|
+
constructor(geojson: string | GeoJSON.GeoJSON, options?: Record<string, any>);
|
|
154
|
+
updateData(geojson: any): this;
|
|
155
|
+
addTo(map: any): this;
|
|
156
|
+
fitBounds(options?: {}): this;
|
|
157
|
+
/**
|
|
158
|
+
* Set polygon geometries.
|
|
159
|
+
*/
|
|
160
|
+
setPolygonGeometries(): void;
|
|
161
|
+
/**
|
|
162
|
+
* Set line geometries.
|
|
163
|
+
*/
|
|
164
|
+
setLineGeometries(): void;
|
|
165
|
+
/**
|
|
166
|
+
* Setup point geometries.
|
|
167
|
+
*/
|
|
168
|
+
setPointGeometries(): void;
|
|
169
|
+
setPopup(map: any, source: string): Promise<void>;
|
|
170
|
+
/**
|
|
171
|
+
* Setup cluster markers
|
|
172
|
+
*/
|
|
173
|
+
setCluster(): void;
|
|
174
|
+
remove(): this;
|
|
175
|
+
setGeoJSON(geojson: string | GeoJSON.GeoJSON): void;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
declare class SimpleStyleVector {
|
|
179
|
+
private url;
|
|
180
|
+
private sourceName;
|
|
181
|
+
constructor(url: string);
|
|
182
|
+
addTo(map: any): void;
|
|
183
|
+
/**
|
|
184
|
+
* Set polygon geometries.
|
|
185
|
+
*
|
|
186
|
+
* @param map
|
|
187
|
+
*/
|
|
188
|
+
setPolygonGeometries(map: any): void;
|
|
189
|
+
/**
|
|
190
|
+
* Set line geometries.
|
|
191
|
+
*
|
|
192
|
+
* @param map
|
|
193
|
+
*/
|
|
194
|
+
setLineGeometries(map: any): void;
|
|
195
|
+
/**
|
|
196
|
+
* Setup point geometries.
|
|
197
|
+
*
|
|
198
|
+
* @param map
|
|
199
|
+
*/
|
|
200
|
+
setPointGeometries(map: any): void;
|
|
201
|
+
setPopup(map: any, source: string): Promise<void>;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
declare const VERSION = "0.1.0";
|
|
205
|
+
|
|
206
|
+
export { CustomAttributionControl, GeoloniaControl, GeoloniaMap, type GeoloniaMapOptions, GeoloniaMarker, SimpleStyle, SimpleStyleVector, VERSION as coreVersion, getLang, getStyle, isGeoloniaTilesHost, keyring };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import maplibregl, { IControl, ControlPosition, Map, MapOptions, ExpiryData, StyleSpecification, StyleSwapOptions, StyleOptions, GetResourceResponse, MarkerOptions } from 'maplibre-gl';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Custom Attribution Control using Shadow DOM.
|
|
5
|
+
* Based on maplibre-gl-js's AttributionControl.
|
|
6
|
+
* https://github.com/maplibre/maplibre-gl-js/blob/main/src/ui/control/attribution_control.ts
|
|
7
|
+
*
|
|
8
|
+
* Uses Shadow DOM to isolate attribution styles from the host page,
|
|
9
|
+
* preventing style conflicts. Collapses to an "i" icon on small maps.
|
|
10
|
+
*/
|
|
11
|
+
interface CustomAttributionControlOptions {
|
|
12
|
+
compact?: boolean;
|
|
13
|
+
customAttribution?: string | string[];
|
|
14
|
+
}
|
|
15
|
+
interface StyleDataEvent {
|
|
16
|
+
sourceDataType?: string;
|
|
17
|
+
dataType?: string;
|
|
18
|
+
type?: string;
|
|
19
|
+
}
|
|
20
|
+
declare class CustomAttributionControl implements IControl {
|
|
21
|
+
private options;
|
|
22
|
+
private _map;
|
|
23
|
+
private _compact;
|
|
24
|
+
private _container;
|
|
25
|
+
private _shadowContainer;
|
|
26
|
+
private _innerContainer;
|
|
27
|
+
private _compactButton;
|
|
28
|
+
private _editLink;
|
|
29
|
+
private _attribHTML;
|
|
30
|
+
private styleId;
|
|
31
|
+
private styleOwner;
|
|
32
|
+
private printQuery;
|
|
33
|
+
private onMediaPrintChange;
|
|
34
|
+
constructor(options?: CustomAttributionControlOptions);
|
|
35
|
+
getDefaultPosition(): ControlPosition;
|
|
36
|
+
onAdd(map: Map): HTMLDivElement;
|
|
37
|
+
onRemove(): void;
|
|
38
|
+
_setElementTitle(element: HTMLElement, title: string): void;
|
|
39
|
+
_toggleAttribution(): void;
|
|
40
|
+
_updateData(e: StyleDataEvent): void;
|
|
41
|
+
_updateAttributions(): void;
|
|
42
|
+
_updateCompact(): void;
|
|
43
|
+
_updateCompactMinimize(): void;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
declare class GeoloniaControl implements IControl {
|
|
47
|
+
private container;
|
|
48
|
+
onAdd(): HTMLDivElement;
|
|
49
|
+
onRemove(): void;
|
|
50
|
+
getDefaultPosition(): ControlPosition;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
type GeoloniaMapOptions = MapOptions & {
|
|
54
|
+
/** Geolonia API key */
|
|
55
|
+
apiKey?: string;
|
|
56
|
+
/** API stage (e.g. 'dev', 'v1') */
|
|
57
|
+
stage?: string;
|
|
58
|
+
/** Map style name or URL. Default: 'geolonia/basic-v2' */
|
|
59
|
+
style?: string;
|
|
60
|
+
/** Language for style labels. Default: 'auto' */
|
|
61
|
+
lang?: "ja" | "en" | "auto";
|
|
62
|
+
/** Show default marker at center */
|
|
63
|
+
marker?: boolean;
|
|
64
|
+
/** Marker color (CSS color string) */
|
|
65
|
+
markerColor?: string;
|
|
66
|
+
/** Automatically open marker popup on load */
|
|
67
|
+
openPopup?: boolean;
|
|
68
|
+
/** CSS selector for a custom marker element */
|
|
69
|
+
customMarker?: string;
|
|
70
|
+
/** Offset for custom marker as [x, y] */
|
|
71
|
+
customMarkerOffset?: [number, number];
|
|
72
|
+
/** Show loader animation during map load */
|
|
73
|
+
loader?: boolean;
|
|
74
|
+
/** Enable gesture handling for scroll pages */
|
|
75
|
+
gestureHandling?: boolean;
|
|
76
|
+
/** Navigation control. true, false, or a position string */
|
|
77
|
+
navigationControl?: boolean | ControlPosition;
|
|
78
|
+
/** Geolocate control */
|
|
79
|
+
geolocateControl?: boolean | ControlPosition;
|
|
80
|
+
/** Fullscreen control */
|
|
81
|
+
fullscreenControl?: boolean | ControlPosition;
|
|
82
|
+
/** Scale control */
|
|
83
|
+
scaleControl?: boolean | ControlPosition;
|
|
84
|
+
/** Geolonia logo control */
|
|
85
|
+
geoloniaControl?: boolean | ControlPosition;
|
|
86
|
+
/** GeoJSON URL or object for SimpleStyle */
|
|
87
|
+
geojson?: string | GeoJSON.GeoJSON;
|
|
88
|
+
/** Enable clustering for GeoJSON points */
|
|
89
|
+
cluster?: boolean;
|
|
90
|
+
/** Cluster marker color */
|
|
91
|
+
clusterColor?: string;
|
|
92
|
+
/** Simple vector tile URL */
|
|
93
|
+
simpleVector?: string;
|
|
94
|
+
/** Enable 3D mode */
|
|
95
|
+
"3d"?: boolean;
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
type GetImageCallback = (error?: Error | null, image?: HTMLImageElement | ImageBitmap | null, expiry?: ExpiryData | null) => void;
|
|
99
|
+
declare function isGeoloniaTilesHost(url: string | URL): boolean;
|
|
100
|
+
/**
|
|
101
|
+
* Resolve style name or URL to a full style URL.
|
|
102
|
+
*/
|
|
103
|
+
declare function getStyle(style: string, options: {
|
|
104
|
+
lang?: string;
|
|
105
|
+
apiKey?: string;
|
|
106
|
+
}): string;
|
|
107
|
+
/**
|
|
108
|
+
* Detect browser language.
|
|
109
|
+
*/
|
|
110
|
+
declare function getLang(): "ja" | "en";
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Geolonia Map - extends MapLibre GL Map with Geolonia-specific features.
|
|
114
|
+
* Accepts a GeoloniaMapOptions object directly (no DOM attribute parsing).
|
|
115
|
+
*/
|
|
116
|
+
declare class GeoloniaMap extends maplibregl.Map {
|
|
117
|
+
private geoloniaSourcesUrl;
|
|
118
|
+
private __styleExtensionLoadRequired;
|
|
119
|
+
constructor(options: GeoloniaMapOptions);
|
|
120
|
+
setStyle(style: string | StyleSpecification, options?: StyleSwapOptions & StyleOptions): this;
|
|
121
|
+
remove(): void;
|
|
122
|
+
loadImage(url: string, callback: GetImageCallback): void;
|
|
123
|
+
loadImage(url: string): Promise<GetResourceResponse<HTMLImageElement | ImageBitmap>>;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
declare class GeoloniaMarker extends maplibregl.Marker {
|
|
127
|
+
constructor(options?: MarkerOptions);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
declare class Keyring {
|
|
131
|
+
#private;
|
|
132
|
+
get apiKey(): string;
|
|
133
|
+
get stage(): string;
|
|
134
|
+
get isGeoloniaStyle(): boolean;
|
|
135
|
+
set isGeoloniaStyle(value: boolean);
|
|
136
|
+
setApiKey(key: string): void;
|
|
137
|
+
setStage(stage: string): void;
|
|
138
|
+
reset(): void;
|
|
139
|
+
/**
|
|
140
|
+
* Check if the given style is a Geolonia style (requires API key)
|
|
141
|
+
*/
|
|
142
|
+
isGeoloniaStyleCheck(style: string): boolean;
|
|
143
|
+
}
|
|
144
|
+
declare const keyring: Keyring;
|
|
145
|
+
|
|
146
|
+
declare class SimpleStyle {
|
|
147
|
+
_loadingPromise: Promise<unknown> | undefined;
|
|
148
|
+
private callFitBounds;
|
|
149
|
+
private geojson;
|
|
150
|
+
private map;
|
|
151
|
+
private options;
|
|
152
|
+
private _eventHandlers;
|
|
153
|
+
constructor(geojson: string | GeoJSON.GeoJSON, options?: Record<string, any>);
|
|
154
|
+
updateData(geojson: any): this;
|
|
155
|
+
addTo(map: any): this;
|
|
156
|
+
fitBounds(options?: {}): this;
|
|
157
|
+
/**
|
|
158
|
+
* Set polygon geometries.
|
|
159
|
+
*/
|
|
160
|
+
setPolygonGeometries(): void;
|
|
161
|
+
/**
|
|
162
|
+
* Set line geometries.
|
|
163
|
+
*/
|
|
164
|
+
setLineGeometries(): void;
|
|
165
|
+
/**
|
|
166
|
+
* Setup point geometries.
|
|
167
|
+
*/
|
|
168
|
+
setPointGeometries(): void;
|
|
169
|
+
setPopup(map: any, source: string): Promise<void>;
|
|
170
|
+
/**
|
|
171
|
+
* Setup cluster markers
|
|
172
|
+
*/
|
|
173
|
+
setCluster(): void;
|
|
174
|
+
remove(): this;
|
|
175
|
+
setGeoJSON(geojson: string | GeoJSON.GeoJSON): void;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
declare class SimpleStyleVector {
|
|
179
|
+
private url;
|
|
180
|
+
private sourceName;
|
|
181
|
+
constructor(url: string);
|
|
182
|
+
addTo(map: any): void;
|
|
183
|
+
/**
|
|
184
|
+
* Set polygon geometries.
|
|
185
|
+
*
|
|
186
|
+
* @param map
|
|
187
|
+
*/
|
|
188
|
+
setPolygonGeometries(map: any): void;
|
|
189
|
+
/**
|
|
190
|
+
* Set line geometries.
|
|
191
|
+
*
|
|
192
|
+
* @param map
|
|
193
|
+
*/
|
|
194
|
+
setLineGeometries(map: any): void;
|
|
195
|
+
/**
|
|
196
|
+
* Setup point geometries.
|
|
197
|
+
*
|
|
198
|
+
* @param map
|
|
199
|
+
*/
|
|
200
|
+
setPointGeometries(map: any): void;
|
|
201
|
+
setPopup(map: any, source: string): Promise<void>;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
declare const VERSION = "0.1.0";
|
|
205
|
+
|
|
206
|
+
export { CustomAttributionControl, GeoloniaControl, GeoloniaMap, type GeoloniaMapOptions, GeoloniaMarker, SimpleStyle, SimpleStyleVector, VERSION as coreVersion, getLang, getStyle, isGeoloniaTilesHost, keyring };
|