Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed getting vector _leafletObject by layerModel #803

Merged
merged 2 commits into from
Aug 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions addon/components/base-layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
7 changes: 6 additions & 1 deletion addon/components/feature-result-item.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 1 addition & 3 deletions addon/components/flexberry-edit-layermap.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -638,8 +637,7 @@ export default Ember.Component.extend(
maxLat: bounds.maxLat,
maxLng: bounds.maxLng,
},
leafletObjectGetter: leafletObjectGetter,
returnLeafletObject: returnLeafletObject
leafletObjectGetter: leafletObjectGetter
});
},

Expand Down
11 changes: 8 additions & 3 deletions addon/components/flexberry-maplayers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand All @@ -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 = '';
}
Expand Down
22 changes: 18 additions & 4 deletions addon/mixins/compare-layers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -33,15 +47,15 @@ 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,
layer: labelsOriginalLayer.addTo(leafletMap)
});
}

const labelsAdditionalOriginalLayer = layer.returnLeafletObject().additionalZoomLabel;
const labelsAdditionalOriginalLayer = leafletVectorLayer.additionalZoomLabel;
if (labelsAdditionalOriginalLayer) {
labelsAdditionalOriginalLayer.forEach(zoomLabels => {
layersSideSettings.layers.push({
Expand All @@ -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,
Expand Down
7 changes: 6 additions & 1 deletion addon/mixins/flexberry-map-model-api-visualedit.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
},

Expand Down
8 changes: 6 additions & 2 deletions addon/mixins/flexberry-map-model-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
9 changes: 0 additions & 9 deletions addon/utils/copy-layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

Expand Down Expand Up @@ -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
};
Loading