maplair 4.2.0 → 4.3.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/CHANGELOG.md +17 -0
- package/dist/esm/core/Events.js +1 -0
- package/dist/esm/core/Events.js.map +1 -1
- package/dist/esm/layer/vector/Circle.js +1 -0
- package/dist/esm/layer/vector/Circle.js.map +1 -1
- package/dist/esm/package.js +1 -1
- package/dist/maplair-global-src.js +4 -2
- package/dist/maplair-global-src.js.map +1 -1
- package/dist/maplair-global.js +2 -2
- package/dist/maplair-global.js.map +1 -1
- package/dist/maplair-src.js +4 -2
- package/dist/maplair-src.js.map +1 -1
- package/dist/maplair.js +2 -2
- package/dist/maplair.js.map +1 -1
- package/package.json +2 -1
- package/src/core/Events.js +2 -0
- package/src/layer/vector/Circle.js +3 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,23 @@ Maplair Changelog
|
|
|
3
3
|
|
|
4
4
|
(all changes of Leaflet without author notice are by [@mourner](https://github.com/mourner))
|
|
5
5
|
|
|
6
|
+
## 4.3.0 (2026-11-02)
|
|
7
|
+
|
|
8
|
+
### Leaflet, since 4.2.0
|
|
9
|
+
|
|
10
|
+
Ported from Leaflet (changes without author notice are by [@mourner](https://github.com/mourner))
|
|
11
|
+
|
|
12
|
+
#### ❇️ New Features
|
|
13
|
+
|
|
14
|
+
* Aliases for an easier migration from Leaflet 1: propagated events carry the target as `layer` (the 1.x name of `propagatedFrom`), `new Circle(latlng, radius)` throws pointing to the `radius` option, `maplair/dist/maplair.css` is exported in https://github.com/Leaflet/Leaflet/commit/6c769f974dd9cbc2319763c87aa2293ec739454a
|
|
15
|
+
|
|
16
|
+
#### 📝 Docs
|
|
17
|
+
|
|
18
|
+
* Polish the tutorials: example frames filling the page width, a complete page and a bundler setup in the quick start, the class tutorial, outdated links and names, a hosted image in the overlays tutorial in https://github.com/Leaflet/Leaflet/commit/6d1f3f9b1f3c3d5586d737d3aaadea0c0ef95e5c, https://github.com/Leaflet/Leaflet/commit/44bc6cddf272aa7c29f5918c0fafdb2b8fe75a4e and https://github.com/Leaflet/Leaflet/commit/92e0bb50e4751536d2b6e022ff81a0976feecc9a
|
|
19
|
+
* Update the tile providers, tools and links in the FAQ in https://github.com/Leaflet/Leaflet/commit/a904a6d02f19d87aaea5a29288f83a65200291fd and https://github.com/Leaflet/Leaflet/commit/c7c073f62cbce65ec364557b44148accad1670f5
|
|
20
|
+
* Update the links and the publishing advice in the plugin guide in https://github.com/Leaflet/Leaflet/commit/381883ce944e6085caef5573954336ce9e3917b1
|
|
21
|
+
* Add location-picker to the plugins list by [@cyphercodes](https://github.com/cyphercodes) in https://github.com/Leaflet/Leaflet/pull/10514
|
|
22
|
+
|
|
6
23
|
## 4.2.0 (2026-10-31)
|
|
7
24
|
|
|
8
25
|
⚠️ Despite the minor version, this release contains breaking changes ported from Leaflet, see the refactorings below; e.g. the optional module `maplair/marker-rotation` is replaced by the Marker option `rotation`.
|
package/dist/esm/core/Events.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Events.js","names":["Util.splitWords","Util.falseFn","Util.stamp"],"sources":["../../../src/core/Events.js"],"sourcesContent":["import {Class} from './Class.js';\nimport * as Util from './Util.js';\n\nconst warnedEvents = new Set();\n/** @import {LatLng} from '../geo/LatLng.js' */\n/** @import {LatLngBounds} from '../geo/LatLngBounds.js' */\n/** @import {Point} from '../geometry/Point.js' */\n/** @import {CRS} from '../geo/crs/CRS.js' */\n/** @import {Layer} from '../layer/Layer.js' */\n/** @import {Popup} from '../layer/Popup.js' */\n/** @import {Tooltip} from '../layer/Tooltip.js' */\n\n/**\n * The base event object, the argument of event listeners. All other event objects\n * contain these properties too. Whenever a class inheriting from `Evented` fires an\n * event, a listener function is called with an event object containing information\n * about the event, which depends on the event type. For example:\n *\n * ```js\n * map.on('click', function(ev) {\n * alert(ev.latlng); // ev is an event object (MaplairPointerEvent in this case)\n * });\n * ```\n *\n * @typedef {object} MaplairEvent\n * @property {string} type The event type (e.g. `'click'`).\n * @property {any} target The object that fired the event. For propagated events, the\n * last object in the propagation chain that fired the event.\n * @property {any} sourceTarget The object that originally fired the event. For\n * non-propagated events, this will be the same as the `target`.\n * @property {any} [propagatedFrom] For propagated events, the last object that\n * propagated the event to its event parent.\n */\n\n/**\n * A listener of events, called with the event object, which has more properties\n * depending on the event type (see the event objects below).\n * @typedef {(event: MaplairEvent & Record<string, any>) => void} EventListener\n */\n\n/**\n * The event object of keyboard events.\n * @typedef {object} MaplairKeyboardEvent\n * @property {KeyboardEvent} originalEvent The original\n * [DOM `KeyboardEvent`](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent)\n * that triggered this Maplair event.\n * @extends MaplairEvent\n */\n\n/**\n * The event object of pointer events (`click`, `pointermove`, …).\n * @typedef {object} MaplairPointerEvent\n * @property {LatLng} latlng The geographical point where the pointer event occurred.\n * @property {Point} layerPoint Pixel coordinates of the point where the pointer event\n * occurred relative to the map layer.\n * @property {Point} containerPoint Pixel coordinates of the point where the pointer\n * event occurred relative to the map container.\n * @property {MouseEvent|PointerEvent} originalEvent The original\n * [DOM `MouseEvent`](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent) or\n * [DOM `PointerEvent`](https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent)\n * that triggered this Maplair event.\n * @extends MaplairEvent\n */\n\n/**\n * The event object of `locationfound`.\n * @typedef {object} LocationEvent\n * @property {LatLng} latlng Detected geographical location of the user.\n * @property {LatLngBounds} bounds Geographical bounds of the area user is located in\n * (with respect to the accuracy of location).\n * @property {number} accuracy Accuracy of location in meters.\n * @property {number} altitude Height of the position above the WGS84 ellipsoid in meters.\n * @property {number} altitudeAccuracy Accuracy of altitude in meters.\n * @property {number} heading The direction of travel in degrees counting clockwise from true North.\n * @property {number} speed Current velocity in meters per second.\n * @property {number} timestamp The time when the position was acquired.\n * @extends MaplairEvent\n */\n\n/**\n * The event object of errors, e.g. `locationerror`.\n * @typedef {object} MaplairErrorEvent\n * @property {string} message Error message.\n * @property {number} [code] Error code (if applicable).\n * @extends MaplairEvent\n */\n\n/**\n * The event object of adding and removing layers.\n * @typedef {object} LayerEvent\n * @property {Layer} layer The layer that was added or removed.\n * @extends MaplairEvent\n */\n\n/**\n * The event object of the layers control.\n * @typedef {object} LayersControlEvent\n * @property {Layer} layer The layer that was added or removed.\n * @property {string} name The name of the layer that was added or removed.\n * @property {Event} [originalEvent] The DOM event of the click on the entry in the\n * layers control, `undefined` if the layer was added or removed by code.\n * @extends MaplairEvent\n */\n\n/**\n * The event object of tile events.\n * @typedef {object} TileEvent\n * @property {HTMLElement} tile The tile element (image).\n * @property {Point} coords Point object with the tile's `x`, `y`, and `z` (zoom level) coordinates.\n * @extends MaplairEvent\n */\n\n/**\n * The event object of `tileerror`.\n * @typedef {object} TileErrorEvent\n * @property {any} error Error passed to the tile's `done()` callback.\n * @extends TileEvent\n */\n\n/**\n * The event object of `resize`.\n * @typedef {object} ResizeEvent\n * @property {Point} oldSize The old size before resize event.\n * @property {Point} newSize The new size after the resize event.\n * @extends MaplairEvent\n */\n\n/**\n * The event object of `crschange`.\n * @typedef {object} CrsChangeEvent\n * @property {CRS} oldCrs The CRS of the map before the change.\n * @property {CRS} crs The new CRS of the map.\n * @extends MaplairEvent\n */\n\n/**\n * The event object of `worldcopyjump`.\n * @typedef {object} WorldCopyJumpEvent\n * @property {number} worlds The signed number of world widths by which the map pane moved.\n * @extends MaplairEvent\n */\n\n/**\n * The event object of adding GeoJSON features.\n * @typedef {object} GeoJSONEvent\n * @property {Layer} layer The layer for the GeoJSON feature that is being added to the map.\n * @property {object} properties GeoJSON properties of the feature.\n * @property {string} geometryType GeoJSON geometry type of the feature.\n * @property {string|number} [id] GeoJSON ID of the feature (if present).\n * @extends MaplairEvent\n */\n\n/**\n * The event object of opening and closing popups.\n * @typedef {object} PopupEvent\n * @property {Popup} popup The popup that was opened or closed.\n * @extends MaplairEvent\n */\n\n/**\n * The event object of opening and closing tooltips.\n * @typedef {object} TooltipEvent\n * @property {Tooltip} tooltip The tooltip that was opened or closed.\n * @extends MaplairEvent\n */\n\n/**\n * The event object of `dragend`.\n * @typedef {object} DragEndEvent\n * @property {number} distance The distance in pixels the draggable element was moved by.\n * @extends MaplairEvent\n */\n\n/**\n * The event object of `zoomanim`.\n * @typedef {object} ZoomAnimEvent\n * @property {LatLng} center The current center of the map.\n * @property {number} zoom The current zoom level of the map.\n * @property {boolean} [noUpdate] Whether layers should update their contents due to this event.\n * @extends MaplairEvent\n */\n\n/**\n * A set of methods shared between event-powered classes (like `Map` and `Marker`). Generally, events allow you to execute some function when something happens with an object (e.g. the user clicks on the map, causing the map to fire `'click'` event).\n *\n * @example\n *\n * ```js\n * map.on('click', function(e) {\n * \talert(e.latlng);\n * } );\n * ```\n *\n * Maplair deals with event listeners by reference, so if you want to add a listener and then remove it, define it as a function:\n *\n * ```js\n * function onClick(e) { ... }\n *\n * map.on('click', onClick);\n * map.off('click', onClick);\n * ```\n */\nexport class Evented extends Class {\n\t/**\n\t * Adds a listener function (`fn`) to a particular event type of the object. You can\n\t * optionally specify the context of the listener (object the this keyword will point\n\t * to). You can also pass several space-separated types (e.g. `'click dblclick'`).\n\t * Alternatively, adds a set of type/listener pairs, e.g.\n\t * `{click: onClick, pointermove: onPointerMove}`, with the context as second argument.\n\t * @param {string|Record<string, EventListener>} types\n\t * @param {EventListener|object} [fn]\n\t * @param {object} [context]\n\t * @returns {this}\n\t */\n\ton(types, fn, context) {\n\n\t\t// types can be a map of types/handlers\n\t\tif (typeof types === 'object') {\n\t\t\tfor (const [type, f] of Object.entries(types)) {\n\t\t\t\t// we don't process space-separated events here for performance;\n\t\t\t\t// it's a hot path since Layer uses the on(obj) syntax\n\t\t\t\tthis._on(type, f, fn);\n\t\t\t}\n\n\t\t} else {\n\t\t\t// types can be a string of space-separated words\n\t\t\tfor (const type of Util.splitWords(types)) {\n\t\t\t\tthis._on(type, fn, context);\n\t\t\t}\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Removes a previously added listener function. If no function is specified, it will\n\t * remove all the listeners of that particular event from the object. Note that if you\n\t * passed a custom context to `on`, you must pass the same context to `off` in order to\n\t * remove the listener. Alternatively, removes a set of type/listener pairs. Without\n\t * arguments, removes all listeners to all events on the object, including implicitly\n\t * attached events.\n\t * @param {string|Record<string, EventListener>} [types]\n\t * @param {EventListener|object} [fn]\n\t * @param {object} [context]\n\t * @returns {this}\n\t */\n\toff(types, fn, context) {\n\n\t\tif (!arguments.length) {\n\t\t\t// clear all listeners if called without arguments\n\t\t\tdelete this._events;\n\t\t\tdelete this._listenerIndex;\n\n\t\t} else if (typeof types === 'object') {\n\t\t\tfor (const [type, f] of Object.entries(types)) {\n\t\t\t\tthis._off(type, f, fn);\n\t\t\t}\n\n\t\t} else {\n\t\t\tconst removeAll = arguments.length === 1;\n\t\t\tfor (const type of Util.splitWords(types)) {\n\t\t\t\tif (removeAll) {\n\t\t\t\t\tthis._off(type);\n\t\t\t\t} else {\n\t\t\t\t\tthis._off(type, fn, context);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn this;\n\t}\n\n\tstatic __REMOVED_EVENTS = {\n\t\tmousedown: 'pointerdown',\n\t\tmouseup: 'pointerup',\n\t\tmouseover: 'pointerover',\n\t\tmouseout: 'pointerout',\n\t\tmousemove: 'pointermove',\n\t\tkeypress: 'keydown'\n\t};\n\n\t// attach listener (without syntactic sugar now)\n\t_on(type, fn, context, _once) {\n\t\t// To be removed in maplair 3\n\t\tif (Object.hasOwn(Evented.__REMOVED_EVENTS, type) && !warnedEvents.has(type)) {\n\t\t\twarnedEvents.add(type);\n\t\t\tconsole.error(`The event ${type} has been removed in Maplair. Use ${Evented.__REMOVED_EVENTS[type]} instead.`);\n\t\t}\n\n\t\tif (typeof fn !== 'function') {\n\t\t\tconsole.warn(`wrong listener type: ${typeof fn}`);\n\t\t\treturn;\n\t\t}\n\n\t\tif (context === this) {\n\t\t\t// Less memory footprint.\n\t\t\tcontext = undefined;\n\t\t}\n\n\t\t// check if fn already there\n\t\tconst contexts = this._getListenerIndex(type).get(fn);\n\t\tif (contexts?.has(context)) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst newListener = {fn, ctx: context};\n\t\tif (_once) {\n\t\t\tnewListener.once = true;\n\t\t}\n\n\t\tthis._events ??= {};\n\t\t// a Set keeps the listeners in order, and allows removing them in constant time\n\t\tthis._events[type] ??= new Set();\n\t\tthis._events[type].add(newListener);\n\n\t\tif (contexts) {\n\t\t\tcontexts.set(context, newListener);\n\t\t} else {\n\t\t\tthis._listenerIndex[type].set(fn, new Map([[context, newListener]]));\n\t\t}\n\t}\n\n\t// Listeners of the given event type, indexed by function and context, so that\n\t// adding and removing listeners doesn't need to scan all listeners of the type\n\t// (e.g. each marker listens to the map's `zoom` events with the same function).\n\t_getListenerIndex(type) {\n\t\tthis._listenerIndex ??= {};\n\t\treturn (this._listenerIndex[type] ??= new Map());\n\t}\n\n\t_off(type, fn, context) {\n\t\tif (!this._events) {\n\t\t\treturn;\n\t\t}\n\n\t\tlet listeners = this._events[type];\n\t\tif (!listeners) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (arguments.length === 1) { // remove all\n\t\t\tif (this._firingCount) {\n\t\t\t\t// Set all removed listeners to noop\n\t\t\t\t// so they are not called if remove happens in fire\n\t\t\t\tfor (const listener of listeners) {\n\t\t\t\t\tlistener.fn = Util.falseFn;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// clear all listeners for a type if function isn't specified\n\t\t\tdelete this._events[type];\n\t\t\tdelete this._listenerIndex?.[type];\n\t\t\treturn;\n\t\t}\n\n\t\tif (typeof fn !== 'function') {\n\t\t\tconsole.warn(`wrong listener type: ${typeof fn}`);\n\t\t\treturn;\n\t\t}\n\n\t\t// find fn and remove it\n\t\tif (context === this) {\n\t\t\tcontext = undefined;\n\t\t}\n\t\tconst contexts = this._listenerIndex?.[type]?.get(fn),\n\t\tlistener = contexts?.get(context);\n\t\tif (listener) {\n\t\t\tcontexts.delete(context);\n\t\t\tif (!contexts.size) {\n\t\t\t\tthis._listenerIndex[type].delete(fn);\n\t\t\t}\n\t\t\tif (this._firingCount) {\n\t\t\t\t// set the removed listener to noop so that's not called if remove happens in fire\n\t\t\t\tlistener.fn = Util.falseFn;\n\n\t\t\t\t/* copy listeners in case events are being fired */\n\t\t\t\tthis._events[type] = listeners = new Set(listeners);\n\t\t\t}\n\t\t\tlisteners.delete(listener);\n\t\t}\n\t}\n\n\t/**\n\t * Fires an event of the specified type. You can optionally provide a data\n\t * object — the first argument of the listener function will contain its\n\t * properties. The event can optionally be propagated to event parents.\n\t * @param {string} type\n\t * @param {object} [data]\n\t * @param {boolean} [propagate]\n\t * @returns {this}\n\t */\n\tfire(type, data, propagate) {\n\t\tif (!this.listens(type, propagate)) { return this; }\n\n\t\tconst event = {\n\t\t\t...data,\n\t\t\ttype,\n\t\t\ttarget: this,\n\t\t\tsourceTarget: data?.sourceTarget || this\n\t\t};\n\n\t\tif (this._events) {\n\t\t\tconst listeners = this._events[type];\n\t\t\tif (listeners) {\n\t\t\t\tthis._firingCount = (this._firingCount + 1) || 1;\n\t\t\t\tfor (const l of listeners) {\n\t\t\t\t\t// off overwrites l.fn, so we need to copy fn to a variable\n\t\t\t\t\tconst fn = l.fn;\n\t\t\t\t\tif (l.once) {\n\t\t\t\t\t\tthis.off(type, fn, l.ctx);\n\t\t\t\t\t}\n\t\t\t\t\tfn.call(l.ctx || this, event);\n\t\t\t\t}\n\n\t\t\t\tthis._firingCount--;\n\t\t\t}\n\t\t}\n\n\t\tif (propagate) {\n\t\t\t// propagate the event to parents (set with addEventParent)\n\t\t\tthis._propagateEvent(event);\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Returns `true` if a particular event type has any listeners attached to it (or the\n\t * given listener function, with the given context). The verification can optionally\n\t * be propagated, it will return `true` if parents have the listener attached to it.\n\t * Called as `listens(type, propagate?)` or `listens(type, fn, context?, propagate?)`.\n\t * @param {string} type\n\t * @param {EventListener|boolean} [fn]\n\t * @param {object} [context]\n\t * @param {boolean} [propagate]\n\t * @returns {boolean}\n\t */\n\tlistens(type, fn, context, propagate) {\n\t\tif (typeof type !== 'string') {\n\t\t\tconsole.warn('\"string\" type argument expected');\n\t\t}\n\n\t\t// we don't overwrite the input `fn` value, because we need to use it for propagation\n\t\tlet _fn = fn;\n\t\tif (typeof fn !== 'function') {\n\t\t\tpropagate = !!fn;\n\t\t\t_fn = undefined;\n\t\t\tcontext = undefined;\n\t\t}\n\n\t\tif (this._events?.[type]?.size) {\n\t\t\tif (this._listens(type, _fn, context) !== false) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\n\t\tif (propagate) {\n\t\t\t// also check parents for listeners if event propagates\n\t\t\tfor (const p of Object.values(this._eventParents ?? {})) {\n\t\t\t\tif (p.listens(type, fn, context, propagate)) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\n\t// returns whether the given listener (or any listener, if no `fn` is given) is registered\n\t_listens(type, fn, context) {\n\t\tif (!this._events) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst listeners = this._events[type];\n\t\tif (!fn) {\n\t\t\treturn !!listeners?.size;\n\t\t}\n\n\t\tif (context === this) {\n\t\t\t// Less memory footprint.\n\t\t\tcontext = undefined;\n\t\t}\n\n\t\treturn !!this._listenerIndex?.[type]?.get(fn)?.has(context);\n\n\t}\n\n\t/**\n\t * Behaves as [`on(…)`](#evented-on), except the listener will only get fired once and then removed.\n\t * @param {string|Record<string, EventListener>} types\n\t * @param {EventListener|object} [fn]\n\t * @param {object} [context]\n\t * @returns {this}\n\t */\n\tonce(types, fn, context) {\n\n\t\t// types can be a map of types/handlers\n\t\tif (typeof types === 'object') {\n\t\t\tfor (const [type, f] of Object.entries(types)) {\n\t\t\t\t// we don't process space-separated events here for performance;\n\t\t\t\t// it's a hot path since Layer uses the on(obj) syntax\n\t\t\t\tthis._on(type, f, fn, true);\n\t\t\t}\n\n\t\t} else {\n\t\t\t// types can be a string of space-separated words\n\t\t\tfor (const type of Util.splitWords(types)) {\n\t\t\t\tthis._on(type, fn, context, true);\n\t\t\t}\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Adds an event parent - an `Evented` that will receive propagated events.\n\t * @param {Evented} obj\n\t * @returns {this}\n\t */\n\taddEventParent(obj) {\n\t\tthis._eventParents ??= {};\n\t\tthis._eventParents[Util.stamp(obj)] = obj;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Removes an event parent, so it will stop receiving propagated events.\n\t * @param {Evented} obj\n\t * @returns {this}\n\t */\n\tremoveEventParent(obj) {\n\t\tif (this._eventParents) {\n\t\t\tdelete this._eventParents[Util.stamp(obj)];\n\t\t}\n\t\treturn this;\n\t}\n\n\t_propagateEvent(e) {\n\t\tfor (const p of Object.values(this._eventParents ?? {})) {\n\t\t\tp.fire(e.type, {\n\t\t\t\tpropagatedFrom: e.target,\n\t\t\t\t...e\n\t\t\t}, true);\n\t\t}\n\t}\n};\n"],"mappings":";;;AAGA,MAAM,+BAAe,IAAI,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuM7B,IAAa,UAAb,MAAa,gBAAgB,MAAM;;;;;;;;;;;;CAYlC,GAAG,OAAO,IAAI,SAAS;EAGtB,IAAI,OAAO,UAAU,UACpB,KAAK,MAAM,CAAC,MAAM,MAAM,OAAO,QAAQ,KAAK,GAG3C,KAAK,IAAI,MAAM,GAAG,EAAE;OAKrB,KAAK,MAAM,QAAQA,WAAgB,KAAK,GACvC,KAAK,IAAI,MAAM,IAAI,OAAO;EAI5B,OAAO;CACR;;;;;;;;;;;;;CAcA,IAAI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O;CACR;;;;;;CAOA,kBAAkB,KAAK;EACtB,IAAI,KAAK,eACR,OAAO,KAAK,cAAcA,MAAW,GAAG;EAEzC,OAAO;CACR;CAEA,gBAAgB,GAAG;EAClB,KAAK,MAAM,KAAK,OAAO,OAAO,KAAK,iBAAiB,CAAC,CAAC,GACrD,EAAE,KAAK,EAAE,MAAM;GACd,gBAAgB,EAAE;GAClB,GAAG;EACJ,GAAG,IAAI;CAET;AACD"}
|
|
1
|
+
{"version":3,"file":"Events.js","names":["Util.splitWords","Util.falseFn","Util.stamp"],"sources":["../../../src/core/Events.js"],"sourcesContent":["import {Class} from './Class.js';\nimport * as Util from './Util.js';\n\nconst warnedEvents = new Set();\n/** @import {LatLng} from '../geo/LatLng.js' */\n/** @import {LatLngBounds} from '../geo/LatLngBounds.js' */\n/** @import {Point} from '../geometry/Point.js' */\n/** @import {CRS} from '../geo/crs/CRS.js' */\n/** @import {Layer} from '../layer/Layer.js' */\n/** @import {Popup} from '../layer/Popup.js' */\n/** @import {Tooltip} from '../layer/Tooltip.js' */\n\n/**\n * The base event object, the argument of event listeners. All other event objects\n * contain these properties too. Whenever a class inheriting from `Evented` fires an\n * event, a listener function is called with an event object containing information\n * about the event, which depends on the event type. For example:\n *\n * ```js\n * map.on('click', function(ev) {\n * alert(ev.latlng); // ev is an event object (MaplairPointerEvent in this case)\n * });\n * ```\n *\n * @typedef {object} MaplairEvent\n * @property {string} type The event type (e.g. `'click'`).\n * @property {any} target The object that fired the event. For propagated events, the\n * last object in the propagation chain that fired the event.\n * @property {any} sourceTarget The object that originally fired the event. For\n * non-propagated events, this will be the same as the `target`.\n * @property {any} [propagatedFrom] For propagated events, the last object that\n * propagated the event to its event parent.\n */\n\n/**\n * A listener of events, called with the event object, which has more properties\n * depending on the event type (see the event objects below).\n * @typedef {(event: MaplairEvent & Record<string, any>) => void} EventListener\n */\n\n/**\n * The event object of keyboard events.\n * @typedef {object} MaplairKeyboardEvent\n * @property {KeyboardEvent} originalEvent The original\n * [DOM `KeyboardEvent`](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent)\n * that triggered this Maplair event.\n * @extends MaplairEvent\n */\n\n/**\n * The event object of pointer events (`click`, `pointermove`, …).\n * @typedef {object} MaplairPointerEvent\n * @property {LatLng} latlng The geographical point where the pointer event occurred.\n * @property {Point} layerPoint Pixel coordinates of the point where the pointer event\n * occurred relative to the map layer.\n * @property {Point} containerPoint Pixel coordinates of the point where the pointer\n * event occurred relative to the map container.\n * @property {MouseEvent|PointerEvent} originalEvent The original\n * [DOM `MouseEvent`](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent) or\n * [DOM `PointerEvent`](https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent)\n * that triggered this Maplair event.\n * @extends MaplairEvent\n */\n\n/**\n * The event object of `locationfound`.\n * @typedef {object} LocationEvent\n * @property {LatLng} latlng Detected geographical location of the user.\n * @property {LatLngBounds} bounds Geographical bounds of the area user is located in\n * (with respect to the accuracy of location).\n * @property {number} accuracy Accuracy of location in meters.\n * @property {number} altitude Height of the position above the WGS84 ellipsoid in meters.\n * @property {number} altitudeAccuracy Accuracy of altitude in meters.\n * @property {number} heading The direction of travel in degrees counting clockwise from true North.\n * @property {number} speed Current velocity in meters per second.\n * @property {number} timestamp The time when the position was acquired.\n * @extends MaplairEvent\n */\n\n/**\n * The event object of errors, e.g. `locationerror`.\n * @typedef {object} MaplairErrorEvent\n * @property {string} message Error message.\n * @property {number} [code] Error code (if applicable).\n * @extends MaplairEvent\n */\n\n/**\n * The event object of adding and removing layers.\n * @typedef {object} LayerEvent\n * @property {Layer} layer The layer that was added or removed.\n * @extends MaplairEvent\n */\n\n/**\n * The event object of the layers control.\n * @typedef {object} LayersControlEvent\n * @property {Layer} layer The layer that was added or removed.\n * @property {string} name The name of the layer that was added or removed.\n * @property {Event} [originalEvent] The DOM event of the click on the entry in the\n * layers control, `undefined` if the layer was added or removed by code.\n * @extends MaplairEvent\n */\n\n/**\n * The event object of tile events.\n * @typedef {object} TileEvent\n * @property {HTMLElement} tile The tile element (image).\n * @property {Point} coords Point object with the tile's `x`, `y`, and `z` (zoom level) coordinates.\n * @extends MaplairEvent\n */\n\n/**\n * The event object of `tileerror`.\n * @typedef {object} TileErrorEvent\n * @property {any} error Error passed to the tile's `done()` callback.\n * @extends TileEvent\n */\n\n/**\n * The event object of `resize`.\n * @typedef {object} ResizeEvent\n * @property {Point} oldSize The old size before resize event.\n * @property {Point} newSize The new size after the resize event.\n * @extends MaplairEvent\n */\n\n/**\n * The event object of `crschange`.\n * @typedef {object} CrsChangeEvent\n * @property {CRS} oldCrs The CRS of the map before the change.\n * @property {CRS} crs The new CRS of the map.\n * @extends MaplairEvent\n */\n\n/**\n * The event object of `worldcopyjump`.\n * @typedef {object} WorldCopyJumpEvent\n * @property {number} worlds The signed number of world widths by which the map pane moved.\n * @extends MaplairEvent\n */\n\n/**\n * The event object of adding GeoJSON features.\n * @typedef {object} GeoJSONEvent\n * @property {Layer} layer The layer for the GeoJSON feature that is being added to the map.\n * @property {object} properties GeoJSON properties of the feature.\n * @property {string} geometryType GeoJSON geometry type of the feature.\n * @property {string|number} [id] GeoJSON ID of the feature (if present).\n * @extends MaplairEvent\n */\n\n/**\n * The event object of opening and closing popups.\n * @typedef {object} PopupEvent\n * @property {Popup} popup The popup that was opened or closed.\n * @extends MaplairEvent\n */\n\n/**\n * The event object of opening and closing tooltips.\n * @typedef {object} TooltipEvent\n * @property {Tooltip} tooltip The tooltip that was opened or closed.\n * @extends MaplairEvent\n */\n\n/**\n * The event object of `dragend`.\n * @typedef {object} DragEndEvent\n * @property {number} distance The distance in pixels the draggable element was moved by.\n * @extends MaplairEvent\n */\n\n/**\n * The event object of `zoomanim`.\n * @typedef {object} ZoomAnimEvent\n * @property {LatLng} center The current center of the map.\n * @property {number} zoom The current zoom level of the map.\n * @property {boolean} [noUpdate] Whether layers should update their contents due to this event.\n * @extends MaplairEvent\n */\n\n/**\n * A set of methods shared between event-powered classes (like `Map` and `Marker`). Generally, events allow you to execute some function when something happens with an object (e.g. the user clicks on the map, causing the map to fire `'click'` event).\n *\n * @example\n *\n * ```js\n * map.on('click', function(e) {\n * \talert(e.latlng);\n * } );\n * ```\n *\n * Maplair deals with event listeners by reference, so if you want to add a listener and then remove it, define it as a function:\n *\n * ```js\n * function onClick(e) { ... }\n *\n * map.on('click', onClick);\n * map.off('click', onClick);\n * ```\n */\nexport class Evented extends Class {\n\t/**\n\t * Adds a listener function (`fn`) to a particular event type of the object. You can\n\t * optionally specify the context of the listener (object the this keyword will point\n\t * to). You can also pass several space-separated types (e.g. `'click dblclick'`).\n\t * Alternatively, adds a set of type/listener pairs, e.g.\n\t * `{click: onClick, pointermove: onPointerMove}`, with the context as second argument.\n\t * @param {string|Record<string, EventListener>} types\n\t * @param {EventListener|object} [fn]\n\t * @param {object} [context]\n\t * @returns {this}\n\t */\n\ton(types, fn, context) {\n\n\t\t// types can be a map of types/handlers\n\t\tif (typeof types === 'object') {\n\t\t\tfor (const [type, f] of Object.entries(types)) {\n\t\t\t\t// we don't process space-separated events here for performance;\n\t\t\t\t// it's a hot path since Layer uses the on(obj) syntax\n\t\t\t\tthis._on(type, f, fn);\n\t\t\t}\n\n\t\t} else {\n\t\t\t// types can be a string of space-separated words\n\t\t\tfor (const type of Util.splitWords(types)) {\n\t\t\t\tthis._on(type, fn, context);\n\t\t\t}\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Removes a previously added listener function. If no function is specified, it will\n\t * remove all the listeners of that particular event from the object. Note that if you\n\t * passed a custom context to `on`, you must pass the same context to `off` in order to\n\t * remove the listener. Alternatively, removes a set of type/listener pairs. Without\n\t * arguments, removes all listeners to all events on the object, including implicitly\n\t * attached events.\n\t * @param {string|Record<string, EventListener>} [types]\n\t * @param {EventListener|object} [fn]\n\t * @param {object} [context]\n\t * @returns {this}\n\t */\n\toff(types, fn, context) {\n\n\t\tif (!arguments.length) {\n\t\t\t// clear all listeners if called without arguments\n\t\t\tdelete this._events;\n\t\t\tdelete this._listenerIndex;\n\n\t\t} else if (typeof types === 'object') {\n\t\t\tfor (const [type, f] of Object.entries(types)) {\n\t\t\t\tthis._off(type, f, fn);\n\t\t\t}\n\n\t\t} else {\n\t\t\tconst removeAll = arguments.length === 1;\n\t\t\tfor (const type of Util.splitWords(types)) {\n\t\t\t\tif (removeAll) {\n\t\t\t\t\tthis._off(type);\n\t\t\t\t} else {\n\t\t\t\t\tthis._off(type, fn, context);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn this;\n\t}\n\n\tstatic __REMOVED_EVENTS = {\n\t\tmousedown: 'pointerdown',\n\t\tmouseup: 'pointerup',\n\t\tmouseover: 'pointerover',\n\t\tmouseout: 'pointerout',\n\t\tmousemove: 'pointermove',\n\t\tkeypress: 'keydown'\n\t};\n\n\t// attach listener (without syntactic sugar now)\n\t_on(type, fn, context, _once) {\n\t\t// To be removed in maplair 3\n\t\tif (Object.hasOwn(Evented.__REMOVED_EVENTS, type) && !warnedEvents.has(type)) {\n\t\t\twarnedEvents.add(type);\n\t\t\tconsole.error(`The event ${type} has been removed in Maplair. Use ${Evented.__REMOVED_EVENTS[type]} instead.`);\n\t\t}\n\n\t\tif (typeof fn !== 'function') {\n\t\t\tconsole.warn(`wrong listener type: ${typeof fn}`);\n\t\t\treturn;\n\t\t}\n\n\t\tif (context === this) {\n\t\t\t// Less memory footprint.\n\t\t\tcontext = undefined;\n\t\t}\n\n\t\t// check if fn already there\n\t\tconst contexts = this._getListenerIndex(type).get(fn);\n\t\tif (contexts?.has(context)) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst newListener = {fn, ctx: context};\n\t\tif (_once) {\n\t\t\tnewListener.once = true;\n\t\t}\n\n\t\tthis._events ??= {};\n\t\t// a Set keeps the listeners in order, and allows removing them in constant time\n\t\tthis._events[type] ??= new Set();\n\t\tthis._events[type].add(newListener);\n\n\t\tif (contexts) {\n\t\t\tcontexts.set(context, newListener);\n\t\t} else {\n\t\t\tthis._listenerIndex[type].set(fn, new Map([[context, newListener]]));\n\t\t}\n\t}\n\n\t// Listeners of the given event type, indexed by function and context, so that\n\t// adding and removing listeners doesn't need to scan all listeners of the type\n\t// (e.g. each marker listens to the map's `zoom` events with the same function).\n\t_getListenerIndex(type) {\n\t\tthis._listenerIndex ??= {};\n\t\treturn (this._listenerIndex[type] ??= new Map());\n\t}\n\n\t_off(type, fn, context) {\n\t\tif (!this._events) {\n\t\t\treturn;\n\t\t}\n\n\t\tlet listeners = this._events[type];\n\t\tif (!listeners) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (arguments.length === 1) { // remove all\n\t\t\tif (this._firingCount) {\n\t\t\t\t// Set all removed listeners to noop\n\t\t\t\t// so they are not called if remove happens in fire\n\t\t\t\tfor (const listener of listeners) {\n\t\t\t\t\tlistener.fn = Util.falseFn;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// clear all listeners for a type if function isn't specified\n\t\t\tdelete this._events[type];\n\t\t\tdelete this._listenerIndex?.[type];\n\t\t\treturn;\n\t\t}\n\n\t\tif (typeof fn !== 'function') {\n\t\t\tconsole.warn(`wrong listener type: ${typeof fn}`);\n\t\t\treturn;\n\t\t}\n\n\t\t// find fn and remove it\n\t\tif (context === this) {\n\t\t\tcontext = undefined;\n\t\t}\n\t\tconst contexts = this._listenerIndex?.[type]?.get(fn),\n\t\tlistener = contexts?.get(context);\n\t\tif (listener) {\n\t\t\tcontexts.delete(context);\n\t\t\tif (!contexts.size) {\n\t\t\t\tthis._listenerIndex[type].delete(fn);\n\t\t\t}\n\t\t\tif (this._firingCount) {\n\t\t\t\t// set the removed listener to noop so that's not called if remove happens in fire\n\t\t\t\tlistener.fn = Util.falseFn;\n\n\t\t\t\t/* copy listeners in case events are being fired */\n\t\t\t\tthis._events[type] = listeners = new Set(listeners);\n\t\t\t}\n\t\t\tlisteners.delete(listener);\n\t\t}\n\t}\n\n\t/**\n\t * Fires an event of the specified type. You can optionally provide a data\n\t * object — the first argument of the listener function will contain its\n\t * properties. The event can optionally be propagated to event parents.\n\t * @param {string} type\n\t * @param {object} [data]\n\t * @param {boolean} [propagate]\n\t * @returns {this}\n\t */\n\tfire(type, data, propagate) {\n\t\tif (!this.listens(type, propagate)) { return this; }\n\n\t\tconst event = {\n\t\t\t...data,\n\t\t\ttype,\n\t\t\ttarget: this,\n\t\t\tsourceTarget: data?.sourceTarget || this\n\t\t};\n\n\t\tif (this._events) {\n\t\t\tconst listeners = this._events[type];\n\t\t\tif (listeners) {\n\t\t\t\tthis._firingCount = (this._firingCount + 1) || 1;\n\t\t\t\tfor (const l of listeners) {\n\t\t\t\t\t// off overwrites l.fn, so we need to copy fn to a variable\n\t\t\t\t\tconst fn = l.fn;\n\t\t\t\t\tif (l.once) {\n\t\t\t\t\t\tthis.off(type, fn, l.ctx);\n\t\t\t\t\t}\n\t\t\t\t\tfn.call(l.ctx || this, event);\n\t\t\t\t}\n\n\t\t\t\tthis._firingCount--;\n\t\t\t}\n\t\t}\n\n\t\tif (propagate) {\n\t\t\t// propagate the event to parents (set with addEventParent)\n\t\t\tthis._propagateEvent(event);\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Returns `true` if a particular event type has any listeners attached to it (or the\n\t * given listener function, with the given context). The verification can optionally\n\t * be propagated, it will return `true` if parents have the listener attached to it.\n\t * Called as `listens(type, propagate?)` or `listens(type, fn, context?, propagate?)`.\n\t * @param {string} type\n\t * @param {EventListener|boolean} [fn]\n\t * @param {object} [context]\n\t * @param {boolean} [propagate]\n\t * @returns {boolean}\n\t */\n\tlistens(type, fn, context, propagate) {\n\t\tif (typeof type !== 'string') {\n\t\t\tconsole.warn('\"string\" type argument expected');\n\t\t}\n\n\t\t// we don't overwrite the input `fn` value, because we need to use it for propagation\n\t\tlet _fn = fn;\n\t\tif (typeof fn !== 'function') {\n\t\t\tpropagate = !!fn;\n\t\t\t_fn = undefined;\n\t\t\tcontext = undefined;\n\t\t}\n\n\t\tif (this._events?.[type]?.size) {\n\t\t\tif (this._listens(type, _fn, context) !== false) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\n\t\tif (propagate) {\n\t\t\t// also check parents for listeners if event propagates\n\t\t\tfor (const p of Object.values(this._eventParents ?? {})) {\n\t\t\t\tif (p.listens(type, fn, context, propagate)) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\n\t// returns whether the given listener (or any listener, if no `fn` is given) is registered\n\t_listens(type, fn, context) {\n\t\tif (!this._events) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst listeners = this._events[type];\n\t\tif (!fn) {\n\t\t\treturn !!listeners?.size;\n\t\t}\n\n\t\tif (context === this) {\n\t\t\t// Less memory footprint.\n\t\t\tcontext = undefined;\n\t\t}\n\n\t\treturn !!this._listenerIndex?.[type]?.get(fn)?.has(context);\n\n\t}\n\n\t/**\n\t * Behaves as [`on(…)`](#evented-on), except the listener will only get fired once and then removed.\n\t * @param {string|Record<string, EventListener>} types\n\t * @param {EventListener|object} [fn]\n\t * @param {object} [context]\n\t * @returns {this}\n\t */\n\tonce(types, fn, context) {\n\n\t\t// types can be a map of types/handlers\n\t\tif (typeof types === 'object') {\n\t\t\tfor (const [type, f] of Object.entries(types)) {\n\t\t\t\t// we don't process space-separated events here for performance;\n\t\t\t\t// it's a hot path since Layer uses the on(obj) syntax\n\t\t\t\tthis._on(type, f, fn, true);\n\t\t\t}\n\n\t\t} else {\n\t\t\t// types can be a string of space-separated words\n\t\t\tfor (const type of Util.splitWords(types)) {\n\t\t\t\tthis._on(type, fn, context, true);\n\t\t\t}\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Adds an event parent - an `Evented` that will receive propagated events.\n\t * @param {Evented} obj\n\t * @returns {this}\n\t */\n\taddEventParent(obj) {\n\t\tthis._eventParents ??= {};\n\t\tthis._eventParents[Util.stamp(obj)] = obj;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Removes an event parent, so it will stop receiving propagated events.\n\t * @param {Evented} obj\n\t * @returns {this}\n\t */\n\tremoveEventParent(obj) {\n\t\tif (this._eventParents) {\n\t\t\tdelete this._eventParents[Util.stamp(obj)];\n\t\t}\n\t\treturn this;\n\t}\n\n\t_propagateEvent(e) {\n\t\tfor (const p of Object.values(this._eventParents ?? {})) {\n\t\t\t// `layer` is the Leaflet 1 name of `propagatedFrom`, left out of the types to steer new code to the new one\n\t\t\tp.fire(e.type, {\n\t\t\t\tlayer: e.target,\n\t\t\t\tpropagatedFrom: e.target,\n\t\t\t\t...e\n\t\t\t}, true);\n\t\t}\n\t}\n};\n"],"mappings":";;;AAGA,MAAM,+BAAe,IAAI,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuM7B,IAAa,UAAb,MAAa,gBAAgB,MAAM;;;;;;;;;;;;CAYlC,GAAG,OAAO,IAAI,SAAS;EAGtB,IAAI,OAAO,UAAU,UACpB,KAAK,MAAM,CAAC,MAAM,MAAM,OAAO,QAAQ,KAAK,GAG3C,KAAK,IAAI,MAAM,GAAG,EAAE;OAKrB,KAAK,MAAM,QAAQA,WAAgB,KAAK,GACvC,KAAK,IAAI,MAAM,IAAI,OAAO;EAI5B,OAAO;CACR;;;;;;;;;;;;;CAcA,IAAI,OAAO,IAAI,SAAS;EAEvB,IAAI,CAAC,UAAU,QAAQ;GAEtB,OAAO,KAAK;GACZ,OAAO,KAAK;EAEb,OAAO,IAAI,OAAO,UAAU,UAC3B,KAAK,MAAM,CAAC,MAAM,MAAM,OAAO,QAAQ,KAAK,GAC3C,KAAK,KAAK,MAAM,GAAG,EAAE;OAGhB;GACN,MAAM,YAAY,UAAU,WAAW;GACvC,KAAK,MAAM,QAAQA,WAAgB,KAAK,G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;AACD"}
|
|
@@ -30,6 +30,7 @@ var Circle = class Circle extends CircleMarker {
|
|
|
30
30
|
* @param {CircleOptions} [options]
|
|
31
31
|
*/
|
|
32
32
|
constructor(latlng, options) {
|
|
33
|
+
if (typeof options === "number") throw new Error("Circle: the radius is an option in Maplair. Use new Circle(latlng, {radius}).");
|
|
33
34
|
super(latlng, options);
|
|
34
35
|
if (isNaN(this.options.radius)) throw new Error("Circle radius cannot be NaN");
|
|
35
36
|
this.callInitHooks(Circle);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Circle.js","names":[],"sources":["../../../../src/layer/vector/Circle.js"],"sourcesContent":["import {CircleMarker} from './CircleMarker.js';\nimport {LatLngBounds} from '../../geo/LatLngBounds.js';\nimport {EarthCRS} from '../../geo/crs/EarthCRS.js';\n/** @import {LatLngExpression} from '../../geo/LatLng.js' */\n/** @import {CircleMarkerOptions} from './CircleMarker.js' */\n\n\n/**\n * Options of `Circle`.\n * @typedef {object} CircleOptions\n * @property {number} [radius] Radius of the circle, in meters.\n * @extends CircleMarkerOptions\n */\n\n/**\n * A class for drawing circle overlays on a map with radius specified in meters.\n * Extends `CircleMarker`, its `setRadius()` and `getRadius()` use meters.\n *\n * It's an approximation and starts to diverge from a real circle closer to poles\n * (due to projection distortion).\n *\n * @example\n * ```js\n * new Circle([50.5, 30.5], {radius: 200}).addTo(map);\n * ```\n */\nexport class Circle extends CircleMarker {\n\n\t/**\n\t * Instantiates a circle object given a geographical point, and an options object\n\t * which contains the circle radius.\n\t * @param {LatLngExpression} latlng\n\t * @param {CircleOptions} [options]\n\t */\n\tconstructor(latlng, options) {\n\t\tsuper(latlng, options);\n\n\t\tif (isNaN(this.options.radius)) { throw new Error('Circle radius cannot be NaN'); }\n\n\t\tthis.callInitHooks(Circle);\n\t}\n\n\t/**\n\t * Returns the `LatLngBounds` of the path. When the circle isn't on a map, they're\n\t * approximated on a sphere.\n\t * @returns {LatLngBounds}\n\t */\n\tgetBounds() {\n\t\tif (!this._map) { return this._latlng.toBounds(this._radius * 2); }\n\n\t\tconst half = [this._pxRadius, this._pxRadiusY ?? this._pxRadius];\n\n\t\treturn new LatLngBounds(\n\t\t\tthis._map.layerPointToLatLng(this._point.subtract(half)),\n\t\t\tthis._map.layerPointToLatLng(this._point.add(half)));\n\t}\n\n\t_project() {\n\n\t\tconst lng = this._latlng.lng,\n\t\tlat = this._latlng.lat,\n\t\tmap = this._map,\n\t\tcrs = map.options.crs;\n\n\t\tif (crs.distance === EarthCRS.distance) {\n\t\t\tconst d = Math.PI / 180,\n\t\t\tlatR = (this._radius / EarthCRS.R) / d,\n\t\t\ttop = map.project([lat + latR, lng]),\n\t\t\tbottom = map.project([lat - latR, lng]),\n\t\t\tp = top.add(bottom).divideBy(2),\n\t\t\tlat2 = map.unproject(p).lat;\n\t\t\t// Longitude span from the haversine form of the spherical law of cosines. The plain acos() form\n\t\t\t// loses precision for radii of about a metre and less, where cos(latR) is too close to 1 (#6120).\n\t\t\tlet lngR = 2 * Math.asin(Math.sqrt(\n\t\t\t\t(Math.sin(latR * d / 2) ** 2 - Math.sin((lat2 - lat) * d / 2) ** 2) /\n\t\t\t\t(Math.cos(lat * d) * Math.cos(lat2 * d)))) / d;\n\n\t\t\tif (isNaN(lngR) || lngR === 0) {\n\t\t\t\tlngR = latR / Math.cos(Math.PI / 180 * lat); // Fallback for edge case, #2425\n\t\t\t}\n\n\t\t\tthis._point = p.subtract(map.getPixelOrigin());\n\t\t\tthis._pxRadius = isNaN(lngR) ? 0 : p.x - map.project([lat2, lng - lngR]).x;\n\t\t\tthis._pxRadiusY = p.y - top.y;\n\n\t\t} else {\n\t\t\tconst latlng2 = crs.unproject(crs.project(this._latlng).subtract([this._radius, 0]));\n\n\t\t\tthis._point = map.latLngToLayerPoint(this._latlng);\n\t\t\tthis._pxRadius = Math.abs(this._point.x - map.latLngToLayerPoint(latlng2).x);\n\t\t}\n\n\t\tthis._updateBounds();\n\t}\n}\n"],"mappings":";;;;;;;;;;;;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GAAG;GAG3C,KAAK,SAAS,EAAE,SAAS,IAAI,eAAe,CAAC;GAC7C,KAAK,YAAY,MAAM,IAAI,IAAI,IAAI,EAAE,IAAI,IAAI,QAAQ,CAAC,MAAM,MAAM,IAAI,CAAC,CAAC,CAAC;GACzE,KAAK,aAAa,EAAE,IAAI,IAAI;EAE7B,OAAO;GACN,MAAM,UAAU,IAAI,UAAU,IAAI,QAAQ,KAAK,OAAO,CAAC,CAAC,SAAS,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC;GAEnF,KAAK,SAAS,IAAI,mBAAmB,KAAK,OAAO;GACjD,KAAK,YAAY,KAAK,IAAI,KAAK,OAAO,IAAI,IAAI,mBAAmB,OAAO,CAAC,CAAC,CAAC;EAC5E;EAEA,KAAK,cAAc;CACpB;AACD"}
|
|
1
|
+
{"version":3,"file":"Circle.js","names":[],"sources":["../../../../src/layer/vector/Circle.js"],"sourcesContent":["import {CircleMarker} from './CircleMarker.js';\nimport {LatLngBounds} from '../../geo/LatLngBounds.js';\nimport {EarthCRS} from '../../geo/crs/EarthCRS.js';\n/** @import {LatLngExpression} from '../../geo/LatLng.js' */\n/** @import {CircleMarkerOptions} from './CircleMarker.js' */\n\n\n/**\n * Options of `Circle`.\n * @typedef {object} CircleOptions\n * @property {number} [radius] Radius of the circle, in meters.\n * @extends CircleMarkerOptions\n */\n\n/**\n * A class for drawing circle overlays on a map with radius specified in meters.\n * Extends `CircleMarker`, its `setRadius()` and `getRadius()` use meters.\n *\n * It's an approximation and starts to diverge from a real circle closer to poles\n * (due to projection distortion).\n *\n * @example\n * ```js\n * new Circle([50.5, 30.5], {radius: 200}).addTo(map);\n * ```\n */\nexport class Circle extends CircleMarker {\n\n\t/**\n\t * Instantiates a circle object given a geographical point, and an options object\n\t * which contains the circle radius.\n\t * @param {LatLngExpression} latlng\n\t * @param {CircleOptions} [options]\n\t */\n\tconstructor(latlng, options) {\n\t\tif (typeof options === 'number') {\n\t\t\tthrow new Error('Circle: the radius is an option in Maplair. Use new Circle(latlng, {radius}).');\n\t\t}\n\t\tsuper(latlng, options);\n\n\t\tif (isNaN(this.options.radius)) { throw new Error('Circle radius cannot be NaN'); }\n\n\t\tthis.callInitHooks(Circle);\n\t}\n\n\t/**\n\t * Returns the `LatLngBounds` of the path. When the circle isn't on a map, they're\n\t * approximated on a sphere.\n\t * @returns {LatLngBounds}\n\t */\n\tgetBounds() {\n\t\tif (!this._map) { return this._latlng.toBounds(this._radius * 2); }\n\n\t\tconst half = [this._pxRadius, this._pxRadiusY ?? this._pxRadius];\n\n\t\treturn new LatLngBounds(\n\t\t\tthis._map.layerPointToLatLng(this._point.subtract(half)),\n\t\t\tthis._map.layerPointToLatLng(this._point.add(half)));\n\t}\n\n\t_project() {\n\n\t\tconst lng = this._latlng.lng,\n\t\tlat = this._latlng.lat,\n\t\tmap = this._map,\n\t\tcrs = map.options.crs;\n\n\t\tif (crs.distance === EarthCRS.distance) {\n\t\t\tconst d = Math.PI / 180,\n\t\t\tlatR = (this._radius / EarthCRS.R) / d,\n\t\t\ttop = map.project([lat + latR, lng]),\n\t\t\tbottom = map.project([lat - latR, lng]),\n\t\t\tp = top.add(bottom).divideBy(2),\n\t\t\tlat2 = map.unproject(p).lat;\n\t\t\t// Longitude span from the haversine form of the spherical law of cosines. The plain acos() form\n\t\t\t// loses precision for radii of about a metre and less, where cos(latR) is too close to 1 (#6120).\n\t\t\tlet lngR = 2 * Math.asin(Math.sqrt(\n\t\t\t\t(Math.sin(latR * d / 2) ** 2 - Math.sin((lat2 - lat) * d / 2) ** 2) /\n\t\t\t\t(Math.cos(lat * d) * Math.cos(lat2 * d)))) / d;\n\n\t\t\tif (isNaN(lngR) || lngR === 0) {\n\t\t\t\tlngR = latR / Math.cos(Math.PI / 180 * lat); // Fallback for edge case, #2425\n\t\t\t}\n\n\t\t\tthis._point = p.subtract(map.getPixelOrigin());\n\t\t\tthis._pxRadius = isNaN(lngR) ? 0 : p.x - map.project([lat2, lng - lngR]).x;\n\t\t\tthis._pxRadiusY = p.y - top.y;\n\n\t\t} else {\n\t\t\tconst latlng2 = crs.unproject(crs.project(this._latlng).subtract([this._radius, 0]));\n\n\t\t\tthis._point = map.latLngToLayerPoint(this._latlng);\n\t\t\tthis._pxRadius = Math.abs(this._point.x - map.latLngToLayerPoint(latlng2).x);\n\t\t}\n\n\t\tthis._updateBounds();\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA0BA,IAAa,SAAb,MAAa,eAAe,aAAa;;;;;;;CAQxC,YAAY,QAAQ,SAAS;EAC5B,IAAI,OAAO,YAAY,UACtB,MAAM,IAAI,MAAM,+EAA+E;EAEhG,MAAM,QAAQ,OAAO;EAErB,IAAI,MAAM,KAAK,QAAQ,MAAM,GAAK,MAAM,IAAI,MAAM,6BAA6B;EAE/E,KAAK,cAAc,MAAM;CAC1B;;;;;;CAOA,YAAY;EACX,IAAI,CAAC,KAAK,MAAQ,OAAO,KAAK,QAAQ,SAAS,KAAK,UAAU,CAAC;EAE/D,MAAM,OAAO,CAAC,KAAK,WAAW,KAAK,cAAc,KAAK,SAAS;EAE/D,OAAO,IAAI,aACV,KAAK,KAAK,mBAAmB,KAAK,OAAO,SAAS,IAAI,CAAC,GACvD,KAAK,KAAK,mBAAmB,KAAK,OAAO,IAAI,IAAI,CAAC,CAAC;CACrD;CAEA,WAAW;EAEV,MAAM,MAAM,KAAK,QAAQ,KACzB,MAAM,KAAK,QAAQ,KACnB,MAAM,KAAK,MACX,MAAM,IAAI,QAAQ;EAElB,IAAI,IAAI,aAAa,SAAS,UAAU;GACvC,MAAM,IAAI,KAAK,KAAK,KACpB,OAAQ,KAAK,UAAU,SAAS,IAAK,GACrC,MAAM,IAAI,QAAQ,CAAC,MAAM,MAAM,GAAG,CAAC,GACnC,SAAS,IAAI,QAAQ,CAAC,MAAM,MAAM,GAAG,CAAC,GACtC,IAAI,IAAI,IAAI,MAAM,CAAC,CAAC,SAAS,CAAC,GAC9B,OAAO,IAAI,UAAU,CAAC,CAAC,CAAC;GAGxB,IAAI,OAAO,IAAI,KAAK,KAAK,KAAK,MAC5B,KAAK,IAAI,OAAO,IAAI,CAAC,KAAK,IAAI,KAAK,KAAK,OAAO,OAAO,IAAI,CAAC,KAAK,MAChE,KAAK,IAAI,MAAM,CAAC,IAAI,KAAK,IAAI,OAAO,CAAC,EAAE,CAAC,IAAI;GAE9C,IAAI,MAAM,IAAI,KAAK,SAAS,GAC3B,OAAO,OAAO,KAAK,IAAI,KAAK,KAAK,MAAM,GAAG;GAG3C,KAAK,SAAS,EAAE,SAAS,IAAI,eAAe,CAAC;GAC7C,KAAK,YAAY,MAAM,IAAI,IAAI,IAAI,EAAE,IAAI,IAAI,QAAQ,CAAC,MAAM,MAAM,IAAI,CAAC,CAAC,CAAC;GACzE,KAAK,aAAa,EAAE,IAAI,IAAI;EAE7B,OAAO;GACN,MAAM,UAAU,IAAI,UAAU,IAAI,QAAQ,KAAK,OAAO,CAAC,CAAC,SAAS,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC;GAEnF,KAAK,SAAS,IAAI,mBAAmB,KAAK,OAAO;GACjD,KAAK,YAAY,KAAK,IAAI,KAAK,OAAO,IAAI,IAAI,mBAAmB,OAAO,CAAC,CAAC,CAAC;EAC5E;EAEA,KAAK,cAAc;CACpB;AACD"}
|
package/dist/esm/package.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* @preserve
|
|
2
|
-
* Maplair 4.
|
|
2
|
+
* Maplair 4.3.0, a JS library for interactive maps. https://maplair.org
|
|
3
3
|
* (c) 2026 Simon Legner and Maplair contributors, (c) 2010-2026 Volodymyr Agafonkin, (c) 2010-2011 CloudMade
|
|
4
4
|
*/
|
|
5
5
|
(function (previousL) {
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
return target;
|
|
19
19
|
};
|
|
20
20
|
// package.json
|
|
21
|
-
var version$1 = "4.
|
|
21
|
+
var version$1 = "4.3.0";
|
|
22
22
|
// src/core/Util.js
|
|
23
23
|
var Util_exports = /* @__PURE__ */ __exportAll({
|
|
24
24
|
falseFn: () => falseFn,
|
|
@@ -2065,6 +2065,7 @@
|
|
|
2065
2065
|
}
|
|
2066
2066
|
_propagateEvent(e) {
|
|
2067
2067
|
for (const p of Object.values(this._eventParents ?? {})) p.fire(e.type, {
|
|
2068
|
+
layer: e.target,
|
|
2068
2069
|
propagatedFrom: e.target,
|
|
2069
2070
|
...e
|
|
2070
2071
|
}, true);
|
|
@@ -15963,6 +15964,7 @@
|
|
|
15963
15964
|
* @param {CircleOptions} [options]
|
|
15964
15965
|
*/
|
|
15965
15966
|
constructor(latlng, options) {
|
|
15967
|
+
if (typeof options === "number") throw new Error("Circle: the radius is an option in Maplair. Use new Circle(latlng, {radius}).");
|
|
15966
15968
|
super(latlng, options);
|
|
15967
15969
|
if (isNaN(this.options.radius)) throw new Error("Circle radius cannot be NaN");
|
|
15968
15970
|
this.callInitHooks(Circle);
|