@powerportalspro/react-maps 0.0.0-stage → 13.0.0
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/EULA.txt +263 -0
- package/README.md +37 -2
- package/dist/chunk-7HDK44TQ.js +366 -0
- package/dist/chunk-7HDK44TQ.js.map +1 -0
- package/dist/chunk-G723VLPV.js +238 -0
- package/dist/chunk-G723VLPV.js.map +1 -0
- package/dist/google-6EZOUTYI.js +293 -0
- package/dist/google-6EZOUTYI.js.map +1 -0
- package/dist/index.cjs +4990 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +689 -0
- package/dist/index.d.ts +689 -0
- package/dist/index.js +3603 -0
- package/dist/index.js.map +1 -0
- package/dist/maplibre-J3XSEXEJ.js +424 -0
- package/dist/maplibre-J3XSEXEJ.js.map +1 -0
- package/package.json +68 -3
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,689 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ReactNode, CSSProperties, RefAttributes, ReactElement } from 'react';
|
|
3
|
+
import { GridMapPrint } from '@powerportalspro/react-fluent';
|
|
4
|
+
import { TableRecord, ResolvedColumn, MultiTablePlace, QueryFilter } from '@powerportalspro/core';
|
|
5
|
+
|
|
6
|
+
interface MapsProviderProps {
|
|
7
|
+
children?: ReactNode;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Gives the controls of `@powerportalspro/react-fluent` that show a map this package's maps: the
|
|
11
|
+
* pin of `<AddressDisplayValue showMap>`, which opens the address on a map in a dialog, a grid's
|
|
12
|
+
* `GridLayout.Map`, and a grid's Near button (`allowNearSearch`). Put it once
|
|
13
|
+
* around the app, inside `<PowerPortalsProProvider>` and the theme provider, as the dialog and
|
|
14
|
+
* overlay providers are.
|
|
15
|
+
*
|
|
16
|
+
* ```tsx
|
|
17
|
+
* <PowerPortalsProProvider>
|
|
18
|
+
* <FluentDialogProvider>
|
|
19
|
+
* <MapsProvider>
|
|
20
|
+
* <RouterProvider router={router} />
|
|
21
|
+
* </MapsProvider>
|
|
22
|
+
* </FluentDialogProvider>
|
|
23
|
+
* </PowerPortalsProProvider>
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
declare function MapsProvider({ children }: MapsProviderProps): react_jsx_runtime.JSX.Element;
|
|
27
|
+
|
|
28
|
+
/** A place on the map, in WGS84 degrees. */
|
|
29
|
+
interface MapPosition {
|
|
30
|
+
latitude: number;
|
|
31
|
+
longitude: number;
|
|
32
|
+
}
|
|
33
|
+
/** A rectangle on the map, in WGS84 degrees. `west` is greater than `east` across the antimeridian. */
|
|
34
|
+
interface MapBounds {
|
|
35
|
+
north: number;
|
|
36
|
+
south: number;
|
|
37
|
+
east: number;
|
|
38
|
+
west: number;
|
|
39
|
+
}
|
|
40
|
+
/** A point in the map's element, in CSS pixels from its top left corner. */
|
|
41
|
+
interface MapPoint {
|
|
42
|
+
x: number;
|
|
43
|
+
y: number;
|
|
44
|
+
}
|
|
45
|
+
/** Where the map looks: its center and zoom level (0 shows the whole world; about 15 a street). */
|
|
46
|
+
interface MapCamera {
|
|
47
|
+
center: MapPosition;
|
|
48
|
+
zoom: number;
|
|
49
|
+
}
|
|
50
|
+
/** What the map shows now: its camera and the area in view. */
|
|
51
|
+
interface MapView extends MapCamera {
|
|
52
|
+
bounds: MapBounds;
|
|
53
|
+
}
|
|
54
|
+
/** The kind of base map: streets, aerial imagery, or imagery with streets and labels over it. */
|
|
55
|
+
type MapStyle = 'road' | 'satellite' | 'hybrid';
|
|
56
|
+
interface MapItemBase<TData> {
|
|
57
|
+
/** Unique among the map's items. What a click on the item reports. */
|
|
58
|
+
id: string;
|
|
59
|
+
/** The item's name: its tooltip, what a screen reader announces, and the default popup's heading. */
|
|
60
|
+
title?: string;
|
|
61
|
+
/**
|
|
62
|
+
* Its color, as any CSS color — a Fluent token such as `var(--colorPaletteRedBackground3)`
|
|
63
|
+
* included. The portal's accent color when unset.
|
|
64
|
+
*/
|
|
65
|
+
color?: string;
|
|
66
|
+
/** Anything of the host's, handed back with the item in click events and the popup. */
|
|
67
|
+
data?: TData;
|
|
68
|
+
/** Where the default popup's heading links to: the item's own page. */
|
|
69
|
+
url?: string;
|
|
70
|
+
}
|
|
71
|
+
/** A pin at a position. Pins close together are gathered into a cluster unless clustering is off. */
|
|
72
|
+
interface MapMarker<TData = unknown> extends MapItemBase<TData> {
|
|
73
|
+
kind: 'marker';
|
|
74
|
+
position: MapPosition;
|
|
75
|
+
/**
|
|
76
|
+
* A few characters drawn on the pin in place of its dot — a number, say, matching the pin to a
|
|
77
|
+
* list beside the map. Up to four fit comfortably; longer ones are drawn smaller.
|
|
78
|
+
*/
|
|
79
|
+
label?: string;
|
|
80
|
+
}
|
|
81
|
+
/** A record listed under the map when it is printed. */
|
|
82
|
+
interface MapPrintEntry {
|
|
83
|
+
/** Its pin's label, beside it in the list. */
|
|
84
|
+
label?: string;
|
|
85
|
+
title: string;
|
|
86
|
+
/** Its columns, each a name and the value shown. */
|
|
87
|
+
details?: readonly {
|
|
88
|
+
label: string;
|
|
89
|
+
value: string;
|
|
90
|
+
}[];
|
|
91
|
+
/** The badge's color, as its pin's. The portal's accent color when unset. */
|
|
92
|
+
color?: string;
|
|
93
|
+
}
|
|
94
|
+
/** A line through positions: a route or a boundary. */
|
|
95
|
+
interface MapPolyline<TData = unknown> extends MapItemBase<TData> {
|
|
96
|
+
kind: 'polyline';
|
|
97
|
+
path: readonly MapPosition[];
|
|
98
|
+
/** Line width in pixels. Default 3. */
|
|
99
|
+
width?: number;
|
|
100
|
+
}
|
|
101
|
+
/** An area inside positions, closed from the last back to the first. */
|
|
102
|
+
interface MapPolygon<TData = unknown> extends MapItemBase<TData> {
|
|
103
|
+
kind: 'polygon';
|
|
104
|
+
path: readonly MapPosition[];
|
|
105
|
+
}
|
|
106
|
+
/** A circle on the ground: a radius around a center, in meters. */
|
|
107
|
+
interface MapCircle<TData = unknown> extends MapItemBase<TData> {
|
|
108
|
+
kind: 'circle';
|
|
109
|
+
center: MapPosition;
|
|
110
|
+
/** In meters. */
|
|
111
|
+
radius: number;
|
|
112
|
+
}
|
|
113
|
+
/** Something drawn on the map. */
|
|
114
|
+
type MapItem<TData = unknown> = MapMarker<TData> | MapPolyline<TData> | MapPolygon<TData> | MapCircle<TData>;
|
|
115
|
+
/** An item the provider draws itself: everything but a marker, which the map draws on every provider. */
|
|
116
|
+
type MapShape = MapPolyline | MapPolygon | MapCircle;
|
|
117
|
+
/** A click on the map, away from its items. */
|
|
118
|
+
interface MapClickEvent {
|
|
119
|
+
position: MapPosition;
|
|
120
|
+
}
|
|
121
|
+
/** A click on an item, or Enter on a focused marker. */
|
|
122
|
+
interface MapItemClickEvent {
|
|
123
|
+
id: string;
|
|
124
|
+
/** Where it was clicked: a marker's own position, or the point clicked on a shape. */
|
|
125
|
+
position: MapPosition;
|
|
126
|
+
}
|
|
127
|
+
/** A place an address search found. */
|
|
128
|
+
interface MapPlace {
|
|
129
|
+
/** The place as the provider writes it: its address, or its name and where it is. */
|
|
130
|
+
label: string;
|
|
131
|
+
position: MapPosition;
|
|
132
|
+
/** The area it covers — a city's, a street's — which the map fits into view. Unset for a point. */
|
|
133
|
+
bounds?: MapBounds;
|
|
134
|
+
}
|
|
135
|
+
/** A place suggested for the text typed into the address search, found once it is chosen. */
|
|
136
|
+
interface MapAddressSuggestion {
|
|
137
|
+
/** Unique among the suggestions of one search. */
|
|
138
|
+
id: string;
|
|
139
|
+
/** Its main text: a street address, or a place's name. */
|
|
140
|
+
text: string;
|
|
141
|
+
/** What tells it from others like it: its city, region and country. */
|
|
142
|
+
detail?: string;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/** An Entra access token for Azure Maps, issued to the portal's identity, with the account it is for. */
|
|
146
|
+
interface AzureMapsAccessToken {
|
|
147
|
+
accessToken: string;
|
|
148
|
+
/** The Azure Maps account's client id. */
|
|
149
|
+
clientId: string;
|
|
150
|
+
/** When the token stops working, as an ISO 8601 date and time. */
|
|
151
|
+
expiresOn: string;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Azure Maps, drawn with MapLibre from Azure Maps' tiles, signed in with Entra tokens the portal
|
|
155
|
+
* issues to its own identity, so no Azure Maps key reaches the browser. The portal names the account
|
|
156
|
+
* in its `PowerPortalsPro:Maps:AzureMaps:ClientId` setting, and its identity needs the Azure Maps
|
|
157
|
+
* Data Reader role on it.
|
|
158
|
+
*/
|
|
159
|
+
interface AzureMapsSettings {
|
|
160
|
+
name: 'azureMaps';
|
|
161
|
+
/**
|
|
162
|
+
* The country or region whose view of disputed borders to show, such as `US` or `IN`. The
|
|
163
|
+
* portal's, or Azure Maps' `Auto`, which picks by the viewer's IP address, when unset.
|
|
164
|
+
*/
|
|
165
|
+
view?: string;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Esri's basemaps, from the ArcGIS Basemap Styles service, drawn with MapLibre. The key is the
|
|
169
|
+
* portal's, in its `PowerPortalsPro:Maps:Esri:ApiKey` setting.
|
|
170
|
+
*/
|
|
171
|
+
interface EsriSettings {
|
|
172
|
+
name: 'esri';
|
|
173
|
+
/** The road style, such as `arcgis/navigation`. The portal's, or `arcgis/streets`, when unset. */
|
|
174
|
+
styleName?: string;
|
|
175
|
+
/** The road style in a dark theme. The portal's, or `arcgis/dark-gray`, when unset. */
|
|
176
|
+
darkStyleName?: string;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Google's own map, through the Maps JavaScript API. The key is the portal's, in its
|
|
180
|
+
* `PowerPortalsPro:Maps:Google:ApiKey` setting.
|
|
181
|
+
*/
|
|
182
|
+
interface GoogleSettings {
|
|
183
|
+
name: 'google';
|
|
184
|
+
/**
|
|
185
|
+
* A map id from the Google Cloud console, for a map styled there. The portal's, or Google's own
|
|
186
|
+
* styling, when unset.
|
|
187
|
+
*/
|
|
188
|
+
mapId?: string;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* OpenStreetMap's tiles: no key, for development and light use. OpenStreetMap's tile usage policy
|
|
192
|
+
* rules out heavy use; a production portal points `tileUrl` at a provider of its own — in its
|
|
193
|
+
* `PowerPortalsPro:Maps:OpenStreetMap` settings when the URL carries a key — or uses the `mapLibre`
|
|
194
|
+
* provider with one's style.
|
|
195
|
+
*/
|
|
196
|
+
interface OpenStreetMapSettings {
|
|
197
|
+
name: 'openStreetMap';
|
|
198
|
+
/** An XYZ tile URL with `{z}`, `{x}` and `{y}`. Default OpenStreetMap's own. */
|
|
199
|
+
tileUrl?: string;
|
|
200
|
+
/** Attribution for `tileUrl`'s tiles, as HTML. */
|
|
201
|
+
attribution?: string;
|
|
202
|
+
/**
|
|
203
|
+
* A Nominatim server for the address search. Default OpenStreetMap's own, whose usage policy
|
|
204
|
+
* allows light use: a search only once Enter is pressed, never as the viewer types.
|
|
205
|
+
*/
|
|
206
|
+
geocoderUrl?: string;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Any map MapLibre can draw: a style URL (MapTiler, OpenFreeMap, Stadia, one of your own) or an
|
|
210
|
+
* XYZ raster tile URL. Each is the portal's, from its `PowerPortalsPro:Maps:MapLibre` settings, when
|
|
211
|
+
* the page leaves it unset — the place for a URL that carries a key.
|
|
212
|
+
*/
|
|
213
|
+
interface MapLibreSettings {
|
|
214
|
+
name: 'mapLibre';
|
|
215
|
+
/** A MapLibre style JSON URL. */
|
|
216
|
+
styleUrl?: string;
|
|
217
|
+
/** The style in a dark theme. `styleUrl` when unset. */
|
|
218
|
+
darkStyleUrl?: string;
|
|
219
|
+
/** The style for `satellite`. `styleUrl` when unset. */
|
|
220
|
+
satelliteStyleUrl?: string;
|
|
221
|
+
/** The style for `hybrid`. `satelliteStyleUrl` when unset. */
|
|
222
|
+
hybridStyleUrl?: string;
|
|
223
|
+
/** An XYZ raster tile URL, used when there is no `styleUrl`. */
|
|
224
|
+
tileUrl?: string;
|
|
225
|
+
/** Attribution for `tileUrl`'s tiles, as HTML. */
|
|
226
|
+
attribution?: string;
|
|
227
|
+
/** The highest zoom `tileUrl` has tiles for. Default 19. */
|
|
228
|
+
maxZoom?: number;
|
|
229
|
+
/** A Nominatim server for the address search. Default OpenStreetMap's own, as `openStreetMap`'s. */
|
|
230
|
+
geocoderUrl?: string;
|
|
231
|
+
}
|
|
232
|
+
/** A provider registered by the host with `registerMapProvider`, with its own settings. */
|
|
233
|
+
interface CustomMapProviderSettings {
|
|
234
|
+
name: string;
|
|
235
|
+
[setting: string]: unknown;
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Which provider draws the map, and how it looks. Its keys are the portal's: the settings a page
|
|
239
|
+
* leaves unset come from the portal's `PowerPortalsPro:Maps` configuration too.
|
|
240
|
+
*/
|
|
241
|
+
type MapProviderSettings = AzureMapsSettings | EsriSettings | GoogleSettings | OpenStreetMapSettings | MapLibreSettings | CustomMapProviderSettings;
|
|
242
|
+
/** What the portal adds to a provider's settings: its keys, which a page never holds. */
|
|
243
|
+
interface MapProviderKeys {
|
|
244
|
+
/** Esri's or Google's API key. */
|
|
245
|
+
apiKey?: string;
|
|
246
|
+
/** A current Azure Maps token, asked of the portal again shortly before the last one expires. */
|
|
247
|
+
getToken?: () => Promise<AzureMapsAccessToken>;
|
|
248
|
+
}
|
|
249
|
+
/** What the map tells a provider's surface to report. */
|
|
250
|
+
interface MapSurfaceEvents {
|
|
251
|
+
/** A click on the map that hit none of the shapes. */
|
|
252
|
+
click(position: MapPosition, point: MapPoint): void;
|
|
253
|
+
/** A click on a shape, by its id. */
|
|
254
|
+
shapeClick(id: string, position: MapPosition, point: MapPoint): void;
|
|
255
|
+
/** The view is changing — each frame of a pan or zoom. */
|
|
256
|
+
viewChanging(): void;
|
|
257
|
+
/** The view has stopped changing. */
|
|
258
|
+
viewChanged(): void;
|
|
259
|
+
/**
|
|
260
|
+
* The surface drew its elements again without the view changing — Google redraws its overlays
|
|
261
|
+
* whenever it likes. What sits on the map is placed again; the map isn't moving, so nothing waits
|
|
262
|
+
* for it to stop.
|
|
263
|
+
*/
|
|
264
|
+
redrawn(): void;
|
|
265
|
+
/** Something failed that the surface can't recover from, such as a key that was refused. */
|
|
266
|
+
error(message: string): void;
|
|
267
|
+
}
|
|
268
|
+
/** What an address search asks a geocoder. */
|
|
269
|
+
interface MapAddressQuery {
|
|
270
|
+
text: string;
|
|
271
|
+
/** Where the map is looking: places in and near it come first. */
|
|
272
|
+
view: MapView;
|
|
273
|
+
/** ISO 3166-1 two-letter country codes the places are limited to; anywhere when empty. */
|
|
274
|
+
countries: readonly string[];
|
|
275
|
+
/** The viewer's language, as a culture name such as `en-US`. */
|
|
276
|
+
language: string;
|
|
277
|
+
signal?: AbortSignal;
|
|
278
|
+
}
|
|
279
|
+
/** Finds places by their address or name, with a provider's own search. */
|
|
280
|
+
interface MapGeocoder {
|
|
281
|
+
/**
|
|
282
|
+
* Whether it suggests places as the viewer types. One that doesn't is asked only when they press
|
|
283
|
+
* Enter, as OpenStreetMap's Nominatim asks of the users of its free service.
|
|
284
|
+
*/
|
|
285
|
+
readonly suggestsAsYouType: boolean;
|
|
286
|
+
/** Places for the text, best first. */
|
|
287
|
+
suggest(query: MapAddressQuery): Promise<MapAddressSuggestion[]>;
|
|
288
|
+
/** Where one of its own suggestions is; null when the provider can no longer find it. */
|
|
289
|
+
resolve(suggestion: MapAddressSuggestion, signal?: AbortSignal): Promise<MapPlace | null>;
|
|
290
|
+
}
|
|
291
|
+
/** An element the surface keeps at a position on the map as it moves. */
|
|
292
|
+
interface MapOverlay {
|
|
293
|
+
setPosition(position: MapPosition): void;
|
|
294
|
+
remove(): void;
|
|
295
|
+
}
|
|
296
|
+
/** What a provider is given to draw a map. */
|
|
297
|
+
interface MapSurfaceContext<TSettings extends MapProviderSettings = MapProviderSettings> {
|
|
298
|
+
/** The element to draw into. Empty, positioned, and sized by the map. */
|
|
299
|
+
container: HTMLElement;
|
|
300
|
+
/** The page's settings over the portal's, with the portal's keys. */
|
|
301
|
+
settings: TSettings & MapProviderKeys;
|
|
302
|
+
style: MapStyle;
|
|
303
|
+
/** Whether the portal's theme is dark, for a provider with a dark map. */
|
|
304
|
+
dark: boolean;
|
|
305
|
+
/** The viewer's language, as a culture name such as `en-US`. */
|
|
306
|
+
language: string;
|
|
307
|
+
camera: MapCamera;
|
|
308
|
+
/** Passed to the provider's own map as they are, over the map's: the way to its other features. */
|
|
309
|
+
nativeOptions?: Record<string, unknown>;
|
|
310
|
+
/**
|
|
311
|
+
* What a provider that needs a modifier key to zoom with the wheel — so a page scrolls past its
|
|
312
|
+
* map — shows when someone scrolls without it. Google shows its own.
|
|
313
|
+
*/
|
|
314
|
+
gestureHelp?: MapGestureHelp;
|
|
315
|
+
events: MapSurfaceEvents;
|
|
316
|
+
}
|
|
317
|
+
/** The map's hints for zooming and panning a map that doesn't take the page's scrolling, in the viewer's language. */
|
|
318
|
+
interface MapGestureHelp {
|
|
319
|
+
/** Scrolling with the wheel alone, on Windows and Linux: "Use Ctrl + scroll to zoom the map". */
|
|
320
|
+
windows: string;
|
|
321
|
+
/** The same on a Mac, with ⌘. */
|
|
322
|
+
mac: string;
|
|
323
|
+
/** A one-finger drag on a touch screen: "Use two fingers to move the map". */
|
|
324
|
+
mobile: string;
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* A provider's map: what the shared map control needs of it. Markers, clusters and the popup are
|
|
328
|
+
* the control's, drawn the same way on every provider; a surface only places elements, draws
|
|
329
|
+
* shapes, and reports clicks and moves.
|
|
330
|
+
*/
|
|
331
|
+
interface MapSurface {
|
|
332
|
+
/** The provider's own map object — a MapLibre `Map`, a `google.maps.Map` — for what the control doesn't cover. */
|
|
333
|
+
readonly native: unknown;
|
|
334
|
+
/** The provider's address search, for the map's search box; without one the box isn't shown. */
|
|
335
|
+
readonly geocoder?: MapGeocoder | null;
|
|
336
|
+
getView(): MapView;
|
|
337
|
+
setCamera(camera: MapCamera, animate: boolean): void;
|
|
338
|
+
fitBounds(bounds: MapBounds, padding: number, maxZoom: number): void;
|
|
339
|
+
panBy(x: number, y: number): void;
|
|
340
|
+
/** Where a position is in the container, in CSS pixels. */
|
|
341
|
+
project(position: MapPosition): MapPoint;
|
|
342
|
+
/** Keeps `element` at `position`, its bottom center there for `bottom`, its center for `center`. */
|
|
343
|
+
addOverlay(element: HTMLElement, position: MapPosition, anchor: 'bottom' | 'center'): MapOverlay;
|
|
344
|
+
/** Replaces the shapes drawn. Their colors are resolved, never a CSS variable. */
|
|
345
|
+
setShapes(shapes: readonly MapShape[]): void;
|
|
346
|
+
/**
|
|
347
|
+
* Changes the base map. Returns false when this provider can't without drawing the map again,
|
|
348
|
+
* which the control then does.
|
|
349
|
+
*/
|
|
350
|
+
setStyle(style: MapStyle, dark: boolean): boolean;
|
|
351
|
+
/**
|
|
352
|
+
* Changes the hints for zooming and panning, which arrive after the map is drawn when its strings
|
|
353
|
+
* load late. A provider that shows none of its own leaves it out.
|
|
354
|
+
*/
|
|
355
|
+
setGestureHelp?(help: MapGestureHelp): void;
|
|
356
|
+
resize(): void;
|
|
357
|
+
/**
|
|
358
|
+
* A copy of the map as it is drawn, once every tile in view has loaded, at `pixelRatio` device
|
|
359
|
+
* pixels to a CSS pixel: what the map's image and printout are made from. A provider whose map
|
|
360
|
+
* can't be copied — Google's — leaves it out, and the map is printed as it is on the page.
|
|
361
|
+
*/
|
|
362
|
+
capture?(pixelRatio: number): Promise<HTMLCanvasElement>;
|
|
363
|
+
/** The provider's attribution, as text: written on the map's image. */
|
|
364
|
+
attributionText?(): string;
|
|
365
|
+
dispose(): void;
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
368
|
+
* A map provider. Built-in ones are found by name; a host adds its own with `registerMapProvider`
|
|
369
|
+
* and names it in the map's provider settings.
|
|
370
|
+
*/
|
|
371
|
+
interface MapProvider<TSettings extends MapProviderSettings = MapProviderSettings> {
|
|
372
|
+
readonly name: string;
|
|
373
|
+
create(context: MapSurfaceContext<TSettings>): Promise<MapSurface>;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
/**
|
|
377
|
+
* Adds a map provider, or replaces one of the same name — a built-in one included. A map whose
|
|
378
|
+
* provider settings name it draws with it.
|
|
379
|
+
*/
|
|
380
|
+
declare function registerMapProvider<TSettings extends MapProviderSettings>(provider: MapProvider<TSettings>): void;
|
|
381
|
+
/** The names of the built-in providers. */
|
|
382
|
+
declare const BUILT_IN_MAP_PROVIDERS: readonly string[];
|
|
383
|
+
|
|
384
|
+
/** A unit distances are measured in, as the server numbers them: miles, or kilometers. */
|
|
385
|
+
declare const DistanceUnits: {
|
|
386
|
+
readonly Miles: 0;
|
|
387
|
+
readonly Kilometers: 1;
|
|
388
|
+
};
|
|
389
|
+
type DistanceUnit = (typeof DistanceUnits)[keyof typeof DistanceUnits];
|
|
390
|
+
/** The distances a search near a place offers, unless its page gives others. */
|
|
391
|
+
declare const DEFAULT_NEAR_DISTANCES: readonly number[];
|
|
392
|
+
/** The distance a search near a place starts at, unless its page gives another. */
|
|
393
|
+
declare const DEFAULT_NEAR_DISTANCE = 25;
|
|
394
|
+
/** Where a search near a place is, and how far from it records may be. */
|
|
395
|
+
interface NearPlace {
|
|
396
|
+
/** The place as it was found: an address, or the visitor's location. */
|
|
397
|
+
label: string;
|
|
398
|
+
latitude: number;
|
|
399
|
+
longitude: number;
|
|
400
|
+
distance: number;
|
|
401
|
+
unit: DistanceUnit;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
/**
|
|
405
|
+
* Where MapLibre's worker script is served from. MapLibre 6 loads it as a file of its own, and a
|
|
406
|
+
* bundled app has to say where its bundler put it — once, before a map is drawn:
|
|
407
|
+
*
|
|
408
|
+
* ```ts
|
|
409
|
+
* // Vite
|
|
410
|
+
* import workerUrl from 'maplibre-gl/dist/maplibre-gl-worker.mjs?worker&url';
|
|
411
|
+
* setMapLibreWorkerUrl(workerUrl);
|
|
412
|
+
*
|
|
413
|
+
* // webpack 5, rspack, Next.js
|
|
414
|
+
* setMapLibreWorkerUrl(new URL('maplibre-gl/dist/maplibre-gl-worker.mjs', import.meta.url).toString());
|
|
415
|
+
* ```
|
|
416
|
+
*
|
|
417
|
+
* Calling MapLibre's own `setWorkerUrl` does the same. A function in place of the URL is called
|
|
418
|
+
* when a MapLibre map is first drawn, so code that finds it — loading the worker's script, say —
|
|
419
|
+
* runs only on a page that shows one.
|
|
420
|
+
*/
|
|
421
|
+
declare function setMapLibreWorkerUrl(url: string | (() => string | Promise<string>)): void;
|
|
422
|
+
|
|
423
|
+
/** Dataverse's own latitude and longitude columns on accounts, contacts and other address tables. */
|
|
424
|
+
declare const DEFAULT_LATITUDE_COLUMN = "address1_latitude";
|
|
425
|
+
declare const DEFAULT_LONGITUDE_COLUMN = "address1_longitude";
|
|
426
|
+
/** The most rows a map reads unless told otherwise. */
|
|
427
|
+
declare const DEFAULT_MAX_ROWS = 1000;
|
|
428
|
+
/** What the map draws for a Dataverse row: a marker, with the row and its view's columns. */
|
|
429
|
+
interface MapRecord {
|
|
430
|
+
record: TableRecord;
|
|
431
|
+
/** The view's columns, for a popup showing the row. */
|
|
432
|
+
columns: readonly ResolvedColumn[];
|
|
433
|
+
/** For a row of a table registered for maps: where it is, and what its popup shows. */
|
|
434
|
+
place?: MultiTablePlace;
|
|
435
|
+
}
|
|
436
|
+
/** A marker drawn for a row, carrying it as its data. */
|
|
437
|
+
type MapRecordMarker = MapMarker<MapRecord>;
|
|
438
|
+
|
|
439
|
+
/** An item clicked on the map, with where it was clicked. */
|
|
440
|
+
interface MapItemClick<TData> {
|
|
441
|
+
item: MapItem<TData>;
|
|
442
|
+
position: MapPosition;
|
|
443
|
+
/** Keeps the map from opening the item's popup: for a page that does something else with the click. */
|
|
444
|
+
preventDefault(): void;
|
|
445
|
+
/** Whether `preventDefault` was called. */
|
|
446
|
+
readonly defaultPrevented: boolean;
|
|
447
|
+
}
|
|
448
|
+
/** A map as a Print button of the page's own works it (`onPrintChange`): a grid's map's, the same. */
|
|
449
|
+
type MapPrint = GridMapPrint;
|
|
450
|
+
/** What a map can be told to do through its ref. */
|
|
451
|
+
interface MapHandle {
|
|
452
|
+
/** Moves the view, animated unless `animate` is false. */
|
|
453
|
+
setCamera(camera: MapCamera, animate?: boolean): void;
|
|
454
|
+
/** Moves the view to show every item — or, given `ids`, the items of those ids. */
|
|
455
|
+
fitToItems(ids?: readonly string[]): void;
|
|
456
|
+
/** Opens the popup of the item of that id. */
|
|
457
|
+
openPopup(id: string): void;
|
|
458
|
+
closePopup(): void;
|
|
459
|
+
/**
|
|
460
|
+
* Finds `text` with the provider's address search and goes there: the first place found, pinned.
|
|
461
|
+
* Null when nothing is found, or the provider has no search.
|
|
462
|
+
*/
|
|
463
|
+
goToAddress(text: string): Promise<MapPlace | null>;
|
|
464
|
+
/** Empties the address search and takes the place it found off the map. */
|
|
465
|
+
clearAddress(): void;
|
|
466
|
+
/** What the map shows now; null before it has drawn. */
|
|
467
|
+
getView(): MapView | null;
|
|
468
|
+
/**
|
|
469
|
+
* Prints the map, with `printTitle` above it, its legend, and `printEntries` listed under it — as
|
|
470
|
+
* the print button does.
|
|
471
|
+
*/
|
|
472
|
+
print(): Promise<void>;
|
|
473
|
+
/**
|
|
474
|
+
* Saves the map as a PNG image of that name, with its legend. False when the provider's map can't
|
|
475
|
+
* be copied (Google's), or before the map has drawn.
|
|
476
|
+
*/
|
|
477
|
+
saveImage(fileName?: string): Promise<boolean>;
|
|
478
|
+
/** The provider's own map object — a MapLibre `Map`, a `google.maps.Map` — or null before it has drawn. */
|
|
479
|
+
readonly native: unknown;
|
|
480
|
+
}
|
|
481
|
+
interface MapProps<TData = unknown> {
|
|
482
|
+
/**
|
|
483
|
+
* Which provider draws the map, and how it looks — the portal's own provider, from its
|
|
484
|
+
* `PowerPortalsPro:Maps:Provider` setting, when unset. Keys are only ever the portal's: it fills in
|
|
485
|
+
* each provider's from its `PowerPortalsPro:Maps` settings, with any the page leaves unset.
|
|
486
|
+
*/
|
|
487
|
+
provider?: MapProviderSettings;
|
|
488
|
+
/** Markers, lines, areas and circles of the page's own, drawn with any rows read. */
|
|
489
|
+
items?: readonly MapItem<TData>[];
|
|
490
|
+
/** A view whose rows to plot, each at its latitude and longitude. */
|
|
491
|
+
viewId?: string;
|
|
492
|
+
/** A FetchXML query whose rows to plot, instead of a view. */
|
|
493
|
+
fetchXml?: string;
|
|
494
|
+
/** Narrows the rows read — to those related to the page's record, say. */
|
|
495
|
+
filters?: readonly QueryFilter[];
|
|
496
|
+
/** The rows' latitude column. Default `address1_latitude`. */
|
|
497
|
+
latitudeColumn?: string;
|
|
498
|
+
/** The rows' longitude column. Default `address1_longitude`. */
|
|
499
|
+
longitudeColumn?: string;
|
|
500
|
+
/** The column that names each row's marker. The table's primary name column by default. */
|
|
501
|
+
titleColumn?: string;
|
|
502
|
+
/**
|
|
503
|
+
* The rows' markers' color, as any CSS color: one for every row, or each row's own. The portal's
|
|
504
|
+
* accent color by default.
|
|
505
|
+
*/
|
|
506
|
+
recordColor?: string | ((record: TableRecord) => string | undefined);
|
|
507
|
+
/**
|
|
508
|
+
* A choice, status, status reason or yes/no column whose options color the rows' markers — each
|
|
509
|
+
* the color Dataverse gives it, or one of Fluent's palette — with a legend of the options shown.
|
|
510
|
+
*/
|
|
511
|
+
colorColumn?: string;
|
|
512
|
+
/** Shows the legend of `colorColumn`'s options. Default `true`. */
|
|
513
|
+
showLegend?: boolean;
|
|
514
|
+
/**
|
|
515
|
+
* Each row's page, which its popup's heading links to, in place of its record's page registered
|
|
516
|
+
* with `AddRecordPage`: a URL with `{0}` in place of the row's id and `{1}` its table's, or the URL
|
|
517
|
+
* a function makes of the row.
|
|
518
|
+
*/
|
|
519
|
+
recordUrl?: string | ((record: TableRecord) => string | undefined);
|
|
520
|
+
/**
|
|
521
|
+
* Whether a row's popup heading links to its record's page, registered with `AddRecordPage`, when
|
|
522
|
+
* no `recordUrl` is given. Default `true`; a table with no page shows no link.
|
|
523
|
+
*/
|
|
524
|
+
showRecordLinks?: boolean;
|
|
525
|
+
/** Follows a popup's link in place of the browser — `(url) => navigate(url)` for react-router. */
|
|
526
|
+
onNavigate?: (url: string) => void;
|
|
527
|
+
/** A box over the map's corner for finding an address with the provider's own search. Default `false`. */
|
|
528
|
+
showAddressSearch?: boolean;
|
|
529
|
+
/** ISO 3166-1 two-letter codes of the countries the address search finds places in. Anywhere when unset. */
|
|
530
|
+
addressSearchCountries?: readonly string[];
|
|
531
|
+
/**
|
|
532
|
+
* An address to show, such as `"1 Microsoft Way, Redmond, WA 98052"`: found with the provider's
|
|
533
|
+
* own search once the map is drawn, and again whenever it changes, then pinned and brought into
|
|
534
|
+
* view. A spinner shows while it is looked for, and a message when it isn't found.
|
|
535
|
+
*/
|
|
536
|
+
address?: string;
|
|
537
|
+
/**
|
|
538
|
+
* Keeps the view on chosen items: fitted to the items of these ids — or to every item when it is
|
|
539
|
+
* empty — each time it changes, and when items it was fitted to are gone (a new page of them).
|
|
540
|
+
* Items only added, or restyled, leave the view where the user moved it. Unset, the view is fitted
|
|
541
|
+
* to the items only as they first arrive.
|
|
542
|
+
*/
|
|
543
|
+
fitItemIds?: readonly string[];
|
|
544
|
+
/**
|
|
545
|
+
* Puts the rows of the tables registered for maps (`ForMaps`) on the map, beside its own rows and
|
|
546
|
+
* items: every one, or a view of some, each table's pins in its registration's color, with a toolbar
|
|
547
|
+
* above the map to choose the view and the tables shown. Default `false`.
|
|
548
|
+
*/
|
|
549
|
+
multiTable?: boolean;
|
|
550
|
+
/** Only these of the tables registered for maps, by logical name. Every one the user may read when unset. */
|
|
551
|
+
tables?: readonly string[];
|
|
552
|
+
/** The tables shown at first in the view of every table; the others start switched off. Every one when unset. */
|
|
553
|
+
defaultTables?: readonly string[];
|
|
554
|
+
/** The view shown at first: one registered for maps, or one of the user's. */
|
|
555
|
+
defaultViewId?: string;
|
|
556
|
+
/**
|
|
557
|
+
* Only these views, in this order: views registered for maps (`AddMultiTableView` with `ForMaps`),
|
|
558
|
+
* by id. The view of every table is offered only when this is unset; a signed-in user's own views
|
|
559
|
+
* follow either way. Unset, the view of every table, then every view registered for maps.
|
|
560
|
+
*/
|
|
561
|
+
viewIds?: readonly string[];
|
|
562
|
+
/** Only the rows about this record, through each table's regarding column. */
|
|
563
|
+
regarding?: {
|
|
564
|
+
tableName: string;
|
|
565
|
+
id: string;
|
|
566
|
+
};
|
|
567
|
+
/** Offers the view's filters to change in the Filter menu, a tab for each table shown. Default `false`. */
|
|
568
|
+
allowFiltering?: boolean;
|
|
569
|
+
/**
|
|
570
|
+
* Lets signed-in users save the tables shown, with their filters, as views of their own, and choose
|
|
571
|
+
* their default view and hide the views they don't use. Default `false`.
|
|
572
|
+
*/
|
|
573
|
+
allowSavedViews?: boolean;
|
|
574
|
+
/** Names this map among the maps, so the views saved on it are its own. Shared with every map without one when unset. */
|
|
575
|
+
savedViewsKey?: string;
|
|
576
|
+
/** Where a visitor who isn't signed in is sent to sign in, from the saved views' menu. Default `Account/Login`. */
|
|
577
|
+
signInUrl?: string;
|
|
578
|
+
/** The toolbar's heading when there is only one view to show. None when unset. */
|
|
579
|
+
title?: string;
|
|
580
|
+
/**
|
|
581
|
+
* A Near button on the toolbar of a map of several tables: only the rows within a distance of a
|
|
582
|
+
* place — an address found with the provider's search, or the visitor's location — nearest first,
|
|
583
|
+
* the circle drawn and the map fitted to it, each popup saying how far its row is. Default `false`.
|
|
584
|
+
*/
|
|
585
|
+
allowNearSearch?: boolean;
|
|
586
|
+
/** The distances the Near button offers. Default 1, 5, 10, 25, 50 and 100. */
|
|
587
|
+
nearDistances?: readonly number[];
|
|
588
|
+
/** The distance the Near button starts at. Default 25. */
|
|
589
|
+
nearDistance?: number;
|
|
590
|
+
/** The unit the Near button starts in: `DistanceUnits.Miles` (default) or `DistanceUnits.Kilometers`. */
|
|
591
|
+
nearDistanceUnit?: DistanceUnit;
|
|
592
|
+
/** The most rows read. Default 1000, at most 5000; a note on the map says when there are more. */
|
|
593
|
+
maxRows?: number;
|
|
594
|
+
/** Streets, aerial imagery, or both. Default `road`. */
|
|
595
|
+
mapStyle?: MapStyle;
|
|
596
|
+
/** Where the map looks first. Fitted to its items when unset. */
|
|
597
|
+
center?: MapPosition;
|
|
598
|
+
/** The zoom it starts at, with `center`: 0 is the whole world, about 15 a street. Default 12. */
|
|
599
|
+
zoom?: number;
|
|
600
|
+
/** Gather markers close together into clusters, which zoom in when clicked. Default `true`. */
|
|
601
|
+
cluster?: boolean;
|
|
602
|
+
/**
|
|
603
|
+
* A Print button — on the toolbar with `multiTable`, else over the map's top right corner — for
|
|
604
|
+
* printing the map and, where the provider's map can be copied, saving it as an image. A map is
|
|
605
|
+
* printed as an image with its pins, legend and the provider's attribution, or, for Google, as it
|
|
606
|
+
* is on the page. Default `false`.
|
|
607
|
+
*/
|
|
608
|
+
showPrintButton?: boolean;
|
|
609
|
+
/** The heading printed above the map. `title` when unset. */
|
|
610
|
+
printTitle?: string;
|
|
611
|
+
/**
|
|
612
|
+
* Records listed under the map when it is printed, each beside its pin's label — or a function
|
|
613
|
+
* that makes them as it is printed, for a long list, which then costs nothing until someone prints.
|
|
614
|
+
*/
|
|
615
|
+
printEntries?: readonly MapPrintEntry[] | (() => readonly MapPrintEntry[]);
|
|
616
|
+
/**
|
|
617
|
+
* Called as the map can be printed, or no longer — before it has drawn, once it has failed, as it
|
|
618
|
+
* goes — for a Print button of the page's own, in a toolbar around the map, say.
|
|
619
|
+
*/
|
|
620
|
+
onPrintChange?: (print: MapPrint | null) => void;
|
|
621
|
+
/** Draw the dark map, where the provider has one, when the portal's theme is dark. Default `true`. */
|
|
622
|
+
usePortalTheme?: boolean;
|
|
623
|
+
/**
|
|
624
|
+
* Open a popup on the item clicked: `renderPopup`'s content, a row's view columns, or an item's
|
|
625
|
+
* title. Default `true`. `onItemClick` is called either way.
|
|
626
|
+
*/
|
|
627
|
+
showPopups?: boolean;
|
|
628
|
+
/** The popup's content for an item, in place of the default. Return null for no popup. */
|
|
629
|
+
renderPopup?: (item: MapItem<TData | MapRecord>) => ReactNode;
|
|
630
|
+
/** Options for the provider's own map, over the map's: the way to its other features. */
|
|
631
|
+
nativeOptions?: Record<string, unknown>;
|
|
632
|
+
/** CSS height of the map. Default `400px`. */
|
|
633
|
+
height?: string | number;
|
|
634
|
+
/** CSS width of the map. Default `100%`. */
|
|
635
|
+
width?: string | number;
|
|
636
|
+
className?: string;
|
|
637
|
+
style?: CSSProperties;
|
|
638
|
+
/** A click on the map, away from its items. */
|
|
639
|
+
onMapClick?: (event: MapClickEvent) => void;
|
|
640
|
+
/**
|
|
641
|
+
* A click on an item — a row's marker, a line, an area or a circle. The map opens the item's popup
|
|
642
|
+
* after it, unless `event.preventDefault()` was called.
|
|
643
|
+
*/
|
|
644
|
+
onItemClick?: (event: MapItemClick<TData | MapRecord>) => void;
|
|
645
|
+
/** The address search went to a place, or, with null, was cleared. */
|
|
646
|
+
onAddressSelected?: (place: MapPlace | null) => void;
|
|
647
|
+
/** The view has settled after a move. */
|
|
648
|
+
onViewChanged?: (view: MapView) => void;
|
|
649
|
+
/** The map couldn't be drawn, or its rows read. */
|
|
650
|
+
onError?: (message: string) => void;
|
|
651
|
+
}
|
|
652
|
+
/**
|
|
653
|
+
* A map of Dataverse rows and items of the page's own, drawn by Azure Maps, Esri, Google,
|
|
654
|
+
* OpenStreetMap or any MapLibre style — the portal's own provider unless `provider` names another,
|
|
655
|
+
* each with the keys in the portal's `PowerPortalsPro:Maps` settings. Rows come from a view or
|
|
656
|
+
* FetchXML, each at its latitude and longitude, read with the user's permissions as a grid's are,
|
|
657
|
+
* and colored by a column's options with `colorColumn`. Clicking an item calls `onItemClick`, then
|
|
658
|
+
* opens a popup — its row's columns by default, or what `renderPopup` returns — unless the page
|
|
659
|
+
* prevented it. `showAddressSearch` adds a box for finding an address with the provider's search.
|
|
660
|
+
*/
|
|
661
|
+
declare const Map: <TData = unknown>(props: MapProps<TData> & RefAttributes<MapHandle>) => ReactElement | null;
|
|
662
|
+
|
|
663
|
+
/** What a search near a place shows and changes. */
|
|
664
|
+
interface NearSearchProps {
|
|
665
|
+
/** The place searched near, and how far from it; null when the search isn't near anywhere. */
|
|
666
|
+
value: NearPlace | null;
|
|
667
|
+
/** A place was chosen, the distance or unit changed, or the search was cleared (null). */
|
|
668
|
+
onChange: (value: NearPlace | null) => void;
|
|
669
|
+
/** The distances offered. Default 1, 5, 10, 25, 50 and 100. */
|
|
670
|
+
distances?: readonly number[] | undefined;
|
|
671
|
+
/** The distance offered first, before one is chosen. Default 25, or the first offered when 25 isn't. */
|
|
672
|
+
defaultDistance?: number | undefined;
|
|
673
|
+
/** The unit offered first, before one is chosen. Default miles. */
|
|
674
|
+
defaultUnit?: DistanceUnit | undefined;
|
|
675
|
+
/** Whose address search finds the place: the portal's own map provider unless set. */
|
|
676
|
+
provider?: MapProviderSettings | undefined;
|
|
677
|
+
/** ISO 3166-1 two-letter country codes the places found are limited to; anywhere when unset. */
|
|
678
|
+
countries?: readonly string[] | undefined;
|
|
679
|
+
className?: string | undefined;
|
|
680
|
+
}
|
|
681
|
+
/**
|
|
682
|
+
* Finds the records near a place: a toolbar button that opens the place's search — an address, with
|
|
683
|
+
* the map provider's own search, or the visitor's location — and how far from it, in miles or
|
|
684
|
+
* kilometers. Shown by a multi-table `<Map allowNearSearch>` and a grid's `allowNearSearch` (through
|
|
685
|
+
* `<MapsProvider>`). The twin of Blazor's `NearSearch`.
|
|
686
|
+
*/
|
|
687
|
+
declare function NearSearch({ value, onChange, distances, defaultDistance, defaultUnit, provider, countries, className }: NearSearchProps): react_jsx_runtime.JSX.Element;
|
|
688
|
+
|
|
689
|
+
export { type AzureMapsAccessToken, type AzureMapsSettings, BUILT_IN_MAP_PROVIDERS, type CustomMapProviderSettings, DEFAULT_LATITUDE_COLUMN, DEFAULT_LONGITUDE_COLUMN, DEFAULT_MAX_ROWS, DEFAULT_NEAR_DISTANCE, DEFAULT_NEAR_DISTANCES, type DistanceUnit, DistanceUnits, type EsriSettings, type GoogleSettings, Map, type MapAddressQuery, type MapAddressSuggestion, type MapBounds, type MapCamera, type MapCircle, type MapClickEvent, type MapGeocoder, type MapGestureHelp, type MapHandle, type MapItem, type MapItemClick, type MapItemClickEvent, type MapLibreSettings, type MapMarker, type MapOverlay, type MapPlace, type MapPoint, type MapPolygon, type MapPolyline, type MapPosition, type MapPrint, type MapProps, type MapProvider, type MapProviderKeys, type MapProviderSettings, type MapRecord, type MapRecordMarker, type MapShape, type MapStyle, type MapSurface, type MapSurfaceContext, type MapSurfaceEvents, type MapView, MapsProvider, type MapsProviderProps, type NearPlace, NearSearch, type NearSearchProps, type OpenStreetMapSettings, registerMapProvider, setMapLibreWorkerUrl };
|