@nextgis/leaflet-map-adapter 1.18.1 → 1.18.6
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/leaflet-map-adapter.esm-browser.js +227 -189
- package/lib/leaflet-map-adapter.esm-browser.js.map +1 -1
- package/lib/leaflet-map-adapter.esm-browser.prod.js +2 -2
- package/lib/leaflet-map-adapter.esm-browser.prod.js.map +1 -1
- package/lib/leaflet-map-adapter.esm-bundler.js +216 -178
- package/lib/leaflet-map-adapter.esm-bundler.js.map +1 -1
- package/lib/leaflet-map-adapter.esm-bundler.prod.js +2 -2
- package/lib/leaflet-map-adapter.esm-bundler.prod.js.map +1 -1
- package/lib/leaflet-map-adapter.global.js +221 -185
- package/lib/leaflet-map-adapter.global.js.map +1 -1
- package/lib/leaflet-map-adapter.global.prod.js +2 -2
- package/lib/leaflet-map-adapter.global.prod.js.map +1 -1
- package/package.json +4 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** Bundle of @nextgis/leaflet-map-adapter; version: 1.18.
|
|
1
|
+
/** Bundle of @nextgis/leaflet-map-adapter; version: 1.18.6; author: NextGIS */
|
|
2
2
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
3
3
|
|
|
4
4
|
var events = {exports: {}};
|
|
@@ -14681,19 +14681,6 @@ function debounce(cb, wait = 10) {
|
|
|
14681
14681
|
return wrapper;
|
|
14682
14682
|
}
|
|
14683
14683
|
|
|
14684
|
-
function isPaint(paint) {
|
|
14685
|
-
if (Object.prototype.toString.call(paint) === '[object Object]') {
|
|
14686
|
-
return true;
|
|
14687
|
-
}
|
|
14688
|
-
return false;
|
|
14689
|
-
}
|
|
14690
|
-
function isPaintCallback(paint) {
|
|
14691
|
-
if (typeof paint === 'function') {
|
|
14692
|
-
return true;
|
|
14693
|
-
}
|
|
14694
|
-
return false;
|
|
14695
|
-
}
|
|
14696
|
-
|
|
14697
14684
|
function boundsToArray(bounds) {
|
|
14698
14685
|
const ne = bounds.getNorthEast();
|
|
14699
14686
|
const sw = bounds.getSouthWest();
|
|
@@ -14761,19 +14748,6 @@ function createFeaturePositionOptions(features) {
|
|
|
14761
14748
|
};
|
|
14762
14749
|
}
|
|
14763
14750
|
|
|
14764
|
-
function createMouseEvent({ layer, source, }) {
|
|
14765
|
-
const layer_ = source.target;
|
|
14766
|
-
const feature = layer_.feature;
|
|
14767
|
-
const opt = {
|
|
14768
|
-
layer,
|
|
14769
|
-
feature,
|
|
14770
|
-
event: convertMapClickEvent(source),
|
|
14771
|
-
source,
|
|
14772
|
-
...createFeaturePositionOptions(feature),
|
|
14773
|
-
};
|
|
14774
|
-
return opt;
|
|
14775
|
-
}
|
|
14776
|
-
|
|
14777
14751
|
function findMostFrequentGeomType(arr) {
|
|
14778
14752
|
const counts = {};
|
|
14779
14753
|
for (let fry = 0; fry < arr.length; fry++) {
|
|
@@ -14828,6 +14802,214 @@ class BaseAdapter {
|
|
|
14828
14802
|
}
|
|
14829
14803
|
}
|
|
14830
14804
|
|
|
14805
|
+
function createMouseEvent({ layer, source, }) {
|
|
14806
|
+
const layer_ = source.target;
|
|
14807
|
+
const feature = layer_.feature;
|
|
14808
|
+
const opt = {
|
|
14809
|
+
layer,
|
|
14810
|
+
feature,
|
|
14811
|
+
event: convertMapClickEvent(source),
|
|
14812
|
+
source,
|
|
14813
|
+
...createFeaturePositionOptions(feature),
|
|
14814
|
+
};
|
|
14815
|
+
return opt;
|
|
14816
|
+
}
|
|
14817
|
+
|
|
14818
|
+
class GeoJsonEvents {
|
|
14819
|
+
constructor(layer) {
|
|
14820
|
+
this.layer = layer;
|
|
14821
|
+
}
|
|
14822
|
+
handleMouseEvents(layer) {
|
|
14823
|
+
const { onClick, onLayerClick, onMouseOut, onMouseOver } = this.layer.options;
|
|
14824
|
+
// TODO: remove backward compatibility for onLayerClick
|
|
14825
|
+
const onClick_ = onClick || onLayerClick;
|
|
14826
|
+
if (onClick_) {
|
|
14827
|
+
this._onclick = (e) => {
|
|
14828
|
+
const selected = !!this.layer._getSelected(layer);
|
|
14829
|
+
onClick_({
|
|
14830
|
+
selected,
|
|
14831
|
+
...this._createMouseEvent(e),
|
|
14832
|
+
});
|
|
14833
|
+
};
|
|
14834
|
+
layer.on('click', this._onclick, this);
|
|
14835
|
+
}
|
|
14836
|
+
if (onMouseOut) {
|
|
14837
|
+
this._mouseout = (e) => {
|
|
14838
|
+
onMouseOut(this._createMouseEvent(e));
|
|
14839
|
+
};
|
|
14840
|
+
layer.on('mouseout', this._mouseout, this);
|
|
14841
|
+
}
|
|
14842
|
+
if (onMouseOver) {
|
|
14843
|
+
this._mouseover = (e) => {
|
|
14844
|
+
onMouseOver(this._createMouseEvent(e));
|
|
14845
|
+
};
|
|
14846
|
+
layer.on('mouseover', this._mouseover, this);
|
|
14847
|
+
}
|
|
14848
|
+
}
|
|
14849
|
+
stopMouseEvents(layer) {
|
|
14850
|
+
if (this._mouseover) {
|
|
14851
|
+
layer.off('mouseover', this._mouseover, this);
|
|
14852
|
+
}
|
|
14853
|
+
if (this._mouseout) {
|
|
14854
|
+
layer.off('mouseout', this._mouseout, this);
|
|
14855
|
+
}
|
|
14856
|
+
if (this._onclick) {
|
|
14857
|
+
layer.off('click', this._onclick, this);
|
|
14858
|
+
}
|
|
14859
|
+
}
|
|
14860
|
+
_createMouseEvent(source) {
|
|
14861
|
+
return createMouseEvent({
|
|
14862
|
+
layer: this.layer,
|
|
14863
|
+
source: source,
|
|
14864
|
+
});
|
|
14865
|
+
}
|
|
14866
|
+
}
|
|
14867
|
+
|
|
14868
|
+
function isPaint(paint) {
|
|
14869
|
+
if (Object.prototype.toString.call(paint) === '[object Object]') {
|
|
14870
|
+
return true;
|
|
14871
|
+
}
|
|
14872
|
+
return false;
|
|
14873
|
+
}
|
|
14874
|
+
function isPaintCallback(paint) {
|
|
14875
|
+
if (typeof paint === 'function') {
|
|
14876
|
+
return true;
|
|
14877
|
+
}
|
|
14878
|
+
return false;
|
|
14879
|
+
}
|
|
14880
|
+
|
|
14881
|
+
class GeoJsonPaint {
|
|
14882
|
+
constructor(layer) {
|
|
14883
|
+
this.layer = layer;
|
|
14884
|
+
}
|
|
14885
|
+
setPaintEachLayer(paint) {
|
|
14886
|
+
this.layer._layers.forEach((layerDef) => {
|
|
14887
|
+
this.setPaint(layerDef, paint);
|
|
14888
|
+
});
|
|
14889
|
+
}
|
|
14890
|
+
setPaint(layerDef, paint) {
|
|
14891
|
+
let style = undefined;
|
|
14892
|
+
const { layer, feature } = layerDef;
|
|
14893
|
+
if (layer && feature) {
|
|
14894
|
+
if (isPaintCallback(paint)) {
|
|
14895
|
+
style = paint(feature);
|
|
14896
|
+
}
|
|
14897
|
+
else if (isPaint(paint)) {
|
|
14898
|
+
style = paint;
|
|
14899
|
+
}
|
|
14900
|
+
if (style) {
|
|
14901
|
+
if (this.layer.type === 'point' && style.type === 'icon') {
|
|
14902
|
+
const marker = layer;
|
|
14903
|
+
const divIcon = this._createDivIcon(style);
|
|
14904
|
+
setTimeout(() => {
|
|
14905
|
+
marker.setIcon(divIcon);
|
|
14906
|
+
}, 10);
|
|
14907
|
+
}
|
|
14908
|
+
else if ('setStyle' in layer) {
|
|
14909
|
+
layer.setStyle(this.preparePaint(style));
|
|
14910
|
+
}
|
|
14911
|
+
}
|
|
14912
|
+
}
|
|
14913
|
+
}
|
|
14914
|
+
preparePaint(paint) {
|
|
14915
|
+
if (paint.type !== 'get-paint') {
|
|
14916
|
+
const paintAliases = [
|
|
14917
|
+
['color', 'strokeColor'],
|
|
14918
|
+
['opacity', 'strokeOpacity'],
|
|
14919
|
+
['stroke', 'stroke'],
|
|
14920
|
+
['fillColor', 'fillColor'],
|
|
14921
|
+
['fillOpacity', 'fillOpacity'],
|
|
14922
|
+
['fill', 'fill'],
|
|
14923
|
+
['weight', 'weight'],
|
|
14924
|
+
];
|
|
14925
|
+
const aliases = this.layer.type === 'line'
|
|
14926
|
+
? [
|
|
14927
|
+
['color', 'strokeColor'],
|
|
14928
|
+
['opacity', 'strokeOpacity'],
|
|
14929
|
+
['weight', 'weight'],
|
|
14930
|
+
]
|
|
14931
|
+
: paintAliases;
|
|
14932
|
+
const readyPaint = {};
|
|
14933
|
+
if ('radius' in paint && typeof paint.radius === 'number') {
|
|
14934
|
+
readyPaint.radius = paint.radius;
|
|
14935
|
+
}
|
|
14936
|
+
for (const [to, from] of aliases) {
|
|
14937
|
+
const opacity = this.layer.options.opacity;
|
|
14938
|
+
let paintProp = paint[from];
|
|
14939
|
+
if (defined(opacity) && from.toLowerCase().indexOf('opacity') !== -1) {
|
|
14940
|
+
paintProp = Number(paintProp) * opacity;
|
|
14941
|
+
}
|
|
14942
|
+
if (paintProp !== undefined) {
|
|
14943
|
+
Object.defineProperty(readyPaint, to, {
|
|
14944
|
+
enumerable: true,
|
|
14945
|
+
value: paintProp,
|
|
14946
|
+
});
|
|
14947
|
+
}
|
|
14948
|
+
}
|
|
14949
|
+
return readyPaint;
|
|
14950
|
+
}
|
|
14951
|
+
return PAINT;
|
|
14952
|
+
}
|
|
14953
|
+
_createDivIcon(icon) {
|
|
14954
|
+
const { html, rotate, className, ...toLIconOpt } = icon;
|
|
14955
|
+
const element = document.createElement('div');
|
|
14956
|
+
if (className) {
|
|
14957
|
+
element.className = className;
|
|
14958
|
+
}
|
|
14959
|
+
if (rotate) {
|
|
14960
|
+
element.style.transform = `rotateZ(${rotate}deg)`;
|
|
14961
|
+
}
|
|
14962
|
+
if (html) {
|
|
14963
|
+
element.innerHTML = html;
|
|
14964
|
+
}
|
|
14965
|
+
const divIcon = new leafletSrc.exports.DivIcon({
|
|
14966
|
+
className: '',
|
|
14967
|
+
...toLIconOpt,
|
|
14968
|
+
html: element,
|
|
14969
|
+
});
|
|
14970
|
+
return divIcon;
|
|
14971
|
+
}
|
|
14972
|
+
createPaintToLayer(icon) {
|
|
14973
|
+
if (icon && icon.type) {
|
|
14974
|
+
if (icon.type === 'icon') {
|
|
14975
|
+
const iconClassName = icon.className;
|
|
14976
|
+
const html = icon.html;
|
|
14977
|
+
if (iconClassName || html) {
|
|
14978
|
+
return (_, latlng) => {
|
|
14979
|
+
const divIcon = this._createDivIcon(icon);
|
|
14980
|
+
return new leafletSrc.exports.Marker(latlng, { icon: divIcon });
|
|
14981
|
+
};
|
|
14982
|
+
}
|
|
14983
|
+
}
|
|
14984
|
+
else if (icon.type === 'pin') {
|
|
14985
|
+
return (_, latlng) => {
|
|
14986
|
+
return new leafletSrc.exports.Marker(latlng);
|
|
14987
|
+
};
|
|
14988
|
+
}
|
|
14989
|
+
}
|
|
14990
|
+
return (_, latlng) => {
|
|
14991
|
+
const p = PAINT;
|
|
14992
|
+
return new leafletSrc.exports.CircleMarker(latlng, this.preparePaint({ ...p, ...icon }));
|
|
14993
|
+
};
|
|
14994
|
+
}
|
|
14995
|
+
createPaintOptions(paint) {
|
|
14996
|
+
const geoJsonOptions = {};
|
|
14997
|
+
const newPaint = this.preparePaint(paint);
|
|
14998
|
+
if (paint) {
|
|
14999
|
+
geoJsonOptions.style = () => {
|
|
15000
|
+
return newPaint;
|
|
15001
|
+
};
|
|
15002
|
+
}
|
|
15003
|
+
if (this.layer.type === 'point') {
|
|
15004
|
+
geoJsonOptions.pointToLayer = this.createPaintToLayer(paint);
|
|
15005
|
+
}
|
|
15006
|
+
else if (this.layer.type === 'line') {
|
|
15007
|
+
newPaint.stroke = true;
|
|
15008
|
+
}
|
|
15009
|
+
return geoJsonOptions;
|
|
15010
|
+
}
|
|
15011
|
+
}
|
|
15012
|
+
|
|
14831
15013
|
class GeoJsonAdapter extends BaseAdapter {
|
|
14832
15014
|
constructor(map, options) {
|
|
14833
15015
|
super(map, options);
|
|
@@ -14842,6 +15024,8 @@ class GeoJsonAdapter extends BaseAdapter {
|
|
|
14842
15024
|
this.$unselect = () => {
|
|
14843
15025
|
this.unselect();
|
|
14844
15026
|
};
|
|
15027
|
+
this._events = new GeoJsonEvents(this);
|
|
15028
|
+
this._paint = new GeoJsonPaint(this);
|
|
14845
15029
|
}
|
|
14846
15030
|
addLayer(options) {
|
|
14847
15031
|
Object.assign(this.options, options);
|
|
@@ -14872,7 +15056,7 @@ class GeoJsonAdapter extends BaseAdapter {
|
|
|
14872
15056
|
else if (!this.selected) {
|
|
14873
15057
|
this.selected = true;
|
|
14874
15058
|
if (this.selectedPaint) {
|
|
14875
|
-
this.
|
|
15059
|
+
this._paint.setPaintEachLayer(this.selectedPaint);
|
|
14876
15060
|
}
|
|
14877
15061
|
}
|
|
14878
15062
|
}
|
|
@@ -14888,7 +15072,7 @@ class GeoJsonAdapter extends BaseAdapter {
|
|
|
14888
15072
|
this._removePopup(p[0]);
|
|
14889
15073
|
}
|
|
14890
15074
|
if (this.paint) {
|
|
14891
|
-
this.
|
|
15075
|
+
this._paint.setPaintEachLayer(this.paint);
|
|
14892
15076
|
}
|
|
14893
15077
|
this._selectedLayers.length = 0;
|
|
14894
15078
|
this.selected = false;
|
|
@@ -15059,7 +15243,7 @@ class GeoJsonAdapter extends BaseAdapter {
|
|
|
15059
15243
|
if (paint) {
|
|
15060
15244
|
this.paint = paint;
|
|
15061
15245
|
for (const l of this._layers) {
|
|
15062
|
-
this.
|
|
15246
|
+
this._paint.setPaint(l, paint);
|
|
15063
15247
|
}
|
|
15064
15248
|
}
|
|
15065
15249
|
}
|
|
@@ -15067,22 +15251,25 @@ class GeoJsonAdapter extends BaseAdapter {
|
|
|
15067
15251
|
if (paint) {
|
|
15068
15252
|
this.selectedPaint = paint;
|
|
15069
15253
|
for (const l of this._selectedLayers) {
|
|
15070
|
-
this.
|
|
15254
|
+
this._paint.setPaint(l, paint);
|
|
15071
15255
|
}
|
|
15072
15256
|
}
|
|
15073
15257
|
}
|
|
15074
15258
|
updatePaint(paint) {
|
|
15075
15259
|
this.paint = { ...this.paint, ...paint };
|
|
15076
15260
|
for (const l of this._layers) {
|
|
15077
|
-
this.
|
|
15261
|
+
this._paint.setPaint(l, this.paint);
|
|
15078
15262
|
}
|
|
15079
15263
|
}
|
|
15080
15264
|
updateSelectedPaint(paint) {
|
|
15081
15265
|
this.selectedPaint = { ...this.selectedPaint, ...paint };
|
|
15082
15266
|
for (const l of this._selectedLayers) {
|
|
15083
|
-
this.
|
|
15267
|
+
this._paint.setPaint(l, this.selectedPaint);
|
|
15084
15268
|
}
|
|
15085
15269
|
}
|
|
15270
|
+
_getSelected(layer) {
|
|
15271
|
+
return this._selectedLayers.find((x) => x.layer === layer);
|
|
15272
|
+
}
|
|
15086
15273
|
_updateTooltip(layerDef) {
|
|
15087
15274
|
const { feature, layer } = layerDef;
|
|
15088
15275
|
if (feature && layer && feature.properties && this.options.labelField) {
|
|
@@ -15172,77 +15359,6 @@ class GeoJsonAdapter extends BaseAdapter {
|
|
|
15172
15359
|
}
|
|
15173
15360
|
}
|
|
15174
15361
|
}
|
|
15175
|
-
_setPaintEachLayer(paint) {
|
|
15176
|
-
this._layers.forEach((l) => {
|
|
15177
|
-
this._setPaint(l, paint);
|
|
15178
|
-
});
|
|
15179
|
-
}
|
|
15180
|
-
_setPaint(def, paint) {
|
|
15181
|
-
let style = undefined;
|
|
15182
|
-
const { layer, feature } = def;
|
|
15183
|
-
if (layer && feature) {
|
|
15184
|
-
if (isPaintCallback(paint)) {
|
|
15185
|
-
style = paint(feature);
|
|
15186
|
-
}
|
|
15187
|
-
else if (isPaint(paint)) {
|
|
15188
|
-
style = paint;
|
|
15189
|
-
}
|
|
15190
|
-
if (style) {
|
|
15191
|
-
if (this.type === 'point' && style.type === 'icon') {
|
|
15192
|
-
const marker = layer;
|
|
15193
|
-
const divIcon = this._createDivIcon(style);
|
|
15194
|
-
marker.setIcon(divIcon);
|
|
15195
|
-
}
|
|
15196
|
-
else if ('setStyle' in layer) {
|
|
15197
|
-
layer.setStyle(this._preparePaint(style));
|
|
15198
|
-
}
|
|
15199
|
-
}
|
|
15200
|
-
}
|
|
15201
|
-
}
|
|
15202
|
-
_preparePaint(paint) {
|
|
15203
|
-
if (paint.type !== 'get-paint') {
|
|
15204
|
-
// const path: CircleMarkerOptions | PathOptions = paint as CircleMarkerOptions | PathOptions;
|
|
15205
|
-
// if (path.opacity) {
|
|
15206
|
-
// path.fillOpacity = path.opacity;
|
|
15207
|
-
// }
|
|
15208
|
-
const paintAliases = [
|
|
15209
|
-
// ['color', 'color'],
|
|
15210
|
-
['color', 'strokeColor'],
|
|
15211
|
-
['opacity', 'strokeOpacity'],
|
|
15212
|
-
['stroke', 'stroke'],
|
|
15213
|
-
['fillColor', 'fillColor'],
|
|
15214
|
-
['fillOpacity', 'fillOpacity'],
|
|
15215
|
-
['fill', 'fill'],
|
|
15216
|
-
['weight', 'weight'],
|
|
15217
|
-
];
|
|
15218
|
-
const aliases = this.type === 'line'
|
|
15219
|
-
? [
|
|
15220
|
-
['color', 'strokeColor'],
|
|
15221
|
-
['opacity', 'strokeOpacity'],
|
|
15222
|
-
['weight', 'weight'],
|
|
15223
|
-
]
|
|
15224
|
-
: paintAliases;
|
|
15225
|
-
const readyPaint = {};
|
|
15226
|
-
if ('radius' in paint && typeof paint.radius === 'number') {
|
|
15227
|
-
readyPaint.radius = paint.radius;
|
|
15228
|
-
}
|
|
15229
|
-
for (const [to, from] of aliases) {
|
|
15230
|
-
let paintProp = paint[from];
|
|
15231
|
-
if (defined(this.options.opacity) &&
|
|
15232
|
-
from.toLowerCase().indexOf('opacity') !== -1) {
|
|
15233
|
-
paintProp = Number(paintProp) * this.options.opacity;
|
|
15234
|
-
}
|
|
15235
|
-
if (paintProp !== undefined) {
|
|
15236
|
-
Object.defineProperty(readyPaint, to, {
|
|
15237
|
-
enumerable: true,
|
|
15238
|
-
value: paintProp,
|
|
15239
|
-
});
|
|
15240
|
-
}
|
|
15241
|
-
}
|
|
15242
|
-
return readyPaint;
|
|
15243
|
-
}
|
|
15244
|
-
return PAINT;
|
|
15245
|
-
}
|
|
15246
15362
|
_getGeoJsonOptions(options, type) {
|
|
15247
15363
|
const paint = options.paint;
|
|
15248
15364
|
let lopt = {};
|
|
@@ -15251,7 +15367,7 @@ class GeoJsonAdapter extends BaseAdapter {
|
|
|
15251
15367
|
// TODO: fix types (@geoman-io/leaflet-geoman-free)
|
|
15252
15368
|
lopt.pointToLayer = (feature, latLng) => {
|
|
15253
15369
|
const iconOpt = paint(feature);
|
|
15254
|
-
const pointToLayer = this.
|
|
15370
|
+
const pointToLayer = this._paint.createPaintToLayer(iconOpt);
|
|
15255
15371
|
return pointToLayer(feature, latLng);
|
|
15256
15372
|
};
|
|
15257
15373
|
}
|
|
@@ -15259,17 +15375,17 @@ class GeoJsonAdapter extends BaseAdapter {
|
|
|
15259
15375
|
lopt = {
|
|
15260
15376
|
style: (feature) => {
|
|
15261
15377
|
if (feature) {
|
|
15262
|
-
return this.
|
|
15378
|
+
return this._paint.preparePaint({ ...PAINT, ...paint(feature) });
|
|
15263
15379
|
}
|
|
15264
15380
|
else {
|
|
15265
|
-
return this.
|
|
15381
|
+
return this._paint.preparePaint({ ...PAINT, type: 'path' });
|
|
15266
15382
|
}
|
|
15267
15383
|
},
|
|
15268
15384
|
};
|
|
15269
15385
|
}
|
|
15270
15386
|
}
|
|
15271
15387
|
else {
|
|
15272
|
-
lopt = this.
|
|
15388
|
+
lopt = this._paint.createPaintOptions(paint);
|
|
15273
15389
|
}
|
|
15274
15390
|
lopt.onEachFeature = (feature, layer) => {
|
|
15275
15391
|
this._onEachFeature(feature, layer);
|
|
@@ -15285,7 +15401,6 @@ class GeoJsonAdapter extends BaseAdapter {
|
|
|
15285
15401
|
layer,
|
|
15286
15402
|
...createFeaturePositionOptions(feature),
|
|
15287
15403
|
};
|
|
15288
|
-
// @ts-ignore
|
|
15289
15404
|
layer.options.pane = this.pane;
|
|
15290
15405
|
this._layers.push(def);
|
|
15291
15406
|
let ok = true;
|
|
@@ -15310,7 +15425,7 @@ class GeoJsonAdapter extends BaseAdapter {
|
|
|
15310
15425
|
layer.on('click', (e) => this._selectOnLayerClick(e), this);
|
|
15311
15426
|
}
|
|
15312
15427
|
}
|
|
15313
|
-
this.
|
|
15428
|
+
this._events.handleMouseEvents(layer);
|
|
15314
15429
|
// The timeout is needed to display the popup immediately when adding a layer to the map.
|
|
15315
15430
|
// Without a timeout, the layer may not yet have a _map object
|
|
15316
15431
|
setTimeout(() => {
|
|
@@ -15327,39 +15442,6 @@ class GeoJsonAdapter extends BaseAdapter {
|
|
|
15327
15442
|
}
|
|
15328
15443
|
}
|
|
15329
15444
|
}
|
|
15330
|
-
_handleMouseEvents(layer) {
|
|
15331
|
-
const { onClick, onLayerClick, onMouseOut, onMouseOver } = this.options;
|
|
15332
|
-
// TODO: remove backward compatibility for onLayerClick
|
|
15333
|
-
const onClick_ = onClick || onLayerClick;
|
|
15334
|
-
if (onClick_) {
|
|
15335
|
-
layer.on('click', (e) => {
|
|
15336
|
-
const selected = !!this._getSelected(layer);
|
|
15337
|
-
onClick_({
|
|
15338
|
-
selected,
|
|
15339
|
-
...this._createMouseEvent(e),
|
|
15340
|
-
});
|
|
15341
|
-
}, this);
|
|
15342
|
-
}
|
|
15343
|
-
if (onMouseOut) {
|
|
15344
|
-
layer.on('mouseout', (e) => {
|
|
15345
|
-
onMouseOut(this._createMouseEvent(e));
|
|
15346
|
-
}, this);
|
|
15347
|
-
}
|
|
15348
|
-
if (onMouseOver) {
|
|
15349
|
-
layer.on('mouseover', (e) => {
|
|
15350
|
-
onMouseOver(this._createMouseEvent(e));
|
|
15351
|
-
}, this);
|
|
15352
|
-
}
|
|
15353
|
-
}
|
|
15354
|
-
_createMouseEvent(source) {
|
|
15355
|
-
return createMouseEvent({
|
|
15356
|
-
layer: this,
|
|
15357
|
-
source: source,
|
|
15358
|
-
});
|
|
15359
|
-
}
|
|
15360
|
-
_getSelected(layer) {
|
|
15361
|
-
return this._selectedLayers.find((x) => x.layer === layer);
|
|
15362
|
-
}
|
|
15363
15445
|
_selectOnLayerClick(e) {
|
|
15364
15446
|
leafletSrc.exports.DomEvent.stopPropagation(e);
|
|
15365
15447
|
const layer = e.target;
|
|
@@ -15393,7 +15475,7 @@ class GeoJsonAdapter extends BaseAdapter {
|
|
|
15393
15475
|
this.selected = true;
|
|
15394
15476
|
const { selectedPaint, popupOnSelect, popupOptions } = this.options;
|
|
15395
15477
|
if (selectedPaint && def.layer) {
|
|
15396
|
-
this.
|
|
15478
|
+
this._paint.setPaint(def, selectedPaint);
|
|
15397
15479
|
}
|
|
15398
15480
|
if (popupOnSelect) {
|
|
15399
15481
|
this._openPopup(def, popupOptions, type, latlng);
|
|
@@ -15414,7 +15496,7 @@ class GeoJsonAdapter extends BaseAdapter {
|
|
|
15414
15496
|
this._selectedLayers.splice(index, 1);
|
|
15415
15497
|
if (this.options) {
|
|
15416
15498
|
if (this.options.paint) {
|
|
15417
|
-
this.
|
|
15499
|
+
this._paint.setPaint(def, this.options.paint);
|
|
15418
15500
|
}
|
|
15419
15501
|
if (this.options.popupOnSelect && def.layer) {
|
|
15420
15502
|
this._removePopup(def.layer);
|
|
@@ -15423,50 +15505,6 @@ class GeoJsonAdapter extends BaseAdapter {
|
|
|
15423
15505
|
}
|
|
15424
15506
|
this.selected = this._selectedLayers.length > 0;
|
|
15425
15507
|
}
|
|
15426
|
-
_createDivIcon(icon) {
|
|
15427
|
-
const { ...toLIconOpt } = icon;
|
|
15428
|
-
return new leafletSrc.exports.DivIcon({ className: '', ...toLIconOpt });
|
|
15429
|
-
}
|
|
15430
|
-
_createPaintToLayer(icon) {
|
|
15431
|
-
if (icon && icon.type) {
|
|
15432
|
-
if (icon.type === 'icon') {
|
|
15433
|
-
const iconClassName = icon.className;
|
|
15434
|
-
const html = icon.html;
|
|
15435
|
-
if (iconClassName || html) {
|
|
15436
|
-
return (geoJsonPoint, latlng) => {
|
|
15437
|
-
const divIcon = this._createDivIcon(icon);
|
|
15438
|
-
return new leafletSrc.exports.Marker(latlng, { icon: divIcon });
|
|
15439
|
-
};
|
|
15440
|
-
}
|
|
15441
|
-
}
|
|
15442
|
-
else if (icon.type === 'pin') {
|
|
15443
|
-
return (geoJsonPoint, latlng) => {
|
|
15444
|
-
// const divIcon = this.createDivIcon(icon);
|
|
15445
|
-
return new leafletSrc.exports.Marker(latlng);
|
|
15446
|
-
};
|
|
15447
|
-
}
|
|
15448
|
-
}
|
|
15449
|
-
return (geoJsonPoint, latlng) => {
|
|
15450
|
-
const p = PAINT;
|
|
15451
|
-
return new leafletSrc.exports.CircleMarker(latlng, this._preparePaint({ ...p, ...icon }));
|
|
15452
|
-
};
|
|
15453
|
-
}
|
|
15454
|
-
_createPaintOptions(paintOptions, type) {
|
|
15455
|
-
const geoJsonOptions = {};
|
|
15456
|
-
const paint = (paintOptions && this._preparePaint(paintOptions)) || {};
|
|
15457
|
-
if (paintOptions) {
|
|
15458
|
-
geoJsonOptions.style = () => {
|
|
15459
|
-
return paint;
|
|
15460
|
-
};
|
|
15461
|
-
}
|
|
15462
|
-
if (type === 'point') {
|
|
15463
|
-
geoJsonOptions.pointToLayer = this._createPaintToLayer(paintOptions);
|
|
15464
|
-
}
|
|
15465
|
-
else if (type === 'line') {
|
|
15466
|
-
paint.stroke = true;
|
|
15467
|
-
}
|
|
15468
|
-
return geoJsonOptions;
|
|
15469
|
-
}
|
|
15470
15508
|
_addMapClickListener() {
|
|
15471
15509
|
const map = this.map;
|
|
15472
15510
|
if (map) {
|