@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 LeafletMapAdapter = (function () {
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
@@ -14801,19 +14801,6 @@ var LeafletMapAdapter = (function () {
|
|
|
14801
14801
|
return wrapper;
|
|
14802
14802
|
}
|
|
14803
14803
|
|
|
14804
|
-
function isPaint(paint) {
|
|
14805
|
-
if (Object.prototype.toString.call(paint) === '[object Object]') {
|
|
14806
|
-
return true;
|
|
14807
|
-
}
|
|
14808
|
-
return false;
|
|
14809
|
-
}
|
|
14810
|
-
function isPaintCallback(paint) {
|
|
14811
|
-
if (typeof paint === 'function') {
|
|
14812
|
-
return true;
|
|
14813
|
-
}
|
|
14814
|
-
return false;
|
|
14815
|
-
}
|
|
14816
|
-
|
|
14817
14804
|
function boundsToArray(bounds) {
|
|
14818
14805
|
var ne = bounds.getNorthEast();
|
|
14819
14806
|
var sw = bounds.getSouthWest();
|
|
@@ -14885,14 +14872,6 @@ var LeafletMapAdapter = (function () {
|
|
|
14885
14872
|
};
|
|
14886
14873
|
}
|
|
14887
14874
|
|
|
14888
|
-
function createMouseEvent(_a) {
|
|
14889
|
-
var layer = _a.layer, source = _a.source;
|
|
14890
|
-
var layer_ = source.target;
|
|
14891
|
-
var feature = layer_.feature;
|
|
14892
|
-
var opt = __assign({ layer: layer, feature: feature, event: convertMapClickEvent(source), source: source }, createFeaturePositionOptions(feature));
|
|
14893
|
-
return opt;
|
|
14894
|
-
}
|
|
14895
|
-
|
|
14896
14875
|
function findMostFrequentGeomType(arr) {
|
|
14897
14876
|
var counts = {};
|
|
14898
14877
|
for (var fry = 0; fry < arr.length; fry++) {
|
|
@@ -14948,6 +14927,208 @@ var LeafletMapAdapter = (function () {
|
|
|
14948
14927
|
return BaseAdapter;
|
|
14949
14928
|
}());
|
|
14950
14929
|
|
|
14930
|
+
function createMouseEvent(_a) {
|
|
14931
|
+
var layer = _a.layer, source = _a.source;
|
|
14932
|
+
var layer_ = source.target;
|
|
14933
|
+
var feature = layer_.feature;
|
|
14934
|
+
var opt = __assign({ layer: layer, feature: feature, event: convertMapClickEvent(source), source: source }, createFeaturePositionOptions(feature));
|
|
14935
|
+
return opt;
|
|
14936
|
+
}
|
|
14937
|
+
|
|
14938
|
+
var GeoJsonEvents = /** @class */ (function () {
|
|
14939
|
+
function GeoJsonEvents(layer) {
|
|
14940
|
+
this.layer = layer;
|
|
14941
|
+
}
|
|
14942
|
+
GeoJsonEvents.prototype.handleMouseEvents = function (layer) {
|
|
14943
|
+
var _this = this;
|
|
14944
|
+
var _a = this.layer.options, onClick = _a.onClick, onLayerClick = _a.onLayerClick, onMouseOut = _a.onMouseOut, onMouseOver = _a.onMouseOver;
|
|
14945
|
+
// TODO: remove backward compatibility for onLayerClick
|
|
14946
|
+
var onClick_ = onClick || onLayerClick;
|
|
14947
|
+
if (onClick_) {
|
|
14948
|
+
this._onclick = function (e) {
|
|
14949
|
+
var selected = !!_this.layer._getSelected(layer);
|
|
14950
|
+
onClick_(__assign({ selected: selected }, _this._createMouseEvent(e)));
|
|
14951
|
+
};
|
|
14952
|
+
layer.on('click', this._onclick, this);
|
|
14953
|
+
}
|
|
14954
|
+
if (onMouseOut) {
|
|
14955
|
+
this._mouseout = function (e) {
|
|
14956
|
+
onMouseOut(_this._createMouseEvent(e));
|
|
14957
|
+
};
|
|
14958
|
+
layer.on('mouseout', this._mouseout, this);
|
|
14959
|
+
}
|
|
14960
|
+
if (onMouseOver) {
|
|
14961
|
+
this._mouseover = function (e) {
|
|
14962
|
+
onMouseOver(_this._createMouseEvent(e));
|
|
14963
|
+
};
|
|
14964
|
+
layer.on('mouseover', this._mouseover, this);
|
|
14965
|
+
}
|
|
14966
|
+
};
|
|
14967
|
+
GeoJsonEvents.prototype.stopMouseEvents = function (layer) {
|
|
14968
|
+
if (this._mouseover) {
|
|
14969
|
+
layer.off('mouseover', this._mouseover, this);
|
|
14970
|
+
}
|
|
14971
|
+
if (this._mouseout) {
|
|
14972
|
+
layer.off('mouseout', this._mouseout, this);
|
|
14973
|
+
}
|
|
14974
|
+
if (this._onclick) {
|
|
14975
|
+
layer.off('click', this._onclick, this);
|
|
14976
|
+
}
|
|
14977
|
+
};
|
|
14978
|
+
GeoJsonEvents.prototype._createMouseEvent = function (source) {
|
|
14979
|
+
return createMouseEvent({
|
|
14980
|
+
layer: this.layer,
|
|
14981
|
+
source: source,
|
|
14982
|
+
});
|
|
14983
|
+
};
|
|
14984
|
+
return GeoJsonEvents;
|
|
14985
|
+
}());
|
|
14986
|
+
|
|
14987
|
+
function isPaint(paint) {
|
|
14988
|
+
if (Object.prototype.toString.call(paint) === '[object Object]') {
|
|
14989
|
+
return true;
|
|
14990
|
+
}
|
|
14991
|
+
return false;
|
|
14992
|
+
}
|
|
14993
|
+
function isPaintCallback(paint) {
|
|
14994
|
+
if (typeof paint === 'function') {
|
|
14995
|
+
return true;
|
|
14996
|
+
}
|
|
14997
|
+
return false;
|
|
14998
|
+
}
|
|
14999
|
+
|
|
15000
|
+
var GeoJsonPaint = /** @class */ (function () {
|
|
15001
|
+
function GeoJsonPaint(layer) {
|
|
15002
|
+
this.layer = layer;
|
|
15003
|
+
}
|
|
15004
|
+
GeoJsonPaint.prototype.setPaintEachLayer = function (paint) {
|
|
15005
|
+
var _this = this;
|
|
15006
|
+
this.layer._layers.forEach(function (layerDef) {
|
|
15007
|
+
_this.setPaint(layerDef, paint);
|
|
15008
|
+
});
|
|
15009
|
+
};
|
|
15010
|
+
GeoJsonPaint.prototype.setPaint = function (layerDef, paint) {
|
|
15011
|
+
var style = undefined;
|
|
15012
|
+
var layer = layerDef.layer, feature = layerDef.feature;
|
|
15013
|
+
if (layer && feature) {
|
|
15014
|
+
if (isPaintCallback(paint)) {
|
|
15015
|
+
style = paint(feature);
|
|
15016
|
+
}
|
|
15017
|
+
else if (isPaint(paint)) {
|
|
15018
|
+
style = paint;
|
|
15019
|
+
}
|
|
15020
|
+
if (style) {
|
|
15021
|
+
if (this.layer.type === 'point' && style.type === 'icon') {
|
|
15022
|
+
var marker_1 = layer;
|
|
15023
|
+
var divIcon_1 = this._createDivIcon(style);
|
|
15024
|
+
setTimeout(function () {
|
|
15025
|
+
marker_1.setIcon(divIcon_1);
|
|
15026
|
+
}, 10);
|
|
15027
|
+
}
|
|
15028
|
+
else if ('setStyle' in layer) {
|
|
15029
|
+
layer.setStyle(this.preparePaint(style));
|
|
15030
|
+
}
|
|
15031
|
+
}
|
|
15032
|
+
}
|
|
15033
|
+
};
|
|
15034
|
+
GeoJsonPaint.prototype.preparePaint = function (paint) {
|
|
15035
|
+
if (paint.type !== 'get-paint') {
|
|
15036
|
+
var paintAliases = [
|
|
15037
|
+
['color', 'strokeColor'],
|
|
15038
|
+
['opacity', 'strokeOpacity'],
|
|
15039
|
+
['stroke', 'stroke'],
|
|
15040
|
+
['fillColor', 'fillColor'],
|
|
15041
|
+
['fillOpacity', 'fillOpacity'],
|
|
15042
|
+
['fill', 'fill'],
|
|
15043
|
+
['weight', 'weight'],
|
|
15044
|
+
];
|
|
15045
|
+
var aliases = this.layer.type === 'line'
|
|
15046
|
+
? [
|
|
15047
|
+
['color', 'strokeColor'],
|
|
15048
|
+
['opacity', 'strokeOpacity'],
|
|
15049
|
+
['weight', 'weight'],
|
|
15050
|
+
]
|
|
15051
|
+
: paintAliases;
|
|
15052
|
+
var readyPaint = {};
|
|
15053
|
+
if ('radius' in paint && typeof paint.radius === 'number') {
|
|
15054
|
+
readyPaint.radius = paint.radius;
|
|
15055
|
+
}
|
|
15056
|
+
for (var _i = 0, aliases_1 = aliases; _i < aliases_1.length; _i++) {
|
|
15057
|
+
var _a = aliases_1[_i], to = _a[0], from = _a[1];
|
|
15058
|
+
var opacity = this.layer.options.opacity;
|
|
15059
|
+
var paintProp = paint[from];
|
|
15060
|
+
if (defined(opacity) && from.toLowerCase().indexOf('opacity') !== -1) {
|
|
15061
|
+
paintProp = Number(paintProp) * opacity;
|
|
15062
|
+
}
|
|
15063
|
+
if (paintProp !== undefined) {
|
|
15064
|
+
Object.defineProperty(readyPaint, to, {
|
|
15065
|
+
enumerable: true,
|
|
15066
|
+
value: paintProp,
|
|
15067
|
+
});
|
|
15068
|
+
}
|
|
15069
|
+
}
|
|
15070
|
+
return readyPaint;
|
|
15071
|
+
}
|
|
15072
|
+
return PAINT;
|
|
15073
|
+
};
|
|
15074
|
+
GeoJsonPaint.prototype._createDivIcon = function (icon) {
|
|
15075
|
+
var html = icon.html, rotate = icon.rotate, className = icon.className, toLIconOpt = __rest(icon, ["html", "rotate", "className"]);
|
|
15076
|
+
var element = document.createElement('div');
|
|
15077
|
+
if (className) {
|
|
15078
|
+
element.className = className;
|
|
15079
|
+
}
|
|
15080
|
+
if (rotate) {
|
|
15081
|
+
element.style.transform = "rotateZ(".concat(rotate, "deg)");
|
|
15082
|
+
}
|
|
15083
|
+
if (html) {
|
|
15084
|
+
element.innerHTML = html;
|
|
15085
|
+
}
|
|
15086
|
+
var divIcon = new leafletSrc.exports.DivIcon(__assign(__assign({ className: '' }, toLIconOpt), { html: element }));
|
|
15087
|
+
return divIcon;
|
|
15088
|
+
};
|
|
15089
|
+
GeoJsonPaint.prototype.createPaintToLayer = function (icon) {
|
|
15090
|
+
var _this = this;
|
|
15091
|
+
if (icon && icon.type) {
|
|
15092
|
+
if (icon.type === 'icon') {
|
|
15093
|
+
var iconClassName = icon.className;
|
|
15094
|
+
var html = icon.html;
|
|
15095
|
+
if (iconClassName || html) {
|
|
15096
|
+
return function (_, latlng) {
|
|
15097
|
+
var divIcon = _this._createDivIcon(icon);
|
|
15098
|
+
return new leafletSrc.exports.Marker(latlng, { icon: divIcon });
|
|
15099
|
+
};
|
|
15100
|
+
}
|
|
15101
|
+
}
|
|
15102
|
+
else if (icon.type === 'pin') {
|
|
15103
|
+
return function (_, latlng) {
|
|
15104
|
+
return new leafletSrc.exports.Marker(latlng);
|
|
15105
|
+
};
|
|
15106
|
+
}
|
|
15107
|
+
}
|
|
15108
|
+
return function (_, latlng) {
|
|
15109
|
+
var p = PAINT;
|
|
15110
|
+
return new leafletSrc.exports.CircleMarker(latlng, _this.preparePaint(__assign(__assign({}, p), icon)));
|
|
15111
|
+
};
|
|
15112
|
+
};
|
|
15113
|
+
GeoJsonPaint.prototype.createPaintOptions = function (paint) {
|
|
15114
|
+
var geoJsonOptions = {};
|
|
15115
|
+
var newPaint = this.preparePaint(paint);
|
|
15116
|
+
if (paint) {
|
|
15117
|
+
geoJsonOptions.style = function () {
|
|
15118
|
+
return newPaint;
|
|
15119
|
+
};
|
|
15120
|
+
}
|
|
15121
|
+
if (this.layer.type === 'point') {
|
|
15122
|
+
geoJsonOptions.pointToLayer = this.createPaintToLayer(paint);
|
|
15123
|
+
}
|
|
15124
|
+
else if (this.layer.type === 'line') {
|
|
15125
|
+
newPaint.stroke = true;
|
|
15126
|
+
}
|
|
15127
|
+
return geoJsonOptions;
|
|
15128
|
+
};
|
|
15129
|
+
return GeoJsonPaint;
|
|
15130
|
+
}());
|
|
15131
|
+
|
|
14951
15132
|
var GeoJsonAdapter = /** @class */ (function (_super) {
|
|
14952
15133
|
__extends(GeoJsonAdapter, _super);
|
|
14953
15134
|
function GeoJsonAdapter(map, options) {
|
|
@@ -14963,6 +15144,8 @@ var LeafletMapAdapter = (function () {
|
|
|
14963
15144
|
_this.$unselect = function () {
|
|
14964
15145
|
_this.unselect();
|
|
14965
15146
|
};
|
|
15147
|
+
_this._events = new GeoJsonEvents(_this);
|
|
15148
|
+
_this._paint = new GeoJsonPaint(_this);
|
|
14966
15149
|
return _this;
|
|
14967
15150
|
}
|
|
14968
15151
|
GeoJsonAdapter.prototype.addLayer = function (options) {
|
|
@@ -14992,7 +15175,7 @@ var LeafletMapAdapter = (function () {
|
|
|
14992
15175
|
else if (!this.selected) {
|
|
14993
15176
|
this.selected = true;
|
|
14994
15177
|
if (this.selectedPaint) {
|
|
14995
|
-
this.
|
|
15178
|
+
this._paint.setPaintEachLayer(this.selectedPaint);
|
|
14996
15179
|
}
|
|
14997
15180
|
}
|
|
14998
15181
|
};
|
|
@@ -15010,7 +15193,7 @@ var LeafletMapAdapter = (function () {
|
|
|
15010
15193
|
this._removePopup(p[0]);
|
|
15011
15194
|
}
|
|
15012
15195
|
if (this.paint) {
|
|
15013
|
-
this.
|
|
15196
|
+
this._paint.setPaintEachLayer(this.paint);
|
|
15014
15197
|
}
|
|
15015
15198
|
this._selectedLayers.length = 0;
|
|
15016
15199
|
this.selected = false;
|
|
@@ -15171,7 +15354,7 @@ var LeafletMapAdapter = (function () {
|
|
|
15171
15354
|
this.paint = paint;
|
|
15172
15355
|
for (var _i = 0, _a = this._layers; _i < _a.length; _i++) {
|
|
15173
15356
|
var l = _a[_i];
|
|
15174
|
-
this.
|
|
15357
|
+
this._paint.setPaint(l, paint);
|
|
15175
15358
|
}
|
|
15176
15359
|
}
|
|
15177
15360
|
};
|
|
@@ -15180,7 +15363,7 @@ var LeafletMapAdapter = (function () {
|
|
|
15180
15363
|
this.selectedPaint = paint;
|
|
15181
15364
|
for (var _i = 0, _a = this._selectedLayers; _i < _a.length; _i++) {
|
|
15182
15365
|
var l = _a[_i];
|
|
15183
|
-
this.
|
|
15366
|
+
this._paint.setPaint(l, paint);
|
|
15184
15367
|
}
|
|
15185
15368
|
}
|
|
15186
15369
|
};
|
|
@@ -15188,16 +15371,19 @@ var LeafletMapAdapter = (function () {
|
|
|
15188
15371
|
this.paint = __assign(__assign({}, this.paint), paint);
|
|
15189
15372
|
for (var _i = 0, _a = this._layers; _i < _a.length; _i++) {
|
|
15190
15373
|
var l = _a[_i];
|
|
15191
|
-
this.
|
|
15374
|
+
this._paint.setPaint(l, this.paint);
|
|
15192
15375
|
}
|
|
15193
15376
|
};
|
|
15194
15377
|
GeoJsonAdapter.prototype.updateSelectedPaint = function (paint) {
|
|
15195
15378
|
this.selectedPaint = __assign(__assign({}, this.selectedPaint), paint);
|
|
15196
15379
|
for (var _i = 0, _a = this._selectedLayers; _i < _a.length; _i++) {
|
|
15197
15380
|
var l = _a[_i];
|
|
15198
|
-
this.
|
|
15381
|
+
this._paint.setPaint(l, this.selectedPaint);
|
|
15199
15382
|
}
|
|
15200
15383
|
};
|
|
15384
|
+
GeoJsonAdapter.prototype._getSelected = function (layer) {
|
|
15385
|
+
return this._selectedLayers.find(function (x) { return x.layer === layer; });
|
|
15386
|
+
};
|
|
15201
15387
|
GeoJsonAdapter.prototype._updateTooltip = function (layerDef) {
|
|
15202
15388
|
var feature = layerDef.feature, layer = layerDef.layer;
|
|
15203
15389
|
if (feature && layer && feature.properties && this.options.labelField) {
|
|
@@ -15289,79 +15475,6 @@ var LeafletMapAdapter = (function () {
|
|
|
15289
15475
|
}
|
|
15290
15476
|
}
|
|
15291
15477
|
};
|
|
15292
|
-
GeoJsonAdapter.prototype._setPaintEachLayer = function (paint) {
|
|
15293
|
-
var _this = this;
|
|
15294
|
-
this._layers.forEach(function (l) {
|
|
15295
|
-
_this._setPaint(l, paint);
|
|
15296
|
-
});
|
|
15297
|
-
};
|
|
15298
|
-
GeoJsonAdapter.prototype._setPaint = function (def, paint) {
|
|
15299
|
-
var style = undefined;
|
|
15300
|
-
var layer = def.layer, feature = def.feature;
|
|
15301
|
-
if (layer && feature) {
|
|
15302
|
-
if (isPaintCallback(paint)) {
|
|
15303
|
-
style = paint(feature);
|
|
15304
|
-
}
|
|
15305
|
-
else if (isPaint(paint)) {
|
|
15306
|
-
style = paint;
|
|
15307
|
-
}
|
|
15308
|
-
if (style) {
|
|
15309
|
-
if (this.type === 'point' && style.type === 'icon') {
|
|
15310
|
-
var marker = layer;
|
|
15311
|
-
var divIcon = this._createDivIcon(style);
|
|
15312
|
-
marker.setIcon(divIcon);
|
|
15313
|
-
}
|
|
15314
|
-
else if ('setStyle' in layer) {
|
|
15315
|
-
layer.setStyle(this._preparePaint(style));
|
|
15316
|
-
}
|
|
15317
|
-
}
|
|
15318
|
-
}
|
|
15319
|
-
};
|
|
15320
|
-
GeoJsonAdapter.prototype._preparePaint = function (paint) {
|
|
15321
|
-
if (paint.type !== 'get-paint') {
|
|
15322
|
-
// const path: CircleMarkerOptions | PathOptions = paint as CircleMarkerOptions | PathOptions;
|
|
15323
|
-
// if (path.opacity) {
|
|
15324
|
-
// path.fillOpacity = path.opacity;
|
|
15325
|
-
// }
|
|
15326
|
-
var paintAliases = [
|
|
15327
|
-
// ['color', 'color'],
|
|
15328
|
-
['color', 'strokeColor'],
|
|
15329
|
-
['opacity', 'strokeOpacity'],
|
|
15330
|
-
['stroke', 'stroke'],
|
|
15331
|
-
['fillColor', 'fillColor'],
|
|
15332
|
-
['fillOpacity', 'fillOpacity'],
|
|
15333
|
-
['fill', 'fill'],
|
|
15334
|
-
['weight', 'weight'],
|
|
15335
|
-
];
|
|
15336
|
-
var aliases = this.type === 'line'
|
|
15337
|
-
? [
|
|
15338
|
-
['color', 'strokeColor'],
|
|
15339
|
-
['opacity', 'strokeOpacity'],
|
|
15340
|
-
['weight', 'weight'],
|
|
15341
|
-
]
|
|
15342
|
-
: paintAliases;
|
|
15343
|
-
var readyPaint = {};
|
|
15344
|
-
if ('radius' in paint && typeof paint.radius === 'number') {
|
|
15345
|
-
readyPaint.radius = paint.radius;
|
|
15346
|
-
}
|
|
15347
|
-
for (var _i = 0, aliases_1 = aliases; _i < aliases_1.length; _i++) {
|
|
15348
|
-
var _a = aliases_1[_i], to = _a[0], from = _a[1];
|
|
15349
|
-
var paintProp = paint[from];
|
|
15350
|
-
if (defined(this.options.opacity) &&
|
|
15351
|
-
from.toLowerCase().indexOf('opacity') !== -1) {
|
|
15352
|
-
paintProp = Number(paintProp) * this.options.opacity;
|
|
15353
|
-
}
|
|
15354
|
-
if (paintProp !== undefined) {
|
|
15355
|
-
Object.defineProperty(readyPaint, to, {
|
|
15356
|
-
enumerable: true,
|
|
15357
|
-
value: paintProp,
|
|
15358
|
-
});
|
|
15359
|
-
}
|
|
15360
|
-
}
|
|
15361
|
-
return readyPaint;
|
|
15362
|
-
}
|
|
15363
|
-
return PAINT;
|
|
15364
|
-
};
|
|
15365
15478
|
GeoJsonAdapter.prototype._getGeoJsonOptions = function (options, type) {
|
|
15366
15479
|
var _this = this;
|
|
15367
15480
|
var paint = options.paint;
|
|
@@ -15371,7 +15484,7 @@ var LeafletMapAdapter = (function () {
|
|
|
15371
15484
|
// TODO: fix types (@geoman-io/leaflet-geoman-free)
|
|
15372
15485
|
lopt.pointToLayer = function (feature, latLng) {
|
|
15373
15486
|
var iconOpt = paint(feature);
|
|
15374
|
-
var pointToLayer = _this.
|
|
15487
|
+
var pointToLayer = _this._paint.createPaintToLayer(iconOpt);
|
|
15375
15488
|
return pointToLayer(feature, latLng);
|
|
15376
15489
|
};
|
|
15377
15490
|
}
|
|
@@ -15379,17 +15492,17 @@ var LeafletMapAdapter = (function () {
|
|
|
15379
15492
|
lopt = {
|
|
15380
15493
|
style: function (feature) {
|
|
15381
15494
|
if (feature) {
|
|
15382
|
-
return _this.
|
|
15495
|
+
return _this._paint.preparePaint(__assign(__assign({}, PAINT), paint(feature)));
|
|
15383
15496
|
}
|
|
15384
15497
|
else {
|
|
15385
|
-
return _this.
|
|
15498
|
+
return _this._paint.preparePaint(__assign(__assign({}, PAINT), { type: 'path' }));
|
|
15386
15499
|
}
|
|
15387
15500
|
},
|
|
15388
15501
|
};
|
|
15389
15502
|
}
|
|
15390
15503
|
}
|
|
15391
15504
|
else {
|
|
15392
|
-
lopt = this.
|
|
15505
|
+
lopt = this._paint.createPaintOptions(paint);
|
|
15393
15506
|
}
|
|
15394
15507
|
lopt.onEachFeature = function (feature, layer) {
|
|
15395
15508
|
_this._onEachFeature(feature, layer);
|
|
@@ -15401,7 +15514,6 @@ var LeafletMapAdapter = (function () {
|
|
|
15401
15514
|
var layer_ = this.layer;
|
|
15402
15515
|
if (layer_) {
|
|
15403
15516
|
var def_2 = __assign({ target: this, feature: feature, layer: layer }, createFeaturePositionOptions(feature));
|
|
15404
|
-
// @ts-ignore
|
|
15405
15517
|
layer.options.pane = this.pane;
|
|
15406
15518
|
this._layers.push(def_2);
|
|
15407
15519
|
var ok = true;
|
|
@@ -15426,7 +15538,7 @@ var LeafletMapAdapter = (function () {
|
|
|
15426
15538
|
layer.on('click', function (e) { return _this._selectOnLayerClick(e); }, this);
|
|
15427
15539
|
}
|
|
15428
15540
|
}
|
|
15429
|
-
this.
|
|
15541
|
+
this._events.handleMouseEvents(layer);
|
|
15430
15542
|
// The timeout is needed to display the popup immediately when adding a layer to the map.
|
|
15431
15543
|
// Without a timeout, the layer may not yet have a _map object
|
|
15432
15544
|
setTimeout(function () {
|
|
@@ -15438,37 +15550,6 @@ var LeafletMapAdapter = (function () {
|
|
|
15438
15550
|
}
|
|
15439
15551
|
}
|
|
15440
15552
|
};
|
|
15441
|
-
GeoJsonAdapter.prototype._handleMouseEvents = function (layer) {
|
|
15442
|
-
var _this = this;
|
|
15443
|
-
var _a = this.options, onClick = _a.onClick, onLayerClick = _a.onLayerClick, onMouseOut = _a.onMouseOut, onMouseOver = _a.onMouseOver;
|
|
15444
|
-
// TODO: remove backward compatibility for onLayerClick
|
|
15445
|
-
var onClick_ = onClick || onLayerClick;
|
|
15446
|
-
if (onClick_) {
|
|
15447
|
-
layer.on('click', function (e) {
|
|
15448
|
-
var selected = !!_this._getSelected(layer);
|
|
15449
|
-
onClick_(__assign({ selected: selected }, _this._createMouseEvent(e)));
|
|
15450
|
-
}, this);
|
|
15451
|
-
}
|
|
15452
|
-
if (onMouseOut) {
|
|
15453
|
-
layer.on('mouseout', function (e) {
|
|
15454
|
-
onMouseOut(_this._createMouseEvent(e));
|
|
15455
|
-
}, this);
|
|
15456
|
-
}
|
|
15457
|
-
if (onMouseOver) {
|
|
15458
|
-
layer.on('mouseover', function (e) {
|
|
15459
|
-
onMouseOver(_this._createMouseEvent(e));
|
|
15460
|
-
}, this);
|
|
15461
|
-
}
|
|
15462
|
-
};
|
|
15463
|
-
GeoJsonAdapter.prototype._createMouseEvent = function (source) {
|
|
15464
|
-
return createMouseEvent({
|
|
15465
|
-
layer: this,
|
|
15466
|
-
source: source,
|
|
15467
|
-
});
|
|
15468
|
-
};
|
|
15469
|
-
GeoJsonAdapter.prototype._getSelected = function (layer) {
|
|
15470
|
-
return this._selectedLayers.find(function (x) { return x.layer === layer; });
|
|
15471
|
-
};
|
|
15472
15553
|
GeoJsonAdapter.prototype._selectOnLayerClick = function (e) {
|
|
15473
15554
|
leafletSrc.exports.DomEvent.stopPropagation(e);
|
|
15474
15555
|
var layer = e.target;
|
|
@@ -15498,7 +15579,7 @@ var LeafletMapAdapter = (function () {
|
|
|
15498
15579
|
this.selected = true;
|
|
15499
15580
|
var _a = this.options, selectedPaint = _a.selectedPaint, popupOnSelect = _a.popupOnSelect, popupOptions = _a.popupOptions;
|
|
15500
15581
|
if (selectedPaint && def.layer) {
|
|
15501
|
-
this.
|
|
15582
|
+
this._paint.setPaint(def, selectedPaint);
|
|
15502
15583
|
}
|
|
15503
15584
|
if (popupOnSelect) {
|
|
15504
15585
|
this._openPopup(def, popupOptions, type, latlng);
|
|
@@ -15514,7 +15595,7 @@ var LeafletMapAdapter = (function () {
|
|
|
15514
15595
|
this._selectedLayers.splice(index, 1);
|
|
15515
15596
|
if (this.options) {
|
|
15516
15597
|
if (this.options.paint) {
|
|
15517
|
-
this.
|
|
15598
|
+
this._paint.setPaint(def, this.options.paint);
|
|
15518
15599
|
}
|
|
15519
15600
|
if (this.options.popupOnSelect && def.layer) {
|
|
15520
15601
|
this._removePopup(def.layer);
|
|
@@ -15523,51 +15604,6 @@ var LeafletMapAdapter = (function () {
|
|
|
15523
15604
|
}
|
|
15524
15605
|
this.selected = this._selectedLayers.length > 0;
|
|
15525
15606
|
};
|
|
15526
|
-
GeoJsonAdapter.prototype._createDivIcon = function (icon) {
|
|
15527
|
-
var toLIconOpt = __rest(icon, []);
|
|
15528
|
-
return new leafletSrc.exports.DivIcon(__assign({ className: '' }, toLIconOpt));
|
|
15529
|
-
};
|
|
15530
|
-
GeoJsonAdapter.prototype._createPaintToLayer = function (icon) {
|
|
15531
|
-
var _this = this;
|
|
15532
|
-
if (icon && icon.type) {
|
|
15533
|
-
if (icon.type === 'icon') {
|
|
15534
|
-
var iconClassName = icon.className;
|
|
15535
|
-
var html = icon.html;
|
|
15536
|
-
if (iconClassName || html) {
|
|
15537
|
-
return function (geoJsonPoint, latlng) {
|
|
15538
|
-
var divIcon = _this._createDivIcon(icon);
|
|
15539
|
-
return new leafletSrc.exports.Marker(latlng, { icon: divIcon });
|
|
15540
|
-
};
|
|
15541
|
-
}
|
|
15542
|
-
}
|
|
15543
|
-
else if (icon.type === 'pin') {
|
|
15544
|
-
return function (geoJsonPoint, latlng) {
|
|
15545
|
-
// const divIcon = this.createDivIcon(icon);
|
|
15546
|
-
return new leafletSrc.exports.Marker(latlng);
|
|
15547
|
-
};
|
|
15548
|
-
}
|
|
15549
|
-
}
|
|
15550
|
-
return function (geoJsonPoint, latlng) {
|
|
15551
|
-
var p = PAINT;
|
|
15552
|
-
return new leafletSrc.exports.CircleMarker(latlng, _this._preparePaint(__assign(__assign({}, p), icon)));
|
|
15553
|
-
};
|
|
15554
|
-
};
|
|
15555
|
-
GeoJsonAdapter.prototype._createPaintOptions = function (paintOptions, type) {
|
|
15556
|
-
var geoJsonOptions = {};
|
|
15557
|
-
var paint = (paintOptions && this._preparePaint(paintOptions)) || {};
|
|
15558
|
-
if (paintOptions) {
|
|
15559
|
-
geoJsonOptions.style = function () {
|
|
15560
|
-
return paint;
|
|
15561
|
-
};
|
|
15562
|
-
}
|
|
15563
|
-
if (type === 'point') {
|
|
15564
|
-
geoJsonOptions.pointToLayer = this._createPaintToLayer(paintOptions);
|
|
15565
|
-
}
|
|
15566
|
-
else if (type === 'line') {
|
|
15567
|
-
paint.stroke = true;
|
|
15568
|
-
}
|
|
15569
|
-
return geoJsonOptions;
|
|
15570
|
-
};
|
|
15571
15607
|
GeoJsonAdapter.prototype._addMapClickListener = function () {
|
|
15572
15608
|
var map = this.map;
|
|
15573
15609
|
if (map) {
|