1 | import RBush from 'rbush';
|
2 | import Collection from './Collection';
|
3 | import Control from './control/Control';
|
4 | import { Coordinate } from './coordinate';
|
5 | import { EventsKey } from './events';
|
6 | import BaseEvent from './events/Event';
|
7 | import { Extent } from './extent';
|
8 | import { FeatureLike } from './Feature';
|
9 | import SimpleGeometry from './geom/SimpleGeometry';
|
10 | import Interaction from './interaction/Interaction';
|
11 | import BaseLayer from './layer/Base';
|
12 | import LayerGroup from './layer/Group';
|
13 | import Layer, { State as State_1 } from './layer/Layer';
|
14 | import MapBrowserEvent from './MapBrowserEvent';
|
15 | import MapEvent from './MapEvent';
|
16 | import BaseObject, { ObjectEvent } from './Object';
|
17 | import Overlay from './Overlay';
|
18 | import { Pixel } from './pixel';
|
19 | import RenderEvent from './render/Event';
|
20 | import MapRenderer from './renderer/Map';
|
21 | import { Size } from './size';
|
22 | import Source from './source/Source';
|
23 | import Tile from './Tile';
|
24 | import TileQueue from './TileQueue';
|
25 | import { Transform } from './transform';
|
26 | import View, { State } from './View';
|
27 |
|
28 | export interface AtPixelOptions {
|
29 | layerFilter?: ((p0: Layer<Source>) => boolean) | undefined;
|
30 | hitTolerance?: number | undefined;
|
31 | checkWrapped?: boolean | undefined;
|
32 | }
|
33 | /**
|
34 | * State of the current frame. Only pixelRatio, time and viewState should
|
35 | * be used in applications.
|
36 | */
|
37 | export interface FrameState {
|
38 | pixelRatio: number;
|
39 | time: number;
|
40 | viewState: State;
|
41 | animate: boolean;
|
42 | coordinateToPixelTransform: Transform;
|
43 | declutterTree: RBush<any>;
|
44 | extent: null | Extent;
|
45 | index: number;
|
46 | layerStatesArray: State_1[];
|
47 | layerIndex: number;
|
48 | pixelToCoordinateTransform: Transform;
|
49 | postRenderFunctions: PostRenderFunction[];
|
50 | size: Size;
|
51 | tileQueue: TileQueue;
|
52 | usedTiles: { [key: string]: { [key: string]: boolean } };
|
53 | viewHints: number[];
|
54 | wantedTiles: { [key: string]: { [key: string]: boolean } };
|
55 | }
|
56 | /**
|
57 | * Object literal with config options for the map.
|
58 | */
|
59 | export interface MapOptions {
|
60 | controls?: Collection<Control> | Control[] | undefined;
|
61 | pixelRatio?: number | undefined;
|
62 | interactions?: Collection<Interaction> | Interaction[] | undefined;
|
63 | keyboardEventTarget?: HTMLElement | Document | string | undefined;
|
64 | layers?: BaseLayer[] | Collection<BaseLayer> | LayerGroup | undefined;
|
65 | maxTilesLoading?: number | undefined;
|
66 | moveTolerance?: number | undefined;
|
67 | overlays?: Collection<Overlay> | Overlay[] | undefined;
|
68 | target?: HTMLElement | string | undefined;
|
69 | view?: View | undefined;
|
70 | }
|
71 | export interface MapOptionsInternal {
|
72 | controls?: Collection<Control> | undefined;
|
73 | interactions?: Collection<Interaction> | undefined;
|
74 | keyboardEventTarget: HTMLElement | Document;
|
75 | overlays: Collection<Overlay>;
|
76 | values: { [key: string]: any };
|
77 | }
|
78 | export type PostRenderFunction = (p0: PluggableMap, p1: FrameState) => any;
|
79 | export default class PluggableMap extends BaseObject {
|
80 | constructor(options: MapOptions);
|
81 | protected controls: Collection<Control>;
|
82 | protected interactions: Collection<Interaction>;
|
83 | protected handlePostRender(): void;
|
84 | /**
|
85 | * Add the given control to the map.
|
86 | */
|
87 | addControl(control: Control): void;
|
88 | /**
|
89 | * Add the given interaction to the map. If you want to add an interaction
|
90 | * at another point of the collection use getInteraction() and the methods
|
91 | * available on {@link module:ol/Collection~Collection}. This can be used to
|
92 | * stop the event propagation from the handleEvent function. The interactions
|
93 | * get to handle the events in the reverse order of this collection.
|
94 | */
|
95 | addInteraction(interaction: Interaction): void;
|
96 | /**
|
97 | * Adds the given layer to the top of this map. If you want to add a layer
|
98 | * elsewhere in the stack, use getLayers() and the methods available on
|
99 | * {@link module:ol/Collection~Collection}.
|
100 | */
|
101 | addLayer(layer: BaseLayer): void;
|
102 | /**
|
103 | * Add the given overlay to the map.
|
104 | */
|
105 | addOverlay(overlay: Overlay): void;
|
106 | createRenderer(): MapRenderer;
|
107 | /**
|
108 | * Clean up.
|
109 | */
|
110 | disposeInternal(): void;
|
111 | /**
|
112 | * Detect features that intersect a pixel on the viewport, and execute a
|
113 | * callback with each intersecting feature. Layers included in the detection can
|
114 | * be configured through the layerFilter option in opt_options.
|
115 | */
|
116 | forEachFeatureAtPixel<S, T>(
|
117 | pixel: Pixel,
|
118 | callback: (p0: FeatureLike, p1: Layer<Source>, p2: SimpleGeometry) => T,
|
119 | opt_options?: AtPixelOptions,
|
120 | ): T | undefined;
|
121 | /**
|
122 | * Detect layers that have a color value at a pixel on the viewport, and
|
123 | * execute a callback with each matching layer. Layers included in the
|
124 | * detection can be configured through opt_layerFilter.
|
125 | * Note: this may give false positives unless the map layers have had different className
|
126 | * properties assigned to them.
|
127 | */
|
128 | forEachLayerAtPixel<S, T>(
|
129 | pixel: Pixel,
|
130 | callback: (this: S, p0: Layer<Source>, p1: Uint8ClampedArray | Uint8Array) => T,
|
131 | opt_options?: AtPixelOptions,
|
132 | ): T | undefined;
|
133 | /**
|
134 | * Get the map controls. Modifying this collection changes the controls
|
135 | * associated with the map.
|
136 | */
|
137 | getControls(): Collection<Control>;
|
138 | /**
|
139 | * Get the coordinate for a given pixel. This returns a coordinate in the
|
140 | * user projection.
|
141 | */
|
142 | getCoordinateFromPixel(pixel: Pixel): Coordinate;
|
143 | /**
|
144 | * Get the coordinate for a given pixel. This returns a coordinate in the
|
145 | * map view projection.
|
146 | */
|
147 | getCoordinateFromPixelInternal(pixel: Pixel): Coordinate;
|
148 | /**
|
149 | * Returns the coordinate in user projection for a browser event.
|
150 | */
|
151 | getEventCoordinate(event: MouseEvent): Coordinate;
|
152 | /**
|
153 | * Returns the coordinate in view projection for a browser event.
|
154 | */
|
155 | getEventCoordinateInternal(event: MouseEvent): Coordinate;
|
156 | /**
|
157 | * Returns the map pixel position for a browser event relative to the viewport.
|
158 | */
|
159 | getEventPixel(event: UIEvent): Pixel;
|
160 | /**
|
161 | * Get all features that intersect a pixel on the viewport.
|
162 | */
|
163 | getFeaturesAtPixel(pixel: Pixel, opt_options?: AtPixelOptions): FeatureLike[];
|
164 | /**
|
165 | * Get the map interactions. Modifying this collection changes the interactions
|
166 | * associated with the map.
|
167 | * Interactions are used for e.g. pan, zoom and rotate.
|
168 | */
|
169 | getInteractions(): Collection<Interaction>;
|
170 | /**
|
171 | * Get the layergroup associated with this map.
|
172 | */
|
173 | getLayerGroup(): LayerGroup;
|
174 | /**
|
175 | * Get the collection of layers associated with this map.
|
176 | */
|
177 | getLayers(): Collection<BaseLayer>;
|
178 | getLoading(): boolean;
|
179 | /**
|
180 | * Get an overlay by its identifier (the value returned by overlay.getId()).
|
181 | * Note that the index treats string and numeric identifiers as the same. So
|
182 | * map.getOverlayById(2) will return an overlay with id '2' or 2.
|
183 | */
|
184 | getOverlayById(id: string | number): Overlay;
|
185 | /**
|
186 | * Get the element that serves as the container for overlays. Elements added to
|
187 | * this container will let mousedown and touchstart events through to the map,
|
188 | * so clicks and gestures on an overlay will trigger {@link module:ol/MapBrowserEvent~MapBrowserEvent}
|
189 | * events.
|
190 | */
|
191 | getOverlayContainer(): HTMLElement;
|
192 | /**
|
193 | * Get the element that serves as a container for overlays that don't allow
|
194 | * event propagation. Elements added to this container won't let mousedown and
|
195 | * touchstart events through to the map, so clicks and gestures on an overlay
|
196 | * don't trigger any {@link module:ol/MapBrowserEvent~MapBrowserEvent}.
|
197 | */
|
198 | getOverlayContainerStopEvent(): HTMLElement;
|
199 | /**
|
200 | * Get the map overlays. Modifying this collection changes the overlays
|
201 | * associated with the map.
|
202 | */
|
203 | getOverlays(): Collection<Overlay>;
|
204 | getOwnerDocument(): Document;
|
205 | /**
|
206 | * Get the pixel for a coordinate. This takes a coordinate in the user
|
207 | * projection and returns the corresponding pixel.
|
208 | */
|
209 | getPixelFromCoordinate(coordinate: Coordinate): Pixel;
|
210 | /**
|
211 | * Get the pixel for a coordinate. This takes a coordinate in the map view
|
212 | * projection and returns the corresponding pixel.
|
213 | */
|
214 | getPixelFromCoordinateInternal(coordinate: Coordinate): Pixel;
|
215 | /**
|
216 | * Get the map renderer.
|
217 | */
|
218 | getRenderer(): MapRenderer;
|
219 | /**
|
220 | * Get the size of this map.
|
221 | */
|
222 | getSize(): Size | undefined;
|
223 | /**
|
224 | * Get the target in which this map is rendered.
|
225 | * Note that this returns what is entered as an option or in setTarget:
|
226 | * if that was an element, it returns an element; if a string, it returns that.
|
227 | */
|
228 | getTarget(): HTMLElement | string | undefined;
|
229 | /**
|
230 | * Get the DOM element into which this map is rendered. In contrast to
|
231 | * getTarget this method always return an Element, or null if the
|
232 | * map has no target.
|
233 | */
|
234 | getTargetElement(): HTMLElement;
|
235 | getTilePriority(tile: Tile, tileSourceKey: string, tileCenter: Coordinate, tileResolution: number): number;
|
236 | /**
|
237 | * Get the view associated with this map. A view manages properties such as
|
238 | * center and resolution.
|
239 | */
|
240 | getView(): View;
|
241 | /**
|
242 | * Get the element that serves as the map viewport.
|
243 | */
|
244 | getViewport(): HTMLElement;
|
245 | handleBrowserEvent(browserEvent: UIEvent, opt_type?: string): void;
|
246 | handleMapBrowserEvent(mapBrowserEvent: MapBrowserEvent<UIEvent>): void;
|
247 | /**
|
248 | * Detect if features intersect a pixel on the viewport. Layers included in the
|
249 | * detection can be configured through opt_layerFilter.
|
250 | */
|
251 | hasFeatureAtPixel(pixel: Pixel, opt_options?: AtPixelOptions): boolean;
|
252 | isRendered(): boolean;
|
253 | /**
|
254 | * Redraws all text after new fonts have loaded
|
255 | */
|
256 | redrawText(): void;
|
257 | /**
|
258 | * Remove the given control from the map.
|
259 | */
|
260 | removeControl(control: Control): Control | undefined;
|
261 | /**
|
262 | * Remove the given interaction from the map.
|
263 | */
|
264 | removeInteraction(interaction: Interaction): Interaction | undefined;
|
265 | /**
|
266 | * Removes the given layer from the map.
|
267 | */
|
268 | removeLayer(layer: BaseLayer): BaseLayer | undefined;
|
269 | /**
|
270 | * Remove the given overlay from the map.
|
271 | */
|
272 | removeOverlay(overlay: Overlay): Overlay | undefined;
|
273 | /**
|
274 | * Request a map rendering (at the next animation frame).
|
275 | */
|
276 | render(): void;
|
277 | /**
|
278 | * Requests an immediate render in a synchronous manner.
|
279 | */
|
280 | renderSync(): void;
|
281 | /**
|
282 | * Sets the layergroup of this map.
|
283 | */
|
284 | setLayerGroup(layerGroup: LayerGroup): void;
|
285 | /**
|
286 | * Set the size of this map.
|
287 | */
|
288 | setSize(size: Size | undefined): void;
|
289 | /**
|
290 | * Set the target element to render this map into.
|
291 | */
|
292 | setTarget(target: HTMLElement | string | undefined): void;
|
293 | /**
|
294 | * Set the view for this map.
|
295 | */
|
296 | setView(view: View): void;
|
297 | /**
|
298 | * Force a recalculation of the map viewport size. This should be called when
|
299 | * third-party code changes the size of the map viewport.
|
300 | */
|
301 | updateSize(): void;
|
302 | on(type: string | string[], listener: (p0: any) => any): EventsKey | EventsKey[];
|
303 | once(type: string | string[], listener: (p0: any) => any): EventsKey | EventsKey[];
|
304 | un(type: string | string[], listener: (p0: any) => any): void;
|
305 | on(type: 'change', listener: (evt: BaseEvent) => void): EventsKey;
|
306 | once(type: 'change', listener: (evt: BaseEvent) => void): EventsKey;
|
307 | un(type: 'change', listener: (evt: BaseEvent) => void): void;
|
308 | on(type: 'change:layerGroup', listener: (evt: ObjectEvent) => void): EventsKey;
|
309 | once(type: 'change:layerGroup', listener: (evt: ObjectEvent) => void): EventsKey;
|
310 | un(type: 'change:layerGroup', listener: (evt: ObjectEvent) => void): void;
|
311 | on(type: 'change:size', listener: (evt: ObjectEvent) => void): EventsKey;
|
312 | once(type: 'change:size', listener: (evt: ObjectEvent) => void): EventsKey;
|
313 | un(type: 'change:size', listener: (evt: ObjectEvent) => void): void;
|
314 | on(type: 'change:target', listener: (evt: ObjectEvent) => void): EventsKey;
|
315 | once(type: 'change:target', listener: (evt: ObjectEvent) => void): EventsKey;
|
316 | un(type: 'change:target', listener: (evt: ObjectEvent) => void): void;
|
317 | on(type: 'change:view', listener: (evt: ObjectEvent) => void): EventsKey;
|
318 | once(type: 'change:view', listener: (evt: ObjectEvent) => void): EventsKey;
|
319 | un(type: 'change:view', listener: (evt: ObjectEvent) => void): void;
|
320 | on(type: 'click', listener: (evt: MapBrowserEvent<UIEvent>) => void): EventsKey;
|
321 | once(type: 'click', listener: (evt: MapBrowserEvent<UIEvent>) => void): EventsKey;
|
322 | un(type: 'click', listener: (evt: MapBrowserEvent<UIEvent>) => void): void;
|
323 | on(type: 'dblclick', listener: (evt: MapBrowserEvent<UIEvent>) => void): EventsKey;
|
324 | once(type: 'dblclick', listener: (evt: MapBrowserEvent<UIEvent>) => void): EventsKey;
|
325 | un(type: 'dblclick', listener: (evt: MapBrowserEvent<UIEvent>) => void): void;
|
326 | on(type: 'error', listener: (evt: BaseEvent) => void): EventsKey;
|
327 | once(type: 'error', listener: (evt: BaseEvent) => void): EventsKey;
|
328 | un(type: 'error', listener: (evt: BaseEvent) => void): void;
|
329 | on(type: 'moveend', listener: (evt: MapEvent) => void): EventsKey;
|
330 | once(type: 'moveend', listener: (evt: MapEvent) => void): EventsKey;
|
331 | un(type: 'moveend', listener: (evt: MapEvent) => void): void;
|
332 | on(type: 'movestart', listener: (evt: MapEvent) => void): EventsKey;
|
333 | once(type: 'movestart', listener: (evt: MapEvent) => void): EventsKey;
|
334 | un(type: 'movestart', listener: (evt: MapEvent) => void): void;
|
335 | on(type: 'pointerdrag', listener: (evt: MapBrowserEvent<UIEvent>) => void): EventsKey;
|
336 | once(type: 'pointerdrag', listener: (evt: MapBrowserEvent<UIEvent>) => void): EventsKey;
|
337 | un(type: 'pointerdrag', listener: (evt: MapBrowserEvent<UIEvent>) => void): void;
|
338 | on(type: 'pointermove', listener: (evt: MapBrowserEvent<UIEvent>) => void): EventsKey;
|
339 | once(type: 'pointermove', listener: (evt: MapBrowserEvent<UIEvent>) => void): EventsKey;
|
340 | un(type: 'pointermove', listener: (evt: MapBrowserEvent<UIEvent>) => void): void;
|
341 | on(type: 'postcompose', listener: (evt: RenderEvent) => void): EventsKey;
|
342 | once(type: 'postcompose', listener: (evt: RenderEvent) => void): EventsKey;
|
343 | un(type: 'postcompose', listener: (evt: RenderEvent) => void): void;
|
344 | on(type: 'postrender', listener: (evt: MapEvent) => void): EventsKey;
|
345 | once(type: 'postrender', listener: (evt: MapEvent) => void): EventsKey;
|
346 | un(type: 'postrender', listener: (evt: MapEvent) => void): void;
|
347 | on(type: 'precompose', listener: (evt: RenderEvent) => void): EventsKey;
|
348 | once(type: 'precompose', listener: (evt: RenderEvent) => void): EventsKey;
|
349 | un(type: 'precompose', listener: (evt: RenderEvent) => void): void;
|
350 | on(type: 'propertychange', listener: (evt: ObjectEvent) => void): EventsKey;
|
351 | once(type: 'propertychange', listener: (evt: ObjectEvent) => void): EventsKey;
|
352 | un(type: 'propertychange', listener: (evt: ObjectEvent) => void): void;
|
353 | on(type: 'rendercomplete', listener: (evt: RenderEvent) => void): EventsKey;
|
354 | once(type: 'rendercomplete', listener: (evt: RenderEvent) => void): EventsKey;
|
355 | un(type: 'rendercomplete', listener: (evt: RenderEvent) => void): void;
|
356 | on(type: 'singleclick', listener: (evt: MapBrowserEvent<UIEvent>) => void): EventsKey;
|
357 | once(type: 'singleclick', listener: (evt: MapBrowserEvent<UIEvent>) => void): EventsKey;
|
358 | un(type: 'singleclick', listener: (evt: MapBrowserEvent<UIEvent>) => void): void;
|
359 | }
|