@@ -17539,21 +17539,23 @@ var DataFlowLayer = exports.DataFlowLayer = _leaflet2.default.GeoJSON.extend({
1753917539 options: {
1754017540 geometry: null,
1754117541 prjCoordSys: null,
17542- excludeField: null
17542+ excludeField: null,
17543+ idField: "id"
1754317544 },
1754417545
1754517546 initialize: function initialize(url, options) {
1754617547 options = options || {};
1754717548 var me = this;
1754817549 if (options.style && !options.pointToLayer) {
17549- me. options.pointToLayer = function (geojson, latlng) {
17550- return _leaflet2.default.circleMarker(latlng, me. options.style);
17550+ options.pointToLayer = function (geojson, latlng) {
17551+ return _leaflet2.default.circleMarker(latlng, options.style() );
1755117552 };
1755217553 }
1755317554 _leaflet2.default.Util.setOptions(me, options);
1755417555 me._layers = {};
1755517556 _leaflet2.default.stamp(me);
1755617557 me.url = url;
17558+ this.idCache = {};
1755717559 },
1755817560
1755917561 /**
@@ -17622,9 +17624,52 @@ var DataFlowLayer = exports.DataFlowLayer = _leaflet2.default.GeoJSON.extend({
1762217624 },
1762317625
1762417626 _onMessageSuccessed: function _onMessageSuccessed(msg) {
17625- this.clearLayers();
17626- this.addData(msg.featureResult);
17627- this.fire("dataUpdated", { layer: this, data: msg.featureResult });
17627+ var geojson = msg.featureResult;
17628+ var geoID = msg.featureResult.properties[this.options.idField];
17629+ var layer = null;
17630+ if (geoID !== undefined && this.idCache[geoID]) {
17631+ layer = this.getLayer(this.idCache[geoID]);
17632+ this._updateLayerData(layer, geojson);
17633+ } else {
17634+ layer = _leaflet2.default.GeoJSON.geometryToLayer(geojson, this.options);
17635+ layer.feature = _leaflet2.default.GeoJSON.asFeature(geojson);
17636+ this.addLayer(layer);
17637+ if (geoID !== undefined) {
17638+ this.idCache[geoID] = this.getLayerId(layer);
17639+ }
17640+ }
17641+ if (this.options.onEachFeature) {
17642+ this.options.onEachFeature(geojson, layer);
17643+ }
17644+ this.fire("dataUpdated", { layer: this, updateLayer: layer, data: msg.featureResult });
17645+ },
17646+ _updateLayerData: function _updateLayerData(layer, geojson) {
17647+ if (geojson.properties) {
17648+ layer.feature.properties = geojson.properties;
17649+ }
17650+ var latlngs = [];
17651+ switch (geojson.geometry.type) {
17652+ case 'Point':
17653+ latlngs = _leaflet2.default.GeoJSON.coordsToLatLng(geojson.geometry.coordinates);
17654+ layer.setLatLng(latlngs);
17655+ break;
17656+ case 'LineString':
17657+ latlngs = _leaflet2.default.GeoJSON.coordsToLatLngs(geojson.geometry.coordinates, 0);
17658+ layer.setLatLngs(latlngs);
17659+ break;
17660+ case 'MultiLineString':
17661+ latlngs = _leaflet2.default.GeoJSON.coordsToLatLngs(geojson.geometry.coordinates, 1);
17662+ layer.setLatLngs(latlngs);
17663+ break;
17664+ case 'Polygon':
17665+ latlngs = _leaflet2.default.GeoJSON.coordsToLatLngs(geojson.geometry.coordinates, 1);
17666+ layer.setLatLngs(latlngs);
17667+ break;
17668+ case 'MultiPolygon':
17669+ latlngs = _leaflet2.default.GeoJSON.coordsToLatLngs(geojson.geometry.coordinates, 2);
17670+ layer.setLatLngs(latlngs);
17671+ break;
17672+ }
1762817673 }
1762917674});
1763017675var dataFlowLayer = exports.dataFlowLayer = function dataFlowLayer(url, options) {
0 commit comments