@nextgis/ngw-leaflet 1.18.3 → 1.18.9
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/lib/ngw-leaflet.esm-browser.js +249 -197
- package/lib/ngw-leaflet.esm-browser.js.map +1 -1
- package/lib/ngw-leaflet.esm-browser.prod.js +2 -2
- package/lib/ngw-leaflet.esm-browser.prod.js.map +1 -1
- package/lib/ngw-leaflet.esm-bundler.js +1 -1
- package/lib/ngw-leaflet.global.js +244 -194
- package/lib/ngw-leaflet.global.js.map +1 -1
- package/lib/ngw-leaflet.global.prod.js +2 -2
- package/lib/ngw-leaflet.global.prod.js.map +1 -1
- package/package.json +4 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** Bundle of @nextgis/ngw-leaflet; version: 1.18.
|
|
1
|
+
/** Bundle of @nextgis/ngw-leaflet; version: 1.18.9; author: NextGIS */
|
|
2
2
|
function styleInject(css, ref) {
|
|
3
3
|
if ( ref === void 0 ) ref = {};
|
|
4
4
|
var insertAt = ref.insertAt;
|
|
@@ -19016,8 +19016,9 @@ class NgwConnector {
|
|
|
19016
19016
|
* ```
|
|
19017
19017
|
*/
|
|
19018
19018
|
apiRequest(name, params_ = {}, requestOptions = {}) {
|
|
19019
|
-
var _a;
|
|
19019
|
+
var _a, _b;
|
|
19020
19020
|
const { method, headers, withCredentials, responseType } = requestOptions;
|
|
19021
|
+
params_ = (_a = requestOptions.params) !== null && _a !== void 0 ? _a : params_;
|
|
19021
19022
|
const params = objectRemoveEmpty(params_);
|
|
19022
19023
|
const makeApiRequest = () => apiRequest({ name, params, requestOptions, connector: this });
|
|
19023
19024
|
if (requestOptions.cache && method === 'GET') {
|
|
@@ -19029,7 +19030,7 @@ class NgwConnector {
|
|
|
19029
19030
|
withCredentials,
|
|
19030
19031
|
responseType,
|
|
19031
19032
|
baseUrl: this.options.baseUrl,
|
|
19032
|
-
userId: (
|
|
19033
|
+
userId: (_b = this.user) === null || _b === void 0 ? void 0 : _b.id,
|
|
19033
19034
|
}),
|
|
19034
19035
|
});
|
|
19035
19036
|
}
|
|
@@ -19458,8 +19459,11 @@ function createGeoJsonFeature(item) {
|
|
|
19458
19459
|
}
|
|
19459
19460
|
function updateItemRequestParam(params, options) {
|
|
19460
19461
|
const { extensions, geom, fields, srs, ilike, like } = options;
|
|
19461
|
-
|
|
19462
|
-
|
|
19462
|
+
// Empty extesions by default
|
|
19463
|
+
let extensionsStr = extensions ? extensions.join(',') : '';
|
|
19464
|
+
// Use character * to set all extensions
|
|
19465
|
+
if (extensionsStr !== '*') {
|
|
19466
|
+
params.extensions = extensionsStr;
|
|
19463
19467
|
}
|
|
19464
19468
|
if (fields !== undefined) {
|
|
19465
19469
|
params.fields = Array.isArray(fields) ? fields.join(',') : '';
|
|
@@ -22077,15 +22081,16 @@ const svgPath = {
|
|
|
22077
22081
|
minus: '<path d="m12 7.5v-3h-12v3z"/>',
|
|
22078
22082
|
asterisk: '<path d="m7.59 12v-3.27l2.83 1.64 1.58-2.74-2.85-1.64 2.83-1.64-1.56-2.74-2.83 1.64v-3.24h-3.17v3.24l-2.85-1.64-1.57 2.74 2.84 1.64-2.84 1.64 1.57 2.74 2.85-1.64v3.27z"/>',
|
|
22079
22083
|
};
|
|
22084
|
+
const VIEW_BOX = 12;
|
|
22080
22085
|
const STROKE = 0.8;
|
|
22081
|
-
function generateSvg(width, height, stroke = 0, content) {
|
|
22086
|
+
function generateSvg({ width, height, stroke = 0, content, }) {
|
|
22082
22087
|
const s = stroke / 2;
|
|
22083
22088
|
const svg = `<svg
|
|
22084
22089
|
version="1.1"
|
|
22085
22090
|
xmlns="http://www.w3.org/2000/svg"
|
|
22086
22091
|
width="${width}"
|
|
22087
22092
|
height="${height}"
|
|
22088
|
-
viewBox="-${s} -${s} ${
|
|
22093
|
+
viewBox="-${s} -${s} ${VIEW_BOX + stroke} ${VIEW_BOX + stroke}"
|
|
22089
22094
|
>${content}</svg>`;
|
|
22090
22095
|
return svg;
|
|
22091
22096
|
}
|
|
@@ -22094,36 +22099,45 @@ function insertSvg(svg) {
|
|
|
22094
22099
|
const oDOM = oParser.parseFromString(svg, 'image/svg+xml');
|
|
22095
22100
|
return oDOM.documentElement;
|
|
22096
22101
|
}
|
|
22102
|
+
/**
|
|
22103
|
+
* Retrieves an icon with the provided options.
|
|
22104
|
+
* @function
|
|
22105
|
+
* @param {IconOptions} [opt={}] - Options for the icon.
|
|
22106
|
+
* @returns {IconPaint} Icon paint object.
|
|
22107
|
+
*/
|
|
22097
22108
|
function getIcon(opt = {}) {
|
|
22098
|
-
var _a, _b, _c, _d, _e;
|
|
22099
|
-
//
|
|
22109
|
+
var _a, _b, _c, _d, _e, _f;
|
|
22110
|
+
// Default values
|
|
22100
22111
|
const shape = (_a = opt.shape) !== null && _a !== void 0 ? _a : 'circle';
|
|
22101
22112
|
const color = (_b = opt.color) !== null && _b !== void 0 ? _b : 'blue';
|
|
22102
22113
|
const strokeColor = (_c = opt.strokeColor) !== null && _c !== void 0 ? _c : 'white';
|
|
22103
|
-
const size = (_d = opt.size) !== null && _d !== void 0 ? _d :
|
|
22114
|
+
const size = (_d = opt.size) !== null && _d !== void 0 ? _d : VIEW_BOX;
|
|
22104
22115
|
const rotate = (_e = opt.rotate) !== null && _e !== void 0 ? _e : 0;
|
|
22105
|
-
const anchor = size / 2;
|
|
22106
|
-
const defSize = 12;
|
|
22116
|
+
const anchor = (_f = opt.anchor) !== null && _f !== void 0 ? _f : [size / 2, size / 2];
|
|
22107
22117
|
const stroke = opt.stroke !== undefined ? Number(opt.stroke) : STROKE;
|
|
22108
|
-
const scale = size / defSize;
|
|
22109
22118
|
const pathAlias = opt.p || svgPath[shape] || 'circle';
|
|
22110
22119
|
const path = typeof pathAlias === 'string' ? pathAlias : pathAlias(opt);
|
|
22111
|
-
const svg = insertSvg(opt.svg ||
|
|
22112
|
-
|
|
22113
|
-
|
|
22114
|
-
|
|
22115
|
-
|
|
22120
|
+
const svg = insertSvg(opt.svg ||
|
|
22121
|
+
generateSvg({
|
|
22122
|
+
width: size,
|
|
22123
|
+
height: size,
|
|
22124
|
+
stroke,
|
|
22125
|
+
content: path,
|
|
22126
|
+
}));
|
|
22127
|
+
svg.setAttribute('width', String(size));
|
|
22128
|
+
svg.setAttribute('height', String(size));
|
|
22129
|
+
svg.setAttribute('fill', color);
|
|
22116
22130
|
if (stroke) {
|
|
22117
|
-
|
|
22118
|
-
|
|
22131
|
+
svg.setAttribute('stroke', strokeColor);
|
|
22132
|
+
svg.setAttribute('stroke-width', String(stroke));
|
|
22119
22133
|
}
|
|
22120
|
-
fistChild.setAttribute('transform', transform);
|
|
22121
22134
|
const s = new XMLSerializer();
|
|
22122
22135
|
return {
|
|
22123
22136
|
type: 'icon',
|
|
22124
22137
|
iconSize: [size, size],
|
|
22125
|
-
iconAnchor:
|
|
22138
|
+
iconAnchor: anchor,
|
|
22126
22139
|
html: s.serializeToString(svg),
|
|
22140
|
+
rotate,
|
|
22127
22141
|
svg,
|
|
22128
22142
|
};
|
|
22129
22143
|
}
|
|
@@ -22928,19 +22942,6 @@ function createFeaturePositionOptions(features) {
|
|
|
22928
22942
|
};
|
|
22929
22943
|
}
|
|
22930
22944
|
|
|
22931
|
-
function createMouseEvent({ layer, source, }) {
|
|
22932
|
-
const layer_ = source.target;
|
|
22933
|
-
const feature = layer_.feature;
|
|
22934
|
-
const opt = {
|
|
22935
|
-
layer,
|
|
22936
|
-
feature,
|
|
22937
|
-
event: convertMapClickEvent(source),
|
|
22938
|
-
source,
|
|
22939
|
-
...createFeaturePositionOptions(feature),
|
|
22940
|
-
};
|
|
22941
|
-
return opt;
|
|
22942
|
-
}
|
|
22943
|
-
|
|
22944
22945
|
function findMostFrequentGeomType(arr) {
|
|
22945
22946
|
const counts = {};
|
|
22946
22947
|
for (let fry = 0; fry < arr.length; fry++) {
|
|
@@ -22995,6 +22996,201 @@ class BaseAdapter {
|
|
|
22995
22996
|
}
|
|
22996
22997
|
}
|
|
22997
22998
|
|
|
22999
|
+
function createMouseEvent({ layer, source, }) {
|
|
23000
|
+
const layer_ = source.target;
|
|
23001
|
+
const feature = layer_.feature;
|
|
23002
|
+
const opt = {
|
|
23003
|
+
layer,
|
|
23004
|
+
feature,
|
|
23005
|
+
event: convertMapClickEvent(source),
|
|
23006
|
+
source,
|
|
23007
|
+
...createFeaturePositionOptions(feature),
|
|
23008
|
+
};
|
|
23009
|
+
return opt;
|
|
23010
|
+
}
|
|
23011
|
+
|
|
23012
|
+
class GeoJsonEvents {
|
|
23013
|
+
constructor(layer) {
|
|
23014
|
+
this.layer = layer;
|
|
23015
|
+
}
|
|
23016
|
+
handleMouseEvents(layer) {
|
|
23017
|
+
const { onClick, onLayerClick, onMouseOut, onMouseOver } = this.layer.options;
|
|
23018
|
+
// TODO: remove backward compatibility for onLayerClick
|
|
23019
|
+
const onClick_ = onClick || onLayerClick;
|
|
23020
|
+
if (onClick_) {
|
|
23021
|
+
this._onclick = (e) => {
|
|
23022
|
+
const selected = !!this.layer._getSelected(layer);
|
|
23023
|
+
onClick_({
|
|
23024
|
+
selected,
|
|
23025
|
+
...this._createMouseEvent(e),
|
|
23026
|
+
});
|
|
23027
|
+
};
|
|
23028
|
+
layer.on('click', this._onclick, this);
|
|
23029
|
+
}
|
|
23030
|
+
if (onMouseOut) {
|
|
23031
|
+
this._mouseout = (e) => {
|
|
23032
|
+
onMouseOut(this._createMouseEvent(e));
|
|
23033
|
+
};
|
|
23034
|
+
layer.on('mouseout', this._mouseout, this);
|
|
23035
|
+
}
|
|
23036
|
+
if (onMouseOver) {
|
|
23037
|
+
this._mouseover = (e) => {
|
|
23038
|
+
onMouseOver(this._createMouseEvent(e));
|
|
23039
|
+
};
|
|
23040
|
+
layer.on('mouseover', this._mouseover, this);
|
|
23041
|
+
}
|
|
23042
|
+
}
|
|
23043
|
+
stopMouseEvents(layer) {
|
|
23044
|
+
if (this._mouseover) {
|
|
23045
|
+
layer.off('mouseover', this._mouseover, this);
|
|
23046
|
+
}
|
|
23047
|
+
if (this._mouseout) {
|
|
23048
|
+
layer.off('mouseout', this._mouseout, this);
|
|
23049
|
+
}
|
|
23050
|
+
if (this._onclick) {
|
|
23051
|
+
layer.off('click', this._onclick, this);
|
|
23052
|
+
}
|
|
23053
|
+
}
|
|
23054
|
+
_createMouseEvent(source) {
|
|
23055
|
+
return createMouseEvent({
|
|
23056
|
+
layer: this.layer,
|
|
23057
|
+
source: source,
|
|
23058
|
+
});
|
|
23059
|
+
}
|
|
23060
|
+
}
|
|
23061
|
+
|
|
23062
|
+
class GeoJsonPaint {
|
|
23063
|
+
constructor(layer) {
|
|
23064
|
+
this.layer = layer;
|
|
23065
|
+
}
|
|
23066
|
+
setPaintEachLayer(paint) {
|
|
23067
|
+
this.layer._layers.forEach((layerDef) => {
|
|
23068
|
+
this.setPaint(layerDef, paint);
|
|
23069
|
+
});
|
|
23070
|
+
}
|
|
23071
|
+
setPaint(layerDef, paint) {
|
|
23072
|
+
let style = undefined;
|
|
23073
|
+
const { layer, feature } = layerDef;
|
|
23074
|
+
if (layer && feature) {
|
|
23075
|
+
if (isPaintCallback(paint)) {
|
|
23076
|
+
style = paint(feature);
|
|
23077
|
+
}
|
|
23078
|
+
else if (isPaint(paint)) {
|
|
23079
|
+
style = paint;
|
|
23080
|
+
}
|
|
23081
|
+
if (style) {
|
|
23082
|
+
if (this.layer.type === 'point' && style.type === 'icon') {
|
|
23083
|
+
const marker = layer;
|
|
23084
|
+
const divIcon = this._createDivIcon(style);
|
|
23085
|
+
setTimeout(() => {
|
|
23086
|
+
marker.setIcon(divIcon);
|
|
23087
|
+
}, 10);
|
|
23088
|
+
}
|
|
23089
|
+
else if ('setStyle' in layer) {
|
|
23090
|
+
layer.setStyle(this.preparePaint(style));
|
|
23091
|
+
}
|
|
23092
|
+
}
|
|
23093
|
+
}
|
|
23094
|
+
}
|
|
23095
|
+
preparePaint(paint) {
|
|
23096
|
+
if (paint.type !== 'get-paint') {
|
|
23097
|
+
const paintAliases = [
|
|
23098
|
+
['color', 'strokeColor'],
|
|
23099
|
+
['opacity', 'strokeOpacity'],
|
|
23100
|
+
['stroke', 'stroke'],
|
|
23101
|
+
['fillColor', 'fillColor'],
|
|
23102
|
+
['fillOpacity', 'fillOpacity'],
|
|
23103
|
+
['fill', 'fill'],
|
|
23104
|
+
['weight', 'weight'],
|
|
23105
|
+
];
|
|
23106
|
+
const aliases = this.layer.type === 'line'
|
|
23107
|
+
? [
|
|
23108
|
+
['color', 'strokeColor'],
|
|
23109
|
+
['opacity', 'strokeOpacity'],
|
|
23110
|
+
['weight', 'weight'],
|
|
23111
|
+
]
|
|
23112
|
+
: paintAliases;
|
|
23113
|
+
const readyPaint = {};
|
|
23114
|
+
if ('radius' in paint && typeof paint.radius === 'number') {
|
|
23115
|
+
readyPaint.radius = paint.radius;
|
|
23116
|
+
}
|
|
23117
|
+
for (const [to, from] of aliases) {
|
|
23118
|
+
const opacity = this.layer.options.opacity;
|
|
23119
|
+
let paintProp = paint[from];
|
|
23120
|
+
if (defined(opacity) && from.toLowerCase().indexOf('opacity') !== -1) {
|
|
23121
|
+
paintProp = Number(paintProp) * opacity;
|
|
23122
|
+
}
|
|
23123
|
+
if (paintProp !== undefined) {
|
|
23124
|
+
Object.defineProperty(readyPaint, to, {
|
|
23125
|
+
enumerable: true,
|
|
23126
|
+
value: paintProp,
|
|
23127
|
+
});
|
|
23128
|
+
}
|
|
23129
|
+
}
|
|
23130
|
+
return readyPaint;
|
|
23131
|
+
}
|
|
23132
|
+
return PAINT;
|
|
23133
|
+
}
|
|
23134
|
+
_createDivIcon(icon) {
|
|
23135
|
+
const { html, rotate, className, ...toLIconOpt } = icon;
|
|
23136
|
+
const element = document.createElement('div');
|
|
23137
|
+
if (className) {
|
|
23138
|
+
element.className = className;
|
|
23139
|
+
}
|
|
23140
|
+
if (rotate) {
|
|
23141
|
+
element.style.transform = `rotateZ(${rotate}deg)`;
|
|
23142
|
+
}
|
|
23143
|
+
if (html) {
|
|
23144
|
+
element.innerHTML = html;
|
|
23145
|
+
}
|
|
23146
|
+
const divIcon = new leafletSrc.exports.DivIcon({
|
|
23147
|
+
className: '',
|
|
23148
|
+
...toLIconOpt,
|
|
23149
|
+
html: element,
|
|
23150
|
+
});
|
|
23151
|
+
return divIcon;
|
|
23152
|
+
}
|
|
23153
|
+
createPaintToLayer(icon) {
|
|
23154
|
+
if (icon && icon.type) {
|
|
23155
|
+
if (icon.type === 'icon') {
|
|
23156
|
+
const iconClassName = icon.className;
|
|
23157
|
+
const html = icon.html;
|
|
23158
|
+
if (iconClassName || html) {
|
|
23159
|
+
return (_, latlng) => {
|
|
23160
|
+
const divIcon = this._createDivIcon(icon);
|
|
23161
|
+
return new leafletSrc.exports.Marker(latlng, { icon: divIcon });
|
|
23162
|
+
};
|
|
23163
|
+
}
|
|
23164
|
+
}
|
|
23165
|
+
else if (icon.type === 'pin') {
|
|
23166
|
+
return (_, latlng) => {
|
|
23167
|
+
return new leafletSrc.exports.Marker(latlng);
|
|
23168
|
+
};
|
|
23169
|
+
}
|
|
23170
|
+
}
|
|
23171
|
+
return (_, latlng) => {
|
|
23172
|
+
const p = PAINT;
|
|
23173
|
+
return new leafletSrc.exports.CircleMarker(latlng, this.preparePaint({ ...p, ...icon }));
|
|
23174
|
+
};
|
|
23175
|
+
}
|
|
23176
|
+
createPaintOptions(paint) {
|
|
23177
|
+
const geoJsonOptions = {};
|
|
23178
|
+
const newPaint = this.preparePaint(paint);
|
|
23179
|
+
if (paint) {
|
|
23180
|
+
geoJsonOptions.style = () => {
|
|
23181
|
+
return newPaint;
|
|
23182
|
+
};
|
|
23183
|
+
}
|
|
23184
|
+
if (this.layer.type === 'point') {
|
|
23185
|
+
geoJsonOptions.pointToLayer = this.createPaintToLayer(paint);
|
|
23186
|
+
}
|
|
23187
|
+
else if (this.layer.type === 'line') {
|
|
23188
|
+
newPaint.stroke = true;
|
|
23189
|
+
}
|
|
23190
|
+
return geoJsonOptions;
|
|
23191
|
+
}
|
|
23192
|
+
}
|
|
23193
|
+
|
|
22998
23194
|
class GeoJsonAdapter extends BaseAdapter {
|
|
22999
23195
|
constructor(map, options) {
|
|
23000
23196
|
super(map, options);
|
|
@@ -23009,6 +23205,8 @@ class GeoJsonAdapter extends BaseAdapter {
|
|
|
23009
23205
|
this.$unselect = () => {
|
|
23010
23206
|
this.unselect();
|
|
23011
23207
|
};
|
|
23208
|
+
this._events = new GeoJsonEvents(this);
|
|
23209
|
+
this._paint = new GeoJsonPaint(this);
|
|
23012
23210
|
}
|
|
23013
23211
|
addLayer(options) {
|
|
23014
23212
|
Object.assign(this.options, options);
|
|
@@ -23039,7 +23237,7 @@ class GeoJsonAdapter extends BaseAdapter {
|
|
|
23039
23237
|
else if (!this.selected) {
|
|
23040
23238
|
this.selected = true;
|
|
23041
23239
|
if (this.selectedPaint) {
|
|
23042
|
-
this.
|
|
23240
|
+
this._paint.setPaintEachLayer(this.selectedPaint);
|
|
23043
23241
|
}
|
|
23044
23242
|
}
|
|
23045
23243
|
}
|
|
@@ -23055,7 +23253,7 @@ class GeoJsonAdapter extends BaseAdapter {
|
|
|
23055
23253
|
this._removePopup(p[0]);
|
|
23056
23254
|
}
|
|
23057
23255
|
if (this.paint) {
|
|
23058
|
-
this.
|
|
23256
|
+
this._paint.setPaintEachLayer(this.paint);
|
|
23059
23257
|
}
|
|
23060
23258
|
this._selectedLayers.length = 0;
|
|
23061
23259
|
this.selected = false;
|
|
@@ -23226,7 +23424,7 @@ class GeoJsonAdapter extends BaseAdapter {
|
|
|
23226
23424
|
if (paint) {
|
|
23227
23425
|
this.paint = paint;
|
|
23228
23426
|
for (const l of this._layers) {
|
|
23229
|
-
this.
|
|
23427
|
+
this._paint.setPaint(l, paint);
|
|
23230
23428
|
}
|
|
23231
23429
|
}
|
|
23232
23430
|
}
|
|
@@ -23234,22 +23432,25 @@ class GeoJsonAdapter extends BaseAdapter {
|
|
|
23234
23432
|
if (paint) {
|
|
23235
23433
|
this.selectedPaint = paint;
|
|
23236
23434
|
for (const l of this._selectedLayers) {
|
|
23237
|
-
this.
|
|
23435
|
+
this._paint.setPaint(l, paint);
|
|
23238
23436
|
}
|
|
23239
23437
|
}
|
|
23240
23438
|
}
|
|
23241
23439
|
updatePaint(paint) {
|
|
23242
23440
|
this.paint = { ...this.paint, ...paint };
|
|
23243
23441
|
for (const l of this._layers) {
|
|
23244
|
-
this.
|
|
23442
|
+
this._paint.setPaint(l, this.paint);
|
|
23245
23443
|
}
|
|
23246
23444
|
}
|
|
23247
23445
|
updateSelectedPaint(paint) {
|
|
23248
23446
|
this.selectedPaint = { ...this.selectedPaint, ...paint };
|
|
23249
23447
|
for (const l of this._selectedLayers) {
|
|
23250
|
-
this.
|
|
23448
|
+
this._paint.setPaint(l, this.selectedPaint);
|
|
23251
23449
|
}
|
|
23252
23450
|
}
|
|
23451
|
+
_getSelected(layer) {
|
|
23452
|
+
return this._selectedLayers.find((x) => x.layer === layer);
|
|
23453
|
+
}
|
|
23253
23454
|
_updateTooltip(layerDef) {
|
|
23254
23455
|
const { feature, layer } = layerDef;
|
|
23255
23456
|
if (feature && layer && feature.properties && this.options.labelField) {
|
|
@@ -23339,77 +23540,6 @@ class GeoJsonAdapter extends BaseAdapter {
|
|
|
23339
23540
|
}
|
|
23340
23541
|
}
|
|
23341
23542
|
}
|
|
23342
|
-
_setPaintEachLayer(paint) {
|
|
23343
|
-
this._layers.forEach((l) => {
|
|
23344
|
-
this._setPaint(l, paint);
|
|
23345
|
-
});
|
|
23346
|
-
}
|
|
23347
|
-
_setPaint(def, paint) {
|
|
23348
|
-
let style = undefined;
|
|
23349
|
-
const { layer, feature } = def;
|
|
23350
|
-
if (layer && feature) {
|
|
23351
|
-
if (isPaintCallback(paint)) {
|
|
23352
|
-
style = paint(feature);
|
|
23353
|
-
}
|
|
23354
|
-
else if (isPaint(paint)) {
|
|
23355
|
-
style = paint;
|
|
23356
|
-
}
|
|
23357
|
-
if (style) {
|
|
23358
|
-
if (this.type === 'point' && style.type === 'icon') {
|
|
23359
|
-
const marker = layer;
|
|
23360
|
-
const divIcon = this._createDivIcon(style);
|
|
23361
|
-
marker.setIcon(divIcon);
|
|
23362
|
-
}
|
|
23363
|
-
else if ('setStyle' in layer) {
|
|
23364
|
-
layer.setStyle(this._preparePaint(style));
|
|
23365
|
-
}
|
|
23366
|
-
}
|
|
23367
|
-
}
|
|
23368
|
-
}
|
|
23369
|
-
_preparePaint(paint) {
|
|
23370
|
-
if (paint.type !== 'get-paint') {
|
|
23371
|
-
// const path: CircleMarkerOptions | PathOptions = paint as CircleMarkerOptions | PathOptions;
|
|
23372
|
-
// if (path.opacity) {
|
|
23373
|
-
// path.fillOpacity = path.opacity;
|
|
23374
|
-
// }
|
|
23375
|
-
const paintAliases = [
|
|
23376
|
-
// ['color', 'color'],
|
|
23377
|
-
['color', 'strokeColor'],
|
|
23378
|
-
['opacity', 'strokeOpacity'],
|
|
23379
|
-
['stroke', 'stroke'],
|
|
23380
|
-
['fillColor', 'fillColor'],
|
|
23381
|
-
['fillOpacity', 'fillOpacity'],
|
|
23382
|
-
['fill', 'fill'],
|
|
23383
|
-
['weight', 'weight'],
|
|
23384
|
-
];
|
|
23385
|
-
const aliases = this.type === 'line'
|
|
23386
|
-
? [
|
|
23387
|
-
['color', 'strokeColor'],
|
|
23388
|
-
['opacity', 'strokeOpacity'],
|
|
23389
|
-
['weight', 'weight'],
|
|
23390
|
-
]
|
|
23391
|
-
: paintAliases;
|
|
23392
|
-
const readyPaint = {};
|
|
23393
|
-
if ('radius' in paint && typeof paint.radius === 'number') {
|
|
23394
|
-
readyPaint.radius = paint.radius;
|
|
23395
|
-
}
|
|
23396
|
-
for (const [to, from] of aliases) {
|
|
23397
|
-
let paintProp = paint[from];
|
|
23398
|
-
if (defined(this.options.opacity) &&
|
|
23399
|
-
from.toLowerCase().indexOf('opacity') !== -1) {
|
|
23400
|
-
paintProp = Number(paintProp) * this.options.opacity;
|
|
23401
|
-
}
|
|
23402
|
-
if (paintProp !== undefined) {
|
|
23403
|
-
Object.defineProperty(readyPaint, to, {
|
|
23404
|
-
enumerable: true,
|
|
23405
|
-
value: paintProp,
|
|
23406
|
-
});
|
|
23407
|
-
}
|
|
23408
|
-
}
|
|
23409
|
-
return readyPaint;
|
|
23410
|
-
}
|
|
23411
|
-
return PAINT;
|
|
23412
|
-
}
|
|
23413
23543
|
_getGeoJsonOptions(options, type) {
|
|
23414
23544
|
const paint = options.paint;
|
|
23415
23545
|
let lopt = {};
|
|
@@ -23418,7 +23548,7 @@ class GeoJsonAdapter extends BaseAdapter {
|
|
|
23418
23548
|
// TODO: fix types (@geoman-io/leaflet-geoman-free)
|
|
23419
23549
|
lopt.pointToLayer = (feature, latLng) => {
|
|
23420
23550
|
const iconOpt = paint(feature);
|
|
23421
|
-
const pointToLayer = this.
|
|
23551
|
+
const pointToLayer = this._paint.createPaintToLayer(iconOpt);
|
|
23422
23552
|
return pointToLayer(feature, latLng);
|
|
23423
23553
|
};
|
|
23424
23554
|
}
|
|
@@ -23426,17 +23556,17 @@ class GeoJsonAdapter extends BaseAdapter {
|
|
|
23426
23556
|
lopt = {
|
|
23427
23557
|
style: (feature) => {
|
|
23428
23558
|
if (feature) {
|
|
23429
|
-
return this.
|
|
23559
|
+
return this._paint.preparePaint({ ...PAINT, ...paint(feature) });
|
|
23430
23560
|
}
|
|
23431
23561
|
else {
|
|
23432
|
-
return this.
|
|
23562
|
+
return this._paint.preparePaint({ ...PAINT, type: 'path' });
|
|
23433
23563
|
}
|
|
23434
23564
|
},
|
|
23435
23565
|
};
|
|
23436
23566
|
}
|
|
23437
23567
|
}
|
|
23438
23568
|
else {
|
|
23439
|
-
lopt = this.
|
|
23569
|
+
lopt = this._paint.createPaintOptions(paint);
|
|
23440
23570
|
}
|
|
23441
23571
|
lopt.onEachFeature = (feature, layer) => {
|
|
23442
23572
|
this._onEachFeature(feature, layer);
|
|
@@ -23452,7 +23582,6 @@ class GeoJsonAdapter extends BaseAdapter {
|
|
|
23452
23582
|
layer,
|
|
23453
23583
|
...createFeaturePositionOptions(feature),
|
|
23454
23584
|
};
|
|
23455
|
-
// @ts-ignore
|
|
23456
23585
|
layer.options.pane = this.pane;
|
|
23457
23586
|
this._layers.push(def);
|
|
23458
23587
|
let ok = true;
|
|
@@ -23477,7 +23606,7 @@ class GeoJsonAdapter extends BaseAdapter {
|
|
|
23477
23606
|
layer.on('click', (e) => this._selectOnLayerClick(e), this);
|
|
23478
23607
|
}
|
|
23479
23608
|
}
|
|
23480
|
-
this.
|
|
23609
|
+
this._events.handleMouseEvents(layer);
|
|
23481
23610
|
// The timeout is needed to display the popup immediately when adding a layer to the map.
|
|
23482
23611
|
// Without a timeout, the layer may not yet have a _map object
|
|
23483
23612
|
setTimeout(() => {
|
|
@@ -23494,39 +23623,6 @@ class GeoJsonAdapter extends BaseAdapter {
|
|
|
23494
23623
|
}
|
|
23495
23624
|
}
|
|
23496
23625
|
}
|
|
23497
|
-
_handleMouseEvents(layer) {
|
|
23498
|
-
const { onClick, onLayerClick, onMouseOut, onMouseOver } = this.options;
|
|
23499
|
-
// TODO: remove backward compatibility for onLayerClick
|
|
23500
|
-
const onClick_ = onClick || onLayerClick;
|
|
23501
|
-
if (onClick_) {
|
|
23502
|
-
layer.on('click', (e) => {
|
|
23503
|
-
const selected = !!this._getSelected(layer);
|
|
23504
|
-
onClick_({
|
|
23505
|
-
selected,
|
|
23506
|
-
...this._createMouseEvent(e),
|
|
23507
|
-
});
|
|
23508
|
-
}, this);
|
|
23509
|
-
}
|
|
23510
|
-
if (onMouseOut) {
|
|
23511
|
-
layer.on('mouseout', (e) => {
|
|
23512
|
-
onMouseOut(this._createMouseEvent(e));
|
|
23513
|
-
}, this);
|
|
23514
|
-
}
|
|
23515
|
-
if (onMouseOver) {
|
|
23516
|
-
layer.on('mouseover', (e) => {
|
|
23517
|
-
onMouseOver(this._createMouseEvent(e));
|
|
23518
|
-
}, this);
|
|
23519
|
-
}
|
|
23520
|
-
}
|
|
23521
|
-
_createMouseEvent(source) {
|
|
23522
|
-
return createMouseEvent({
|
|
23523
|
-
layer: this,
|
|
23524
|
-
source: source,
|
|
23525
|
-
});
|
|
23526
|
-
}
|
|
23527
|
-
_getSelected(layer) {
|
|
23528
|
-
return this._selectedLayers.find((x) => x.layer === layer);
|
|
23529
|
-
}
|
|
23530
23626
|
_selectOnLayerClick(e) {
|
|
23531
23627
|
leafletSrc.exports.DomEvent.stopPropagation(e);
|
|
23532
23628
|
const layer = e.target;
|
|
@@ -23560,7 +23656,7 @@ class GeoJsonAdapter extends BaseAdapter {
|
|
|
23560
23656
|
this.selected = true;
|
|
23561
23657
|
const { selectedPaint, popupOnSelect, popupOptions } = this.options;
|
|
23562
23658
|
if (selectedPaint && def.layer) {
|
|
23563
|
-
this.
|
|
23659
|
+
this._paint.setPaint(def, selectedPaint);
|
|
23564
23660
|
}
|
|
23565
23661
|
if (popupOnSelect) {
|
|
23566
23662
|
this._openPopup(def, popupOptions, type, latlng);
|
|
@@ -23581,7 +23677,7 @@ class GeoJsonAdapter extends BaseAdapter {
|
|
|
23581
23677
|
this._selectedLayers.splice(index, 1);
|
|
23582
23678
|
if (this.options) {
|
|
23583
23679
|
if (this.options.paint) {
|
|
23584
|
-
this.
|
|
23680
|
+
this._paint.setPaint(def, this.options.paint);
|
|
23585
23681
|
}
|
|
23586
23682
|
if (this.options.popupOnSelect && def.layer) {
|
|
23587
23683
|
this._removePopup(def.layer);
|
|
@@ -23590,50 +23686,6 @@ class GeoJsonAdapter extends BaseAdapter {
|
|
|
23590
23686
|
}
|
|
23591
23687
|
this.selected = this._selectedLayers.length > 0;
|
|
23592
23688
|
}
|
|
23593
|
-
_createDivIcon(icon) {
|
|
23594
|
-
const { ...toLIconOpt } = icon;
|
|
23595
|
-
return new leafletSrc.exports.DivIcon({ className: '', ...toLIconOpt });
|
|
23596
|
-
}
|
|
23597
|
-
_createPaintToLayer(icon) {
|
|
23598
|
-
if (icon && icon.type) {
|
|
23599
|
-
if (icon.type === 'icon') {
|
|
23600
|
-
const iconClassName = icon.className;
|
|
23601
|
-
const html = icon.html;
|
|
23602
|
-
if (iconClassName || html) {
|
|
23603
|
-
return (geoJsonPoint, latlng) => {
|
|
23604
|
-
const divIcon = this._createDivIcon(icon);
|
|
23605
|
-
return new leafletSrc.exports.Marker(latlng, { icon: divIcon });
|
|
23606
|
-
};
|
|
23607
|
-
}
|
|
23608
|
-
}
|
|
23609
|
-
else if (icon.type === 'pin') {
|
|
23610
|
-
return (geoJsonPoint, latlng) => {
|
|
23611
|
-
// const divIcon = this.createDivIcon(icon);
|
|
23612
|
-
return new leafletSrc.exports.Marker(latlng);
|
|
23613
|
-
};
|
|
23614
|
-
}
|
|
23615
|
-
}
|
|
23616
|
-
return (geoJsonPoint, latlng) => {
|
|
23617
|
-
const p = PAINT;
|
|
23618
|
-
return new leafletSrc.exports.CircleMarker(latlng, this._preparePaint({ ...p, ...icon }));
|
|
23619
|
-
};
|
|
23620
|
-
}
|
|
23621
|
-
_createPaintOptions(paintOptions, type) {
|
|
23622
|
-
const geoJsonOptions = {};
|
|
23623
|
-
const paint = (paintOptions && this._preparePaint(paintOptions)) || {};
|
|
23624
|
-
if (paintOptions) {
|
|
23625
|
-
geoJsonOptions.style = () => {
|
|
23626
|
-
return paint;
|
|
23627
|
-
};
|
|
23628
|
-
}
|
|
23629
|
-
if (type === 'point') {
|
|
23630
|
-
geoJsonOptions.pointToLayer = this._createPaintToLayer(paintOptions);
|
|
23631
|
-
}
|
|
23632
|
-
else if (type === 'line') {
|
|
23633
|
-
paint.stroke = true;
|
|
23634
|
-
}
|
|
23635
|
-
return geoJsonOptions;
|
|
23636
|
-
}
|
|
23637
23689
|
_addMapClickListener() {
|
|
23638
23690
|
const map = this.map;
|
|
23639
23691
|
if (map) {
|