diff --git a/addon/components/base-layer.js b/addon/components/base-layer.js index 7ec321038..5f710ac87 100644 --- a/addon/components/base-layer.js +++ b/addon/components/base-layer.js @@ -361,10 +361,6 @@ export default Ember.Component.extend( Ember.set(this.get('layerModel'), 'leafletObjectGetter', this.getLeafletObject.bind(this)); } - if (Ember.isNone(this.get('layerModel.returnLeafletObject'))) { - Ember.set(this.get('layerModel'), 'returnLeafletObject', this.returnLeafletObject.bind(this)); - } - // Save the reference to the instance method for getting attributes options. if (Ember.isNone(this.get('layerModel._attributesOptions'))) { Ember.set(this.get('layerModel'), '_attributesOptions', this._getAttributesOptions.bind(this)); diff --git a/addon/components/feature-result-item.js b/addon/components/feature-result-item.js index 86cb10e37..47c3e9ed4 100644 --- a/addon/components/feature-result-item.js +++ b/addon/components/feature-result-item.js @@ -355,7 +355,12 @@ export default Ember.Component.extend(ResultFeatureInitializer, { if (feature.geometry && feature.geometry.type && (feature.geometry.type === 'Point' || feature.geometry.type === 'MultiPoint' || feature.geometry.type === 'LineString' || feature.geometry.type === 'MultiLineString')) { - let leafletObject = feature.layerModel.returnLeafletObject(); + let leafletObject = feature.layerModel.get('_leafletObject'); + + if (leafletObject instanceof L.MarkerClusterGroup) { + leafletObject = Ember.get(leafletObject, '_originalVectorLayer'); + } + let layerOptions = Ember.get(leafletObject, 'options.renderer.options'); if (Ember.isPresent(layerOptions) && layerOptions.tolerance === 0) { Ember.set(layerOptions, 'tolerance', 3); diff --git a/addon/components/flexberry-edit-layermap.js b/addon/components/flexberry-edit-layermap.js index 2261b3679..8443843d9 100644 --- a/addon/components/flexberry-edit-layermap.js +++ b/addon/components/flexberry-edit-layermap.js @@ -604,7 +604,6 @@ export default Ember.Component.extend( let keyWords = this.get('layer.keyWords'); let boundingBox = this.get('layer.boundingBox'); let leafletObjectGetter = this.get('layer.leafletObjectGetter'); - let returnLeafletObject = this.get('layer.returnLeafletObject'); let bounds = getBounds(boundingBox); let crs = this.get('layer.coordinateReferenceSystem'); @@ -638,8 +637,7 @@ export default Ember.Component.extend( maxLat: bounds.maxLat, maxLng: bounds.maxLng, }, - leafletObjectGetter: leafletObjectGetter, - returnLeafletObject: returnLeafletObject + leafletObjectGetter: leafletObjectGetter }); }, diff --git a/addon/components/flexberry-maplayers.js b/addon/components/flexberry-maplayers.js index 70bdace3a..fc62ecc98 100644 --- a/addon/components/flexberry-maplayers.js +++ b/addon/components/flexberry-maplayers.js @@ -481,13 +481,18 @@ let FlexberryMaplayersComponent = Ember.Component.extend( let layersToAdd = this.get('currentLayers'); let layers = this.get('layers'); layers.forEach(layer => { - const leafletLayer = layer.returnLeafletObject(); + let leafletLayer = layer.get('_leafletObject'); + + if (leafletLayer instanceof L.MarkerClusterGroup) { + leafletLayer = Ember.get(leafletLayer, '_originalVectorLayer'); + } + if (leafletLayer && leafletLayer.getContainer && leafletLayer.getContainer()) { leafletLayer.getContainer().style.clip = ''; } if (layer.get('settingsAsObject.labelSettings.signMapObjects')) { - const labelsAdditionalOriginalLayer = layer.returnLeafletObject().additionalZoomLabel; + const labelsAdditionalOriginalLayer = leafletLayer.additionalZoomLabel; if (labelsAdditionalOriginalLayer) { labelsAdditionalOriginalLayer.forEach(zoomLabels => { if (zoomLabels && zoomLabels.getContainer && zoomLabels.getContainer()) { @@ -496,7 +501,7 @@ let FlexberryMaplayersComponent = Ember.Component.extend( }); } - const labelsOriginalLayer = layer.returnLeafletObject()._labelsLayer; + const labelsOriginalLayer = leafletLayer._labelsLayer; if (labelsOriginalLayer && labelsOriginalLayer.getContainer && labelsOriginalLayer.getContainer()) { leafletLayer.getContainer().style.clip = ''; } diff --git a/addon/mixins/compare-layers.js b/addon/mixins/compare-layers.js index 974c33299..6ef6b3f1a 100644 --- a/addon/mixins/compare-layers.js +++ b/addon/mixins/compare-layers.js @@ -24,7 +24,21 @@ export default Ember.Mixin.create({ */ setLayerBySide(layer, side, leafletMap) { const layerId = Ember.get(layer, 'id'); - const leafletOriginalLayer = Ember.get(layer, '_leafletObjectFirst') || layer.returnLeafletObject(); + let leafletOriginalLayer = Ember.get(layer, '_leafletObjectFirst') || Ember.get(layer, '_leafletObject'); // layer displaying context + let leafletVectorLayer = Ember.get(layer, '_leafletObject'); // layer vector context + + // layers for side-by-side plugin must have the getContainer() method + // Cluster layer does not implement this method, so displaying the cluster layer in the plugin is not available + // Use vector context for both display and map tools + if (leafletOriginalLayer instanceof L.MarkerClusterGroup) { + leafletOriginalLayer = Ember.get(leafletOriginalLayer, '_originalVectorLayer'); + } + + // Clustering vector layer contains the vector context in the "_leafletObject._originalVectorLayer" path + if (leafletVectorLayer instanceof L.MarkerClusterGroup) { + leafletVectorLayer = Ember.get(leafletVectorLayer, '_originalVectorLayer'); + } + let layersSideSettings = this.get(`compare.compareState.${side}`); let existedLayers = layersSideSettings.layers.filter(l => l.id === layerId); if (existedLayers.length > 0) { @@ -33,7 +47,7 @@ export default Ember.Mixin.create({ Ember.set(layersSideSettings, 'layerIds', layersSideSettings.layerIds.filter(l => l !== layerId)); } else { if (layer.get('settingsAsObject.labelSettings.signMapObjects')) { - const labelsOriginalLayer = layer.returnLeafletObject()._labelsLayerMulti; + const labelsOriginalLayer = leafletVectorLayer._labelsLayerMulti; if (labelsOriginalLayer) { layersSideSettings.layers.push({ id: layerId, @@ -41,7 +55,7 @@ export default Ember.Mixin.create({ }); } - const labelsAdditionalOriginalLayer = layer.returnLeafletObject().additionalZoomLabel; + const labelsAdditionalOriginalLayer = leafletVectorLayer.additionalZoomLabel; if (labelsAdditionalOriginalLayer) { labelsAdditionalOriginalLayer.forEach(zoomLabels => { layersSideSettings.layers.push({ @@ -51,7 +65,7 @@ export default Ember.Mixin.create({ }); } - const labelsMultiOriginalLayer = layer.returnLeafletObject()._labelsLayer; + const labelsMultiOriginalLayer = leafletVectorLayer._labelsLayer; if (labelsMultiOriginalLayer) { layersSideSettings.layers.push({ id: layerId, diff --git a/addon/mixins/flexberry-map-model-api-visualedit.js b/addon/mixins/flexberry-map-model-api-visualedit.js index 7f994379f..016e3ae2e 100644 --- a/addon/mixins/flexberry-map-model-api-visualedit.js +++ b/addon/mixins/flexberry-map-model-api-visualedit.js @@ -386,7 +386,12 @@ export default Ember.Mixin.create(SnapDraw, { throw `Layer '${layerId}' not found`; } - let leafletObject = layerModel.returnLeafletObject(); + let leafletObject = layerModel.get('_leafletObject'); + + if (leafletObject instanceof L.MarkerClusterGroup) { + leafletObject = Ember.get(leafletObject, '_originalVectorLayer'); + } + return [layerModel, leafletObject]; }, diff --git a/addon/mixins/flexberry-map-model-api.js b/addon/mixins/flexberry-map-model-api.js index 657fc985e..dccf13634 100644 --- a/addon/mixins/flexberry-map-model-api.js +++ b/addon/mixins/flexberry-map-model-api.js @@ -1333,11 +1333,15 @@ export default Ember.Mixin.create(SnapDraw, actionsHandler, { @return {String} Field name. */ _getPkField(layer) { - if (Ember.isNone(layer) || typeof Ember.get(layer, 'returnLeafletObject') !== 'function') { + if (Ember.isNone(layer)) { throw 'Layer is undefined'; } - let leafletObject = layer.returnLeafletObject(); + let leafletObject = layer.get('_leafletObject'); + + if (leafletObject instanceof L.MarkerClusterGroup) { + leafletObject = Ember.get(leafletObject, '_originalVectorLayer'); + } if (Ember.isNone(leafletObject) || typeof Ember.get(leafletObject, 'getPkField') !== 'function') { throw 'Layer is not VectorLayer'; diff --git a/addon/utils/copy-layer.js b/addon/utils/copy-layer.js index 2ea1fb1a1..7fda8ff92 100644 --- a/addon/utils/copy-layer.js +++ b/addon/utils/copy-layer.js @@ -29,9 +29,6 @@ let copyLayer = function(layerModel, store, ignoreLinks) { // Copy 'leafletObjectGetter' function into created empty model. copyLeafletObjectGetter(layerModel, layerModelCopy); - //Copy 'returnLeafletObject' function into created empty model. - copyReturnLeafletObject(layerModel, layerModelCopy); - return layerModelCopy; }; @@ -85,12 +82,6 @@ let copyLeafletObjectGetter = function(layerModel, layerModelCopy) { layerModelCopy.set('leafletObjectGetter', leafletObjectGetter); }; -let copyReturnLeafletObject = function(layerModel, layerModelCopy) { - let returnLeafletObject = layerModel.get('returnLeafletObject'); - - layerModelCopy.set('returnLeafletObject', returnLeafletObject); -}; - export { copyLayer };