diff --git a/addon/components/base-vector-layer.js b/addon/components/base-vector-layer.js index 218466220..9976b0d67 100644 --- a/addon/components/base-vector-layer.js +++ b/addon/components/base-vector-layer.js @@ -1317,5 +1317,32 @@ export default BaseLayer.extend(layerLabel, { } else { return geoJSONLayer.geometry.coordinates; } + }, + + _boundsCrs(leafletObject) { + let leafletMap = this.get('leafletMap'); + let boundsMap = leafletMap.getBounds(); + if (boundsMap && leafletObject.options && leafletObject.options.crs && leafletObject.options.crs.bounds) { + let crsBounds = leafletObject.options.crs.bounds; + if (boundsMap._northEast.lat > crsBounds.max.x) { + boundsMap._northEast.lat = crsBounds.max.x; + } + + if (boundsMap._northEast.lng > crsBounds.max.y) { + boundsMap._northEast.lng = crsBounds.max.y; + } + + if ((boundsMap._southWest.lat < 0 && boundsMap._southWest.lat < crsBounds.min.x) || + (boundsMap._southWest.lat > 0 && boundsMap._southWest.lat > crsBounds.min.x)) { + boundsMap._southWest.lat = crsBounds.min.x; + } + + if ((boundsMap._southWest.lng < 0 && boundsMap._southWest.lng < crsBounds.min.y) || + (boundsMap._southWest.lng > 0 && boundsMap._southWest.lng > crsBounds.min.y)) { + boundsMap._southWest.lng = crsBounds.min.y; + } + } + + return boundsMap; } }); diff --git a/addon/components/feature-result-item.js b/addon/components/feature-result-item.js index d4b628432..2ca338b23 100644 --- a/addon/components/feature-result-item.js +++ b/addon/components/feature-result-item.js @@ -8,13 +8,14 @@ import { translationMacro as t } from 'ember-i18n'; import openCloseSubmenu from 'ember-flexberry-gis/utils/open-close-sub-menu'; import { zoomToBounds } from '../utils/zoom-to-bounds'; import ResultFeatureInitializer from '../mixins/result-feature-initializer'; +import SlotsMixin from 'ember-block-slots'; /** Component for display GeoJSON feature object details @class FeatureResultItemComponent @extends Ember.Component */ -export default Ember.Component.extend(ResultFeatureInitializer, { +export default Ember.Component.extend(SlotsMixin, ResultFeatureInitializer, { /** Service for managing map API. @@ -600,15 +601,6 @@ export default Ember.Component.extend(ResultFeatureInitializer, { this.sendAction('findIntersection', this.get('feature')); }, - /** - * Action for search satellites - * @method actions.searchSatellites - */ - searchSatellites() { - this.set('isSubmenu', false); - this.sendAction('searchSatellites', this.get('feature')); - }, - /** Add feature to favorites list Action is sended to layer-result-list. diff --git a/addon/components/flexberry-edit-layer-feature.js b/addon/components/flexberry-edit-layer-feature.js index b87fc08f6..d82b44f86 100644 --- a/addon/components/flexberry-edit-layer-feature.js +++ b/addon/components/flexberry-edit-layer-feature.js @@ -4,7 +4,6 @@ import SnapDrawMixin from '../mixins/snap-draw'; import EditFeatureMixin from '../mixins/edit-feature'; import LeafletZoomToFeatureMixin from '../mixins/leaflet-zoom-to-feature'; import { translationMacro as t } from 'ember-i18n'; -import { getLeafletCrs } from '../utils/leaflet-crs'; import { addAlpha, splitColor } from '../utils/leaflet-opacity'; export default Ember.Component.extend(SnapDrawMixin, LeafletZoomToFeatureMixin, EditFeatureMixin, { @@ -778,8 +777,10 @@ export default Ember.Component.extend(SnapDrawMixin, LeafletZoomToFeatureMixin, // Removing a layer from the map that was added for edit mode if (leafletMap.hasLayer(layer)) { - layer.setStyle(layer.defaultFeatureStyle); - layer.styleIsSet = layer.defaultSetStyle; + if (!this.get('isLayerCopy')) { + layer.setStyle(layer.defaultFeatureStyle); + layer.styleIsSet = layer.defaultSetStyle; + } if (this.get('isLayerCopy')) { leafletMap.removeLayer(layer); @@ -893,81 +894,6 @@ export default Ember.Component.extend(SnapDrawMixin, LeafletZoomToFeatureMixin, } }, - /** - Sends request to trancate GeoWebCache for layer by boundingBox. - - @method trancateGeoWebCache - @param {Object} leafletObject laeflet layer. - */ - trancateGeoWebCache(leafletObject) { - let layers = leafletObject.wmsParams.layers.split(); - let workspace; - let layer; - let geoWebCache; - if (layers.length === 2) { - workspace = layers[0]; - layer = layers[1]; - } else { - let urlSplit = leafletObject._url.split('/'); - let indexGeoserver = urlSplit.indexOf('geoserver'); - if (indexGeoserver > -1 && urlSplit.length === indexGeoserver + 3) { - workspace = urlSplit.at(indexGeoserver + 1); - } else { - console.error('Can\'t get workspace in geoserver'); - return; - } - - layer = layers[0]; - } - - if (!Ember.isBlank(leafletObject._url.match(new RegExp('(https?|ftp)://(-\.)?([^\s/?\.#-]+\.?)+(/[^\s]*)?')))) { - let indexGeoserver = leafletObject._url.indexOf('geoserver'); - if (indexGeoserver === -1) { - console.error('Can\'t get url geoserver'); - return; - } - - geoWebCache = leafletObject._url.slice(0, indexGeoserver + 10) + '/gwc/rest/seed/'; - } - - if (!Ember.isNone(geoWebCache)) { - let url = geoWebCache + workspace + ':' + layer; - let gridSetId = leafletObject.wmsParams.crs + '_' + leafletObject.wmsParams.width; - let leafletMap = this.get('leafletMap'); - let zoom = Math.trunc(leafletMap.getZoom()); - let zoomStart = zoom - 1 > 0 ? zoom - 1 : zoom; - let zoomStop = zoom + 1 < 20 ? zoom + 1 : zoom; - let styles = leafletObject.wmsParams.styles; - let parameterStyles = ''; - if (!Ember.isNone(styles)) { - parameterStyles = `parameter_STYLES=${workspace}:${styles}&`; - } - - let crsName = leafletObject.wmsParams.crs; - let crs; - if (!Ember.isNone(crsName)) { - crs = getLeafletCrs('{ "code": "' + crsName.toUpperCase() + '", "definition": "" }', this); - } - - let bounds = leafletMap.getBounds(); - let minXY = L.marker(bounds._southWest).toProjectedGeoJSON(crs); - let maxXY = L.marker(bounds._northEast).toProjectedGeoJSON(crs); - - Ember.$.ajax({ - method: 'POST', - url: url, - async: true, - data: `threadCount=01&type=truncate&gridSetId=${gridSetId}&tileFormat=image%2Fpng&zoomStart=${zoomStart}&zoomStop=${zoomStop}&` + - `${parameterStyles}minX=${minXY.geometry.coordinates[0]}&minY=${minXY.geometry.coordinates[1]}` + - `&maxX=${maxXY.geometry.coordinates[0]}&maxY=${maxXY.geometry.coordinates[1]}`, - contentType: 'text/html', - error: function(data) { - console.error(data); - } - }); - } - }, - actions: { blockForm(block) { @@ -1172,8 +1098,10 @@ export default Ember.Component.extend(SnapDrawMixin, LeafletZoomToFeatureMixin, leafletObject.editLayer(layer); if (leafletMap.hasLayer(layer)) { - layer.setStyle(layer.defaultFeatureStyle); - layer.styleIsSet = layer.defaultSetStyle; + if (!this.get('isLayerCopy')) { + layer.setStyle(layer.defaultFeatureStyle); + layer.styleIsSet = layer.defaultSetStyle; + } if (this.get('isLayerCopy')) { // Deleting a copy of an edited layer from the map @@ -1248,8 +1176,9 @@ export default Ember.Component.extend(SnapDrawMixin, LeafletZoomToFeatureMixin, this.set('mode', 'Saved'); let _leafletObjectFirst = this.get('layerModel.layerModel._leafletObjectFirst'); + let leafletMap = this.get('leafletMap'); if (!Ember.isNone(_leafletObjectFirst) && typeof _leafletObjectFirst.setParams === 'function') { - this.trancateGeoWebCache(_leafletObjectFirst); + this.trancateGeoWebCache(_leafletObjectFirst, leafletMap); _leafletObjectFirst.setParams({ fake: Date.now() }, false); } diff --git a/addon/components/flexberry-identify-file.js b/addon/components/flexberry-identify-file.js index 28f65bdc3..4a46da2e7 100644 --- a/addon/components/flexberry-identify-file.js +++ b/addon/components/flexberry-identify-file.js @@ -28,11 +28,26 @@ export default Ember.Component.extend(CheckFileMixin, { */ geometryField2: null, + /** + Necessity of geometry field names (one (with WKT geometry) or two (X,Y coordinates - points only)) + geometryField1 and geometryField2 + For .csv, .xls, .xlsx + */ needGeometryFieldName: false, - acceptFiles: null, + /** + Necessity of geometry type. For .gpx (it contains different types of data and can be transformed to different types of data) + */ + needGeometryType: false, + + /** + Necessity of "not auto" CRS + */ + needCRS: false, + + acceptFiles: '.zip,.GEOJSON,.gml,.xls,.xlsx,.csv,.xml,.gpx,.kml', - importErrorMessage: 'Загруженный файл не соответствует требованиям: ', + importErrorMessage: 'Загруженный файл не соответствует требованиям', emptyErrorMessage: 'Файл не содержит геометрических объектов', @@ -42,11 +57,10 @@ export default Ember.Component.extend(CheckFileMixin, { typeGeometryErrorMessage: 'Указанный тип геометрии противоречит объектам в файле', - warningMessageSRS: 'Укажите верную систему координат, указанную в загружаемом файле. ' + - 'При выборе ошибочной системы координат слой может некорректно отображаться на карте', - warningMessageEmptyGeometry: 'В файле обнаружены объекты без геометрии. Дальнейшая загрузка будет осуществлена без них', + warningMessageAutoCRS: 'У загруженного файла не определена система координат. Выберите систему координат из списка', + emptyGeometryField: 'Укажите название поля с геометрией в файле (WKT/X,Y)', /** @@ -67,18 +81,11 @@ export default Ember.Component.extend(CheckFileMixin, { }); }, - setAcceptFiles() { - if (Ember.isEmpty(this.get('acceptFiles'))) { - this.set('acceptFiles', '.zip,.GEOJSON,.gml,.xls,.xlsx,.csv,.xml,.gps,.kml'); - } - }, - didInsertElement() { this._super(...arguments); this.set('systemCoordinates', this.get('systemCoordinates') || availableCoordinateReferenceSystemsCodesWithCaptions(this)); this.set('coordinate', 'auto'); - this.setAcceptFiles(); this.send('clearFile'); }, @@ -121,7 +128,7 @@ export default Ember.Component.extend(CheckFileMixin, { @method fieldsSet */ - fieldsSet: Ember.observer('file', 'needGeometryFieldName', 'geometryField1', 'geometryField2', function() { + fieldsSet: Ember.observer('file', 'needGeometryFieldName', 'geometryField1', 'geometryField2', function () { let file = this.get('file'); if (this.get('needGeometryFieldName') && !Ember.isNone(file)) { let geometryField1 = this.get('geometryField1'); @@ -134,11 +141,11 @@ export default Ember.Component.extend(CheckFileMixin, { }), /** - Get headers fields from csv or xls file. + Get headers fields from csv or xls|xlsx file. - @method getFieldsFromCsv + @method getFields */ - getFieldsFromCsv() { + getFields() { this.set('_showError', false); let config = Ember.getOwner(this).resolveRegistration('config:environment'); let data = new FormData(); @@ -154,29 +161,27 @@ export default Ember.Component.extend(CheckFileMixin, { processData: false, }).done((response) => { if (response && response.length) { - const items = response.split(','); - this.set('_availableFields', Ember.A(items)); - this.set('needGeometryFieldName', true); + this.set('_availableFields', Ember.A(response)); } else { - this.set('_errorMessage', this.get('importErrorMessage') + this.get('emptyHeaderErrorMessage')); + this.set('_errorMessage', this.get('emptyHeaderErrorMessage')); this.set('_showError', true); - this.set('needGeometryFieldName', false); - this.set('needGeometryType', false); } }).fail(() => { let message = this.get('badFileMessage'); - this.set('_errorMessage', this.get('importErrorMessage') + message); + this.set('_errorMessage', message); this.set('_showError', true); - this.set('needGeometryFieldName', false); - this.set('needGeometryType', false); }); } }, actions: { - onCoordinateChange() { + clearCacheAndPreview() { this.set('_showError', false); this.clearAjax(); + if (this.get('filePreview')) { + this.get('mapApi').getFromApi('leafletMap').fire(`flexberry-map-loadfile${this.get('suffix')}:clear`); + this.set('filePreview', false); + } }, clearFile() { @@ -184,6 +189,7 @@ export default Ember.Component.extend(CheckFileMixin, { this.set('coordinate', 'auto'); this.set('needGeometryFieldName', false); this.set('needGeometryType', false); + this.set('needCRS', false); this.set('geometryField1', null); this.set('geometryField2', null); this.set('geometryFieldFile', null); @@ -201,19 +207,33 @@ export default Ember.Component.extend(CheckFileMixin, { this.$('.ui.button.remove').addClass('hidden'); }, + /** + * Выбор пользователем файла + */ clickFile(e) { let file = e.target.files[0]; + if (!file) { + return; + } + let fileName = file.name; - let ext = fileName.substring(fileName.indexOf('.'), fileName.length); + let ext = fileName.substring(fileName.lastIndexOf('.'), fileName.length).toLowerCase(); this.set('file', file); - if (ext.toLowerCase() === '.csv' || ext.toLowerCase() === '.xls' || ext.toLowerCase() === '.xlsx') { + if (ext === '.csv' || ext === '.xls' || ext === '.xlsx') { this.set('needGeometryFieldName', true); - this.getFieldsFromCsv(); - this.set('warningMessage', this.get('warningMessageSRS')); + this.getFields(); + } + + if (ext === '.gpx' || ext === '.kml') { + this.set('coordinate', 'EPSG:4326'); + } + + if (ext === '.gpx' || ext === '.gml' || ext === '.csv' || ext === '.xls' || ext === '.xlsx') { + this.set('needCRS', true); } - if (ext.toLowerCase() === '.gpx') { + if (ext === '.gpx') { this.set('needGeometryType', true); } diff --git a/addon/components/flexberry-layers-attributes-panel.js b/addon/components/flexberry-layers-attributes-panel.js index 600e11b31..36f69eb93 100644 --- a/addon/components/flexberry-layers-attributes-panel.js +++ b/addon/components/flexberry-layers-attributes-panel.js @@ -948,6 +948,12 @@ export default Ember.Component.extend(SnapDrawMixin, LeafletZoomToFeatureMixin, this.set('loading', false); tabModel._reload(); leafletObject.off('save:failed', saveFailed); + + let _leafletObjectFirst = tabModel.layerModel._leafletObjectFirst; + if (!Ember.isNone(_leafletObjectFirst) && typeof _leafletObjectFirst.setParams === 'function') { + this.trancateGeoWebCache(_leafletObjectFirst, leafletMap); + _leafletObjectFirst.setParams({ fake: Date.now() }, false); + } }; this.set('loading', true); diff --git a/addon/components/flexberry-search-panel.js b/addon/components/flexberry-search-panel.js index 1cf91754e..23df28355 100644 --- a/addon/components/flexberry-search-panel.js +++ b/addon/components/flexberry-search-panel.js @@ -184,6 +184,8 @@ export default Ember.Component.extend({ actions: { querySearch() { + this.sendAction('clearSearch'); + if (this.get('attrVisible')) { if (Ember.isNone(this.get('_selectedLayer'))) { this.set('errorMessage', this.get('i18n').t('components.flexberry-search.error-message-empty-selected-layer')); @@ -275,6 +277,8 @@ export default Ember.Component.extend({ }, attrSearch() { + this.sendAction('clearSearch'); + let attrVisible = !this.get('attrVisible'); if (attrVisible) { this.set('attrVisible', attrVisible); diff --git a/addon/components/flexberry-simpledatetime.js b/addon/components/flexberry-simpledatetime.js index a3f705474..f112e65af 100644 --- a/addon/components/flexberry-simpledatetime.js +++ b/addon/components/flexberry-simpledatetime.js @@ -49,9 +49,21 @@ export default SimpleDatetime.extend({ this.set('eventNamespace', namespace); Ember.$(document).on(`mousedown.${namespace}`, e => { let clicky = Ember.$(e.target); - if (clicky.closest('.flatpickr-calendar').length === 0 && clicky.get(0) !== this.$('.custom-flatpickr').get(0)) { - this.get('_flatpickr').close(); + let flatpickr = this.get('_flatpickr'); + + if (!flatpickr) { + return; + } + + if (clicky.closest('.flatpickr-calendar').length > 0) { + return; } + + if (clicky.get(0) === this.$('.custom-flatpickr').get(0)) { + return; + } + + flatpickr.close(); }); this.$('.custom-flatpickr').on('click', (e) => { this.inputClick(this, e); }); this.$('.button').on('click', (e) => { this.actions.remove(this, e); }); diff --git a/addon/components/geometry-add-modes/draw.js b/addon/components/geometry-add-modes/draw.js index 8214e39a0..b925f81de 100644 --- a/addon/components/geometry-add-modes/draw.js +++ b/addon/components/geometry-add-modes/draw.js @@ -306,12 +306,14 @@ let FlexberryGeometryAddModeDrawComponent = Ember.Component.extend({ } let label = this.get('_dragLayer._label'); - let zoom = Number(this.get('leafletMap').getZoom().toFixed(1)); - let labelZooms = label.filter(l => { return (l.minZoom == null || l.minZoom <= zoom) && (l.maxZoom == null || l.maxZoom >= zoom); }); - if (labelZooms.length > 0) { - let labelZoom = labelZooms[0]; - newCoords = moveCoords(labelZoom.getLatLng()); - labelZoom.setLatLng(newCoords); + if (label) { + let zoom = Number(this.get('leafletMap').getZoom().toFixed(1)); + let labelZooms = label.filter(l => { return (l.minZoom == null || l.minZoom <= zoom) && (l.maxZoom == null || l.maxZoom >= zoom); }); + if (labelZooms.length > 0) { + let labelZoom = labelZooms[0]; + newCoords = moveCoords(labelZoom.getLatLng()); + labelZoom.setLatLng(newCoords); + } } }; diff --git a/addon/components/layer-result-list.js b/addon/components/layer-result-list.js index 09fcff55d..f56c86230 100644 --- a/addon/components/layer-result-list.js +++ b/addon/components/layer-result-list.js @@ -6,6 +6,7 @@ import Ember from 'ember'; import layout from '../templates/components/layer-result-list'; import LeafletZoomToFeatureMixin from '../mixins/leaflet-zoom-to-feature'; import ResultFeatureInitializer from '../mixins/result-feature-initializer'; +import SlotsMixin from 'ember-block-slots'; // Url key used to identify transitions from ember-flexberry-gis on other resources. const isMapLimitKey = 'GISLinked'; @@ -17,7 +18,7 @@ const isMapLimitKey = 'GISLinked'; @uses LeafletZoomToFeatureMixin @extends Ember.Component */ -export default Ember.Component.extend(LeafletZoomToFeatureMixin, ResultFeatureInitializer, { +export default Ember.Component.extend(SlotsMixin, LeafletZoomToFeatureMixin, ResultFeatureInitializer, { /** Service for managing map API. @@ -260,14 +261,6 @@ export default Ember.Component.extend(LeafletZoomToFeatureMixin, ResultFeatureIn this.sendAction('showIntersectionPanel', feature); }, - /** - * Search satellite action - * @param feature - */ - searchSatellites(feature) { - this.sendAction('showSatellitePanel', feature); - }, - /** Action adds feature to favorites. diff --git a/addon/components/layers/odata-vector-layer.js b/addon/components/layers/odata-vector-layer.js index 1486be369..892b77777 100644 --- a/addon/components/layers/odata-vector-layer.js +++ b/addon/components/layers/odata-vector-layer.js @@ -209,7 +209,7 @@ export default BaseVectorLayer.extend({ }); }); - this._createStringLabel([layer], leafletObject.labelsLayers); + this._createStringLabel([layer], leafletObject); } }, @@ -1517,9 +1517,12 @@ export default BaseVectorLayer.extend({ if ((continueLoad && show && checkMapZoom(leafletObject)) || (showLayerObjects && continueLoad)) { let loadedBounds = this.get('loadedBounds'); - let leafletMap = this.get('leafletMap'); let obj = this.get('_adapterStoreModelProjectionGeom'); - let bounds = L.rectangle(leafletMap.getBounds()); + + let boundsMap = this._boundsCrs(leafletObject); + + let bounds = L.rectangle(boundsMap); + if (!Ember.isNone(leafletObject.showLayerObjects)) { leafletObject.showLayerObjects = false; } diff --git a/addon/components/layers/wfs-layer.js b/addon/components/layers/wfs-layer.js index a373195df..ce565e4a8 100644 --- a/addon/components/layers/wfs-layer.js +++ b/addon/components/layers/wfs-layer.js @@ -244,7 +244,7 @@ export default BaseVectorLayer.extend({ }); }); - this._createStringLabel([layer], leafletObject.labelsLayers); + this._createStringLabel([layer], leafletObject); } }, @@ -613,7 +613,7 @@ export default BaseVectorLayer.extend({ break; case 'date': let dateInfo = getDateFormatFromString(e.searchOptions.queryString); - let searchDate = moment.utc(e.searchOptions.queryString, dateInfo.dateFormat + dateInfo.timeFormat, true); + let searchDate = moment(e.searchOptions.queryString, dateInfo.dateFormat + dateInfo.timeFormat, true); if (dateInfo.dateFormat && searchDate.isValid()) { let [startInterval, endInterval] = createTimeInterval(searchDate, dateInfo.dateFormat); @@ -891,7 +891,6 @@ export default BaseVectorLayer.extend({ leafletObject = this.returnLeafletObject(); } - let leafletMap = this.get('leafletMap'); if (!Ember.isNone(leafletObject)) { let show = this.get('visibility') || (!Ember.isNone(leafletObject.showLayerObjects) && leafletObject.showLayerObjects); let continueLoad = !leafletObject.options.showExisting && leafletObject.options.continueLoading; @@ -899,7 +898,8 @@ export default BaseVectorLayer.extend({ let needPromise = false; if (continueLoad && show && checkMapZoom(leafletObject)) { - let bounds = leafletMap.getBounds(); + let bounds = this._boundsCrs(leafletObject); + if (!Ember.isNone(leafletObject.showLayerObjects)) { leafletObject.showLayerObjects = false; } diff --git a/addon/components/legends/-private/vector-legend.js b/addon/components/legends/-private/vector-legend.js index fb0019561..b9c347d20 100644 --- a/addon/components/legends/-private/vector-legend.js +++ b/addon/components/legends/-private/vector-legend.js @@ -22,7 +22,7 @@ export default BaseLegendComponent.extend({ @private @readOnly */ - _styleSettingsRelatedComponentName: Ember.computed('layer.settingsAsObject.styleSettings.type', function() { - return `legends/layers-styles/${this.get('layer.settingsAsObject.styleSettings.type')}`; + _styleSettingsRelatedComponentName: Ember.computed('layer.styleSettingsTypeForLegend', function() { + return `legends/layers-styles/${this.get('layer.styleSettingsTypeForLegend')}`; }) }); diff --git a/addon/components/legends/layers-styles/-private/base.js b/addon/components/legends/layers-styles/-private/base.js index e3d80eadc..70d502b52 100644 --- a/addon/components/legends/layers-styles/-private/base.js +++ b/addon/components/legends/layers-styles/-private/base.js @@ -18,7 +18,8 @@ const flexberryClassNames = { imageWrapper: 'layer-legend-image-wrapper', image: 'layer-legend-image', caption: 'layer-legend-caption', - zoom: 'layer-legend-zoom' + zoom: 'layer-legend-zoom', + marker: 'layer-legend-marker' }; /** diff --git a/addon/components/legends/layers-styles/simple.js b/addon/components/legends/layers-styles/simple.js index ef7ce9f54..fc3aa59e8 100644 --- a/addon/components/legends/layers-styles/simple.js +++ b/addon/components/legends/layers-styles/simple.js @@ -74,12 +74,23 @@ export default BaseLayerStyleLegendComponent.extend({ } if (this.get('_markersCanBeDisplayed')) { - let style = styleRule.styleSettings.style.marker; - let canvas = this.$(`canvas.markers${index}`)[0]; - this._markerLegendRenderer(style, canvas); + let styles = styleRule.styleSettings.style.marker; + if (styles.hasOwnProperty('scale')) { + return; + } + + let markersStylesRenderer = this.get('_markersStylesRenderer'); + let scale = markersStylesRenderer.calcScale(styles); + styles.scale = scale; + Ember.set(styleRule, 'width', scale.size); + Ember.set(styleRule, 'height', scale.size); + + styles.forEach(style => { + markersStylesRenderer.getStyle(scale, style); + }); + } }); - } else { this._withoutStyleRules(); } @@ -93,9 +104,17 @@ export default BaseLayerStyleLegendComponent.extend({ } if (this.get('_markersCanBeDisplayed')) { - let styleSettings = Ember.isNone(this.parentView.layer.legendStyle) ? this.get('styleSettings.style.marker') : this.parentView.layer.legendStyle; - let canvas = this.$('canvas.markers')[0]; - this._markerLegendRenderer(styleSettings, canvas); + let styles = Ember.isNone(this.parentView.layer.legendStyle) ? this.get('styleSettings.style.marker') : this.parentView.layer.legendStyle; + if (styles.hasOwnProperty('scale')) { + return; + } + + let markersStylesRenderer = this.get('_markersStylesRenderer'); + let scale = markersStylesRenderer.calcScale(styles); + styles.scale = scale; + this.set('width', scale.size); + this.set('height', scale.size); + markersStylesRenderer.getStyle(scale, styles); } }, @@ -114,14 +133,5 @@ export default BaseLayerStyleLegendComponent.extend({ canvas: canvas, target: 'legend' }); - }, - - _markerLegendRenderer(styleSettings, canvas) { - let markersStylesRenderer = this.get('_markersStylesRenderer'); - markersStylesRenderer.renderOnCanvas({ - styleSettings: styleSettings, - canvas: canvas, - target: 'legend' - }); - }, + } }); diff --git a/addon/initializers/leaflet-canvas.js b/addon/initializers/leaflet-canvas.js index 65770cb5a..52db0d776 100644 --- a/addon/initializers/leaflet-canvas.js +++ b/addon/initializers/leaflet-canvas.js @@ -40,6 +40,35 @@ export function initialize() { } }, + /** + @method _updateCircle + Override https://github.com/Leaflet/Leaflet/blob/main/src/layer/vector/Canvas.js#L302 + Get ctx and call _fillStroke. + */ + _updateCircle: function (layer) { + + if (!this._drawing || layer._empty()) { return; } + + let p = layer._point; + let ctx = this._ctx; + let r = Math.max(Math.round(layer._radius), 1); + let s = (Math.max(Math.round(layer._radiusY), 1) || r) / r; + + if (s !== 1) { + ctx.save(); + ctx.scale(1, s); + } + + ctx.beginPath(); + ctx.arc(p.x, p.y / s, r, 0, Math.PI * 2, false); + + if (s !== 1) { + ctx.restore(); + } + + this._fillStroke(ctx, layer.options); + }, + /** @method _fillStroke Override https://github.com/Leaflet/Leaflet/blob/main/src/layer/vector/Canvas.js#L326 diff --git a/addon/initializers/leaflet-path.js b/addon/initializers/leaflet-path.js index 4aa8f5ca7..f97490556 100644 --- a/addon/initializers/leaflet-path.js +++ b/addon/initializers/leaflet-path.js @@ -6,17 +6,43 @@ import Ember from 'ember'; export function initialize() { let setStyle = { setStyle: function (style) { - L.Path.prototype.setStyle.call(this, style); - if (!Ember.isNone(this.layerModel) && Ember.isNone(this.layerModel.legendStyle)) { - this.layerModel.legendStyle = { - type: 'simple', - style: { - path: style + if (style) { + if (this.options.count) { + for (let i = 0; i < this.options.count; i++) { + if (!style.count) { + this.setStyleCustom(this, this.options[i], style); + } else { + L.Path.prototype.setStyle.call(this, style); + } } - }; + } else { + L.Path.prototype.setStyle.call(this, style); + } + + if (!Ember.isNone(this.layerModel) && Ember.isNone(this.layerModel.legendStyle)) { + this.layerModel.legendStyle = { + type: 'simple', + style: { + path: style + } + }; + } } return this; + }, + + setStyleCustom(layer, options, style) { + for (var j in style) { + options[j] = style[j]; + } + + if (layer._renderer) { + layer._renderer._updateStyle(layer); + if (options.stroke && style && style.hasOwnProperty('weight')) { + layer._updateBounds(); + } + } } }; diff --git a/addon/layers-styles/simple.js b/addon/layers-styles/simple.js index 26c0bc9c6..45062eca2 100644 --- a/addon/layers-styles/simple.js +++ b/addon/layers-styles/simple.js @@ -57,10 +57,10 @@ export default BaseLayerStyle.extend({ if (Ember.isNone(path.styleIsSet) || !path.styleIsSet) { let pathStyle = style.path || {}; if (Ember.isArray(pathStyle)) { - pathStyle.forEach(style => { - style = Ember.$.extend(true, {}, style, { + pathStyle.forEach(styleInner => { + styleInner = Ember.$.extend(true, {}, styleInner, { // Fill must be disabled for non polygon layers, because filled polylines and other lines-like geometries looks ugly in leaflet. - fill: style.fill === true && path instanceof L.Polygon + fill: styleInner.fill === true && path instanceof L.Polygon }); }); pathStyle.count = pathStyle.length; diff --git a/addon/layers/-private/base.js b/addon/layers/-private/base.js index c91dfc0f4..23b5385be 100644 --- a/addon/layers/-private/base.js +++ b/addon/layers/-private/base.js @@ -142,6 +142,36 @@ export default Ember.Object.extend({ return settings; }, + /** + Type of legend. + @property getLegendType + @type String + @readOnly + */ + getLegendType(type, settingsAsObject) { + return type; + }, + + /** + Settings of legend. + @property getLegendSettings + @type Object + @readOnly + */ + getLegendSettings(settingsAsObject) { + return settingsAsObject.legendSettings; + }, + + /** + Type of legend from style settings. + @property getStyleSettingsTypeForLegend + @type String + @readOnly + */ + getStyleSettingsTypeForLegend(settingsAsObject) { + return settingsAsObject.styleSettings.type; + }, + /** Creates new settings object (with settings related to layer-type) from the specified CSW record. diff --git a/addon/layers/wms-wfs.js b/addon/layers/wms-wfs.js index 291b311de..6719cdcbe 100644 --- a/addon/layers/wms-wfs.js +++ b/addon/layers/wms-wfs.js @@ -56,6 +56,48 @@ export default WmsLayer.extend({ return settings; }, + /** + Type of legend. + @property getLegendType + @type String + @readOnly + */ + getLegendType(type, settingsAsObject) { + if (settingsAsObject.remoteStyles === false) { + return 'wfs'; + } + + return type; + }, + + /** + Settings of legend. + @property getLegendSettings + @type Object + @readOnly + */ + getLegendSettings(settingsAsObject) { + if (settingsAsObject.remoteStyles === false) { + return settingsAsObject.wfs.legendSettings; + } + + return settingsAsObject.legendSettings; + }, + + /** + Type of legend from style settings. + @property getStyleSettingsTypeForLegend + @type String + @readOnly + */ + getStyleSettingsTypeForLegend(settingsAsObject) { + if (settingsAsObject.remoteStyles === false) { + return settingsAsObject.wfs.styleSettings.type; + } + + return settingsAsObject.styleSettings.type; + }, + /** Creates new search settings object (with search settings related to layer-type). diff --git a/addon/markers-styles/default.js b/addon/markers-styles/default.js index 8e58ff509..dc7b7a833 100644 --- a/addon/markers-styles/default.js +++ b/addon/markers-styles/default.js @@ -54,11 +54,11 @@ export default BaseMarkerStyle.extend({ @param {Object} options.style Hash containing style settings. @param {Object} [options.target = 'preview'] Render target ('preview' or 'legend'). */ - renderOnCanvas({ canvas, style, target }) { + renderOnCanvas({ canvas, style, target, scale }) { // Default 'image' markers-style's settings are settings for leaflet default image icon (L.Icon.Default), // so we can reuse 'image' markers-style here. let markersStylesRenderer = this.get('_markersStylesRenderer'); let defaultMarkerStyleSettings = markersStylesRenderer.getDefaultStyleSettings('image'); - markersStylesRenderer.renderOnCanvas({ canvas, styleSettings: defaultMarkerStyleSettings, target }); + markersStylesRenderer.renderOnCanvas({ canvas, styleSettings: defaultMarkerStyleSettings, target, scale }); } }); diff --git a/addon/markers-styles/image.js b/addon/markers-styles/image.js index 0484cd383..ee2c1ad5c 100644 --- a/addon/markers-styles/image.js +++ b/addon/markers-styles/image.js @@ -36,7 +36,9 @@ export default BaseMarkerStyle.extend({ shadowSize: [41, 41], // Shadow icon anchor relative to it's size. - shadowAnchor: [12, 41] + shadowAnchor: [12, 41], + + iconType: 'default' }; }, @@ -52,82 +54,5 @@ export default BaseMarkerStyle.extend({ if (Ember.isNone(marker.styleIsSet) || !marker.styleIsSet) { marker.setIcon(new L.Icon(style)); } - }, - - /** - Renderes marker-style preview on the specified canvas element. - - @method renderOnCanvas - @param {Object} options Method options. - @param {Canvas} options.canvas Canvas element on which marker-style preview must be rendered. - @param {Object} options.style Hash containing style settings. - @param {Object} [options.target = 'preview'] Render target ('preview' or 'legend'). - */ - renderOnCanvas({ canvas, style, target }) { - let width = canvas.width; - let height = canvas.height; - let ctx = canvas.getContext('2d'); - - // Clear canvas. - ctx.clearRect(0, 0, width, height); - - var iconImage = new Image(); - iconImage.onload = function() { - // Draw loaded image. - let iconWidth = style.iconSize[0] || iconImage.width; - let iconHeight = style.iconSize[1] || iconImage.height; - - let scale = iconWidth > width || iconHeight > height ? - Math.min(width / iconWidth, height / iconHeight) : - 1; - let xOffset = (width - iconWidth * scale) / 2; - let yOffset = (height - iconHeight * scale) / 2; - - let drawIconImage = function() { - ctx.drawImage(iconImage, xOffset, yOffset, iconWidth * scale, iconHeight * scale); - }; - - if (Ember.isBlank(style.shadowUrl)) { - drawIconImage(); - } else { - let shadowImage = new Image(); - shadowImage.onload = function() { - // Draw shadow icon. - let shadowWidth = style.shadowSize[0] || shadowImage.width; - let sadowHeight = style.shadowSize[1] || shadowImage.height; - - let xShadowOffset = style.iconAnchor[0] - style.shadowAnchor[0]; - let yShadowOffset = style.iconAnchor[1] - style.shadowAnchor[1]; - ctx.drawImage(shadowImage, xOffset + xShadowOffset, yOffset + yShadowOffset, shadowWidth * scale, sadowHeight * scale); - - // Draw marker icon. - drawIconImage(); - }; - - shadowImage.onerror = function() { - // Shadow is optional, so draw marker icon anyway. - drawIconImage(); - }; - - // Set shadow image src to start loading. - shadowImage.src = style.shadowUrl; - } - }; - - iconImage.onerror = function() { - // Draw red cross instead of image. - ctx.moveTo(0, 0); - ctx.lineTo(width, height); - - ctx.moveTo(width, 0); - ctx.lineTo(0, height); - - ctx.lineWidth = 4; - ctx.strokeStyle = '#ff0000'; - ctx.stroke(); - }; - - // Set image src to start loading. - iconImage.src = style.iconUrl; } }); diff --git a/addon/mixins/edit-feature.js b/addon/mixins/edit-feature.js index 75836b72c..ac54c8343 100644 --- a/addon/mixins/edit-feature.js +++ b/addon/mixins/edit-feature.js @@ -1,5 +1,6 @@ import Ember from 'ember'; +import { getLeafletCrs } from '../utils/leaflet-crs'; export default Ember.Mixin.create({ @@ -54,5 +55,80 @@ export default Ember.Mixin.create({ return L.geoJson(layer.toGeoJSON(), { pane: 'zoomto' }).setStyle(this.get('zoomFeatureStyle')); + }, + + /** + Sends request to trancate GeoWebCache for layer by boundingBox. + + @method trancateGeoWebCache + @param {Object} leafletObject laeflet layer. + @param {Object} leafletMap laeflet map. + */ + trancateGeoWebCache(leafletObject, leafletMap) { + let layers = leafletObject.wmsParams.layers.split(); + let workspace; + let layer; + let geoWebCache; + if (layers.length === 2) { + workspace = layers[0]; + layer = layers[1]; + } else { + let urlSplit = leafletObject._url.split('/'); + let indexGeoserver = urlSplit.indexOf('geoserver'); + if (indexGeoserver > -1 && urlSplit.length === indexGeoserver + 3) { + workspace = urlSplit.at(indexGeoserver + 1); + } else { + console.error('Can\'t get workspace in geoserver'); + return; + } + + layer = layers[0]; + } + + if (!Ember.isBlank(leafletObject._url.match(new RegExp('(https?|ftp)://(-\.)?([^\s/?\.#-]+\.?)+(/[^\s]*)?')))) { + let indexGeoserver = leafletObject._url.indexOf('geoserver'); + if (indexGeoserver === -1) { + console.error('Can\'t get url geoserver'); + return; + } + + geoWebCache = leafletObject._url.slice(0, indexGeoserver + 10) + '/gwc/rest/seed/'; + } + + if (!Ember.isNone(geoWebCache)) { + let url = geoWebCache + workspace + ':' + layer; + let gridSetId = leafletObject.wmsParams.crs + '_' + leafletObject.wmsParams.width; + let zoom = Math.trunc(leafletMap.getZoom()); + let zoomStart = zoom - 1 > 0 ? zoom - 1 : zoom; + let zoomStop = zoom + 1 < 20 ? zoom + 1 : zoom; + let styles = leafletObject.wmsParams.styles; + let parameterStyles = ''; + if (!Ember.isNone(styles)) { + parameterStyles = `parameter_STYLES=${workspace}:${styles}&`; + } + + let crsName = leafletObject.wmsParams.crs; + let crs; + if (!Ember.isNone(crsName)) { + crs = getLeafletCrs('{ "code": "' + crsName.toUpperCase() + '", "definition": "" }', this); + } + + let bounds = leafletMap.getBounds(); + let minXY = L.marker(bounds._southWest).toProjectedGeoJSON(crs); + let maxXY = L.marker(bounds._northEast).toProjectedGeoJSON(crs); + + Ember.$.ajax({ + method: 'POST', + url: url, + async: true, + data: `threadCount=01&type=truncate&gridSetId=${gridSetId}&tileFormat=image%2Fpng&zoomStart=${zoomStart}&zoomStop=${zoomStop}&` + + `${parameterStyles}minX=${minXY.geometry.coordinates[0]}&minY=${minXY.geometry.coordinates[1]}` + + `&maxX=${maxXY.geometry.coordinates[0]}&maxY=${maxXY.geometry.coordinates[1]}`, + contentType: 'text/html', + error: function (data) { + console.error(data); + } + }); + } } }); diff --git a/addon/mixins/flexberry-check-file.js b/addon/mixins/flexberry-check-file.js index 22b260831..ca59edc3c 100644 --- a/addon/mixins/flexberry-check-file.js +++ b/addon/mixins/flexberry-check-file.js @@ -49,6 +49,10 @@ export default Ember.Mixin.create({ let layer = null; try { + let features = response.features.filter((feature) => { + return !Ember.isNone(feature.geometry) && feature.geometry.coordinates.flat(5).length > 0; + }); + response.features = features; layer = this._createLayer(response, crs); } catch (ex) { @@ -109,7 +113,7 @@ export default Ember.Mixin.create({ let ajax = this.get('fileLoadAjax'); if (ajax) { if (ajax.readyState === 4 && ajax.status === 200) { - resolve(this.get('fileLoadAjax').responseJSON); + resolve(JSON.parse(this.get('fileLoadAjax').responseText || '{}')); return; } @@ -126,7 +130,7 @@ export default Ember.Mixin.create({ let url = `${config.APP.backendUrls.geomFileValidationUrl}?FileName=${file.name}`; let data = new FormData(); data.append(file.name, file); - data.append('crs', this.get('coordinate')); + data.append('fileCrs', this.get('coordinate')); if (this.get('needGeometryType')) { data.append('typeGeometryLayer', this.get('_geometryType')); @@ -149,11 +153,12 @@ export default Ember.Mixin.create({ processData: false }).done((response) => { this._showHideLoader(false); - if (response && response.features) { - this.set('coordinate', response.definedCrs); - this.set('geometryType', this.getGeometryType(response.features[0].geometry.type)); + let jsonResponse = JSON.parse(response || '{}'); + if (jsonResponse.features) { + this.set('coordinate', jsonResponse.definedCrs); + this.set('geometryType', this.getGeometryType(jsonResponse.features[0].geometry.type)); - resolve(response); + resolve(jsonResponse); } else { reject({ message: this.get('emptyErrorMessage') diff --git a/addon/mixins/flexberry-map-model-api.js b/addon/mixins/flexberry-map-model-api.js index dccf13634..fe7d684bb 100644 --- a/addon/mixins/flexberry-map-model-api.js +++ b/addon/mixins/flexberry-map-model-api.js @@ -1214,7 +1214,7 @@ export default Ember.Mixin.create(SnapDraw, actionsHandler, { return new Ember.RSVP.Promise((resolve, reject) => { Ember.$.ajax({ - url: `${config.APP.backendUrl}/controls/FileUploaderHandler.ashx?FileName=${file.name}`, + url: `${config.APP.backendUrls.fileUploadUrl}?FileName=${file.name}`, type: 'POST', data: data, cache: false, diff --git a/addon/mixins/flexberry-maplayer-actions-handler.js b/addon/mixins/flexberry-maplayer-actions-handler.js index 9064a1ee6..55dc70edc 100644 --- a/addon/mixins/flexberry-maplayer-actions-handler.js +++ b/addon/mixins/flexberry-maplayer-actions-handler.js @@ -404,7 +404,7 @@ export default Ember.Mixin.create({ let rootArray = this.get(rootPath); rootArray.pushObject(childLayer); - setIndexes(rootArray, this.get('model.hierarchy')); + setIndexes(rootArray, this.get('model.otherLayers')); }, /** @@ -539,7 +539,7 @@ export default Ember.Mixin.create({ let rootArray = this.get(rootPath); - setIndexes(rootArray, this.get('model.hierarchy')); + setIndexes(rootArray, this.get('model.otherLayers')); } }, diff --git a/addon/mixins/layer-label.js b/addon/mixins/layer-label.js index 799ef04fc..aceff1526 100644 --- a/addon/mixins/layer-label.js +++ b/addon/mixins/layer-label.js @@ -206,7 +206,7 @@ export default Ember.Mixin.create({ @param {Object} layer layer @return {String} string with replaced property */ - _applyProperty(str, layer) { + _applyProperty(str, layer, leafletObject) { let hasReplace = false; let propName; @@ -230,7 +230,7 @@ export default Ember.Mixin.create({ } if (property && layer.feature.properties && layer.feature.properties.hasOwnProperty(property)) { - str = this._labelValue(layer, property, prop, str); + str = this._labelValue(layer, property, prop, str, leafletObject); } } } @@ -242,8 +242,11 @@ export default Ember.Mixin.create({ } }, - _labelValue(layer, property, prop, str) { - let leafletObject = this.returnLeafletObject(); + _labelValue(layer, property, prop, str, leafletObject) { + if (Ember.isNone(leafletObject)) { + leafletObject = this.returnLeafletObject(); + } + let readFormat = Ember.get(leafletObject, 'readFormat.featureType.fieldTypes'); let label = layer.feature.properties[property]; let dateTimeFormat = this.displaySettings.dateTimeFormat; @@ -329,9 +332,8 @@ export default Ember.Mixin.create({ @method _showLabelsMovingMap */ _showLabelsMovingMap() { - let labelsLayers = this.get('labelsLayers'); let leafletObject = this.returnLeafletObject(); - this._createStringLabel(leafletObject.getLayers(), labelsLayers); + this._createStringLabel(leafletObject.getLayers(), leafletObject); }, /** @@ -340,7 +342,7 @@ export default Ember.Mixin.create({ @method _createStringLabel @param {Array} layers new layers for add labels */ - _createStringLabel(layers) { + _createStringLabel(layers, leafletObject) { if (layers) { let labelsLayerZoom = this._getLabelsLayersZoom(); if (labelsLayerZoom) { @@ -358,7 +360,7 @@ export default Ember.Mixin.create({ `text-align: ${Ember.get(optionsLabel, 'captionFontAlign')};${halo}`); this._checkLabelInView(layers, labelsLayerZoom).forEach(layer => { - let label = layer.labelValue || this._applyFunction(this._applyProperty(labelSettingsString, layer)); + let label = layer.labelValue || this._applyFunction(this._applyProperty(labelSettingsString, layer, leafletObject)); this._createLabel(label, layer, style, labelsLayerZoom); }); } @@ -426,21 +428,28 @@ export default Ember.Mixin.create({ let className = 'label'; className += ' point ' + positionPoint.cssClass; let html = '
' + text + '
'; - let optionsMarker = this._optionsMarker(latlng, className, html, iconWidth, iconHeight, anchor); + let optionsMarker = this._optionsMarker(latlng, className, html, positionPoint.iconSize, anchor); let label = this._createLabelMarker(layer, optionsMarker, labelsLayerZoom._paneLabel); this._addLabel(label, labelsLayerZoom, layer); }, _createLabelForPolygon(text, layer, style, labelsLayerZoom) { let latlng = null; - let iconWidth = 10; + let iconWidth = 40; let iconHeight = 40; + + let labelSize = labelsLayerZoom.settings.size; + if (labelSize) { + iconWidth = labelSize[0]; + iconHeight = labelSize[1]; + } + let anchor = null; let html = ''; let label; let geojsonWriter = new jsts.io.GeoJSONWriter(); - let className = 'label'; + let className = 'label polygon'; let multi = labelsLayerZoom.settings.multi; let objJsts = layer.toJsts(L.CRS.EPSG4326); @@ -458,7 +467,7 @@ export default Ember.Mixin.create({ html = '
' + text + '
'; let paneLabel = labelsLayerZoom._paneLabel; - let optionsMarker = this._optionsMarker(latlng, className, html, iconWidth, iconHeight, anchor); + let optionsMarker = this._optionsMarker(latlng, className, html, [iconWidth, iconHeight], anchor); // возможно тут тоже надо будет сделать L.featureGroup() label = this._createLabelMarker(layer, optionsMarker, paneLabel); @@ -487,11 +496,18 @@ export default Ember.Mixin.create({ _polygonMultiLabel(layer, style, text, labelsLayerZoom) { let latlng = null; - let iconWidth = 10; + let iconWidth = 40; let iconHeight = 40; + + let labelSize = labelsLayerZoom.settings.size; + if (labelSize) { + iconWidth = labelSize[0]; + iconHeight = labelSize[1]; + } + let anchor = null; let html = ''; - let className = 'label'; + let className = 'label polygon multi'; let label; let geojsonWriter = new jsts.io.GeoJSONWriter(); let objJsts = layer.toJsts(L.CRS.EPSG4326); @@ -505,7 +521,7 @@ export default Ember.Mixin.create({ let centroidN = geojsonWriter.write(centroidNJsts); latlng = L.latLng(centroidN.coordinates[1], centroidN.coordinates[0]); html = '
' + text + '
'; - let optionsMarker = this._optionsMarker(latlng, className, html, iconWidth, iconHeight, anchor); + let optionsMarker = this._optionsMarker(latlng, className, html, [iconWidth, iconHeight], anchor); let labelN = this._createLabelMarker(layer, optionsMarker, labelsLayerZoom._paneLabel); label.addLayer(labelN); } @@ -564,7 +580,7 @@ export default Ember.Mixin.create({ iconWidth = 12; iconHeight = 12; html = Ember.$(layer._svgConteiner).html(); - let optionsMarker = this._optionsMarker(latlng, className, html, iconWidth, iconHeight, anchor); + let optionsMarker = this._optionsMarker(latlng, className, html, [iconWidth, iconHeight], anchor); if (multi) { let labelN = this._createLabelMarker(layer, optionsMarker, labelsLayerZoom._paneLabel); @@ -583,7 +599,7 @@ export default Ember.Mixin.create({ iconHeight = 12; html = Ember.$(layer._svgConteiner).html(); - let optionsMarker = this._optionsMarker(latlng, className, html, iconWidth, iconHeight, anchor); + let optionsMarker = this._optionsMarker(latlng, className, html, [iconWidth, iconHeight], anchor); label = this._createLabelMarker(layer, optionsMarker, labelsLayerZoom._paneLabel); } } @@ -594,13 +610,12 @@ export default Ember.Mixin.create({ this._addLabel(label, labelsLayerZoom, layer); }, - _optionsMarker(latlng, className, html, iconWidth, iconHeight, anchor) { + _optionsMarker(latlng, className, html, iconSize, anchor) { return { latlng, className, html, - iconWidth, - iconHeight, + iconSize, anchor }; }, @@ -628,7 +643,7 @@ export default Ember.Mixin.create({ let paramsDivIcon = { className: options.className, html: options.html, - iconSize: [options.iconWidth, options.iconHeight], + iconSize: options.iconSize, iconAnchor: options.anchor }; let icon = L.divIcon(paramsDivIcon); @@ -679,27 +694,31 @@ export default Ember.Mixin.create({ return minPosition; }, - _defaultMarkerOptions() { + _defaultMarkerOptions(locationPoint) { return { iconSize: [25, 41], - iconAnchor: [12, 41] + iconAnchor: locationPoint.indexOf('over') >= 0 ? [12, 41] : [12, 20] }; }, - _positionForComboStyle(stylesMarker) { + _positionForComboStyle(stylesMarker, locationPoint) { let leftMin = 0; let rightMax = 0; let topMin = 0; let bottomMax = 0; + let widthMax = 0; + let heightMax = 0; let left = 0; let right = 0; let top = 0; let bottom = 0; + let width = 0; + let height = 0; stylesMarker.forEach(styleMarker => { let style = styleMarker.style; if (styleMarker.type === 'default') { - style = this._defaultMarkerOptions; + style = this._defaultMarkerOptions(locationPoint); } if (!Ember.isNone(style)) { @@ -710,10 +729,14 @@ export default Ember.Mixin.create({ right = (iconSize[0] || 0) - (iconAnchor[0] || 0); top = iconAnchor[1] || 0; bottom = (iconSize[1] || 0) - (iconAnchor[1] || 0); + width = iconSize[0]; + height = iconSize[1]; leftMin = this._positionMin(leftMin, left); rightMax = this._positionMax(rightMax, right); topMin = this._positionMin(topMin, top); bottomMax = this._positionMax(bottomMax, bottom); + widthMax = this._positionMax(widthMax, width); + heightMax = this._positionMax(heightMax, height); } } }); @@ -722,7 +745,9 @@ export default Ember.Mixin.create({ left: leftMin, right: rightMax, top: topMin, - bottom: bottomMax + bottom: bottomMax, + width: widthMax, + height: heightMax }; }, @@ -738,24 +763,33 @@ export default Ember.Mixin.create({ // значения для маркера по умолчанию let left = 12.5; let right = 12.5; - let top = 41; + let top = 20.5; let bottom = 0; let stylesMarker = this.get('styleSettings.style.marker'); if (stylesMarker && Ember.isArray(stylesMarker) && stylesMarker.length > 0) { - let options = this._positionForComboStyle(stylesMarker); + let options = this._positionForComboStyle(stylesMarker, settingsLabel.location.locationPoint); left = options.left; right = options.right; top = options.top; bottom = options.bottom; + width = options.width; + height = options.height; } else { - let iconSize = this.get('styleSettings.style.marker.style.iconSize'); - let iconAnchor = this.get('styleSettings.style.marker.style.iconAnchor'); + let style = stylesMarker.style; + if (stylesMarker.type === 'default') { + style = this._defaultMarkerOptions(settingsLabel.location.locationPoint); + } + + let iconSize = style.iconSize; + let iconAnchor = style.iconAnchor; if (!Ember.isNone(iconAnchor) && iconAnchor.length === 2 && !Ember.isNone(iconSize) && iconSize.length === 2) { left = iconAnchor[0] || 0; right = (iconSize[0] || 0) - (iconAnchor[0] || 0); top = iconAnchor[1] || 0; bottom = (iconSize[1] || 0) - (iconAnchor[1] || 0); + width = iconSize[0] || 0; + height = iconSize[1] || 0; } } @@ -766,12 +800,12 @@ export default Ember.Mixin.create({ switch (settingsLabel.location.locationPoint) { case 'overLeft': style = 'text-align: right;'; - anchor = [left + width, top + height]; + anchor = [left + width - 2, top + height - 2]; cssClass = 'over left'; break; case 'overRight': style = 'text-align: left;'; - anchor = [-1 * right, top + height]; + anchor = [-1 * right + 2, top + height - 2]; cssClass = 'over right'; break; case 'alongLeft': @@ -791,27 +825,29 @@ export default Ember.Mixin.create({ break; case 'underLeft': style = 'text-align: right;'; - anchor = [left + width, -1 * bottom]; + anchor = [left + width, -1 * bottom + 2]; cssClass = 'under left'; break; case 'underMiddle': style = 'text-align: center;'; - anchor = [Math.round((width - (right - left)) / 2), -1 * bottom]; + anchor = [Math.round((width - (right - left)) / 2), -1 * bottom + 2]; cssClass = 'under middle'; break; case 'underRight': style = 'text-align: left;'; - anchor = [-1 * right, -1 * bottom]; + anchor = [-1 * right, -1 * bottom + 2]; cssClass = 'under right'; break; default: // and overMiddle style = 'text-align: center;'; - anchor = [Math.round((width - (right - left)) / 2), top + height]; + anchor = [Math.round((width - (right - left)) / 2), top + height - 2]; cssClass = 'over middle'; break; } - return { style, anchor, cssClass }; + let iconSize = [width, height]; + + return { style, anchor, cssClass, iconSize }; }, /** @@ -1171,6 +1207,45 @@ export default Ember.Mixin.create({ } }, + /** + Update position for marker object's label + + @method _updatePositionLabelForLine + */ + _updatePositionLabelForMarker() { + let leafletObject = this.returnLeafletObject(); + let _this = this; + let labelsLayersZoom = this._getLabelsLayersZoom(); + + if (!Ember.isNone(leafletObject) && labelsLayersZoom && this.get('leafletMap').hasLayer(labelsLayersZoom)) { + // обновлять будем только то что видно + this._checkLabelInView(leafletObject.getLayers(), labelsLayersZoom, false).forEach(layer => { + if (!Ember.isNone(layer._icon) && !Ember.isNone(layer._label)) { + layer._label.forEach(zoomLabel => { + if (zoomLabel instanceof L.FeatureGroup) { + zoomLabel.getLayers().forEach((label) => { + _this._updateAttributesMarker(label, labelsLayersZoom.settings); + }); + } else { + _this._updateAttributesMarker(zoomLabel, labelsLayersZoom.settings); + } + }); + } + }); + } + }, + + _updateAttributesMarker(label, settings) { + let options = this._setPositionPoint(label.options.icon.options.iconSize[0], + label.options.icon.options.iconSize[1], settings); + + let icon = label.getIcon(); + icon.options.iconAnchor = options.anchor; + icon.options.iconSize = options.iconSize; + icon.options.className = 'label point ' + options.cssClass; + label.setIcon(icon); + }, + _updateAttributesSvg(layer, partline, svg, path, settingsLabel) { this._setLabelLine(layer, svg, partline, layer._text, settingsLabel); let d = layer._path.getAttribute('d'); @@ -1185,22 +1260,25 @@ export default Ember.Mixin.create({ } Ember.$('path#' + id).attr('d', d); - Ember.$('svg#svg-' + id).attr('width', svg.getAttribute('width')); - Ember.$('svg#svg-' + id).attr('height', svg.getAttribute('height')); - let options = layer._textOptions; let text = layer._text; let textNode = layer._textNode; - this._setAlignForLine(layer, text, options.align, textNode, settingsLabel); + this._setAlignForLine(layer, text, settingsLabel.options.captionFontAlign, textNode, settingsLabel); Ember.$('text#text-' + id).attr('dx', textNode.getAttribute('dx')); let buffer = 150; - let bbox = document.getElementById(id).getBBox(); - layer._svg.setAttribute('height', bbox.height + buffer); - layer._svg.setAttribute('width', bbox.width + buffer); - document.getElementById(Ember.$(layer._svg)[0].getAttribute('id')).setAttribute('height', bbox.height + buffer); - document.getElementById(Ember.$(layer._svg)[0].getAttribute('id')).setAttribute('width', bbox.width + buffer); + let pathElement = document.getElementById(id); + if (pathElement) { + let bbox = pathElement.getBBox(); + layer._svg.setAttribute('height', bbox.height + buffer); + layer._svg.setAttribute('width', bbox.width + buffer); + let svgElement = document.getElementById(Ember.$(layer._svg)[0].getAttribute('id')); + if (svgElement) { + svgElement.setAttribute('height', bbox.height + buffer); + svgElement.setAttribute('width', bbox.width + buffer); + } + } }, _createLabelsLayerOldSettings(labelsLayersArray) { @@ -1264,13 +1342,15 @@ export default Ember.Mixin.create({ _labelsLayersCreate(leafletObject) { let labelsLayers = this.get('labelsLayers'); let leafletMap = this.get('leafletMap'); - let labelSettingsString = this.get('labelSettings.labelSettingsString'); + if (Ember.isNone(labelsLayers)) { let labelsLayersArray = Ember.A(); - if (labelSettingsString) { - this._createLabelsLayerOldSettings(labelsLayersArray); - } else { + + let rules = this.get('labelSettings.rules'); + if (!Ember.isNone(rules)) { this._createLabelsLayer(labelsLayersArray); + } else { + this._createLabelsLayerOldSettings(labelsLayersArray); } leafletObject.labelsLayers = labelsLayersArray; @@ -1278,6 +1358,8 @@ export default Ember.Mixin.create({ if (this.get('typeGeometry') === 'polyline') { leafletMap.on('zoomend', this._updatePositionLabelForLine, this); + } else if (this.get('typeGeometry') === 'marker') { + leafletMap.on('zoomend', this._updatePositionLabelForMarker, this); } // для showExisting не грузим все надписи сразу. слишком много. поэтому приходится догружать при сдвиге карты, как будто это continueLoading, @@ -1315,7 +1397,7 @@ export default Ember.Mixin.create({ this._labelsLayersCreate(leafletObject); labelsLayers = this.get('labelsLayers'); - this._createStringLabel(layers, labelsLayers); + this._createStringLabel(layers, leafletObject); if (Ember.isNone(this.get('labelsLayers'))) { this.set('labelsLayers', labelsLayers); this._checkZoomPane(); @@ -1323,6 +1405,8 @@ export default Ember.Mixin.create({ if (this.get('typeGeometry') === 'polyline') { this._updatePositionLabelForLine(); + } else if (this.get('typeGeometry') === 'marker') { + this._updatePositionLabelForMarker(); } } }, @@ -1356,7 +1440,11 @@ export default Ember.Mixin.create({ labelsLayers.forEach(labelLayer => { leafletContainer.addLayer(labelLayer); labelLayer.eachLayer(layer => { - this._setOptionsForSvg(layer); + if (layer instanceof L.FeatureGroup) { + layer.eachLayer(partLayer => { this._setOptionsForSvg(partLayer); }); + } else { + this._setOptionsForSvg(layer); + } }); }); } @@ -1444,6 +1532,8 @@ export default Ember.Mixin.create({ this._checkZoomPane(); if (this.get('typeGeometry') === 'polyline') { this._updatePositionLabelForLine(); + } else if (this.get('typeGeometry') === 'marker') { + this._updatePositionLabelForMarker(); } } }, diff --git a/addon/mixins/layer-model.js b/addon/mixins/layer-model.js index c2b55074b..2bcdea803 100644 --- a/addon/mixins/layer-model.js +++ b/addon/mixins/layer-model.js @@ -88,6 +88,57 @@ export default Ember.Mixin.create({ } }, + /** + Type of legend. + @property legendType + @type String + @readOnly + */ + legendType: Ember.computed('isDeleted', 'type', 'settingsAsObject.legendSettings', function () { + if (this.get('isDeleted') || !this.get('settingsAsObject.legendSettings')) { + return false; + } + + let layerClassFactory = Ember.getOwner(this).knownForType('layer', this.get('type')); + let legendType = layerClassFactory.getLegendType(this.get('type'), this.get('settingsAsObject')); + + return legendType; + }), + + /** + Settings of legend. + @property legendSettings + @type Object + @readOnly + */ + legendSettings: Ember.computed('isDeleted', 'type', 'settingsAsObject.legendSettings', function () { + if (this.get('isDeleted') || !this.get('settingsAsObject.legendSettings')) { + return false; + } + + let layerClassFactory = Ember.getOwner(this).knownForType('layer', this.get('type')); + let legendSettings = layerClassFactory.getLegendSettings(this.get('settingsAsObject')); + + return legendSettings; + }), + + /** + Type of legend from style settings. + @property styleSettingsForLegend + @type String + @readOnly + */ + styleSettingsTypeForLegend: Ember.computed('isDeleted', 'type', 'settingsAsObject.styleSettings.type', function () { + if (this.get('isDeleted') || !this.get('settingsAsObject.legendSettings')) { + return false; + } + + let layerClassFactory = Ember.getOwner(this).knownForType('layer', this.get('type')); + let styleSettingsTypeForLegend = layerClassFactory.getStyleSettingsTypeForLegend(this.get('settingsAsObject')); + + return styleSettingsTypeForLegend; + }), + /** Flag: indicates whether layer can be identified. @property canBeIdentified diff --git a/addon/services/markers-styles-renderer.js b/addon/services/markers-styles-renderer.js index e8bad4f1d..0247d7c92 100644 --- a/addon/services/markers-styles-renderer.js +++ b/addon/services/markers-styles-renderer.js @@ -95,6 +95,22 @@ export default Ember.Service.extend({ }; }, + /** + Gets style for default marker. + + @method getDefaultMarkerSettings + @return {Object} Hash containing default style settings (for example { iconUrl: ..., shadowUrl: ..., ... }). + */ + getDefaultMarkerSettings() { + let markerStyle = this._getMarkerStyle('image'); + if (Ember.isNone(markerStyle)) { + Ember.Logger.error(`Service 'markers-styles-renderer' can't get default style settings for default markers-style.`); + return null; + } + + return markerStyle.getDefaultStyleSettings(); + }, + /** Applies marker-style to the specified leaflet marker. @@ -117,43 +133,106 @@ export default Ember.Service.extend({ markerStyle.renderOnLeafletMarker({ marker, style }); }, + calcTransform(top, bottom, left, right) { + let size = (Math.max(Math.abs(top) + Math.abs(bottom), Math.abs(left) + Math.abs(right))); + + let topOffsetCenter = parseFloat(((Math.abs(top) / (Math.abs(top) + Math.abs(bottom))) * 100).toFixed(2)); + let leftOffsetCenter = parseFloat(((Math.abs(left) / (Math.abs(left) + Math.abs(right))) * 100).toFixed(2)); + + return { size, topOffsetCenter, leftOffsetCenter }; + }, + + transform(style, top, bottom, left, right) { + if (!Ember.isNone(style)) { + let width = style.iconSize[0]; + let height = style.iconSize[1]; + let anchorH = style.iconAnchor[1]; + let anchorW = style.iconAnchor[0]; + + if ((0 - anchorH) < top) { top = (0 - anchorH); } + + if ((height - anchorH) > bottom) { bottom = (height - anchorH); } + + if ((0 - anchorW) < left) { left = (0 - anchorW); } + + if ((width - anchorW) > right) { right = (width - anchorW); } + } + + return { top, bottom, left, right }; + }, + /** - Renderes marker-style preview on the specified canvas element. + Calculate scale for canvas of legend. - @method renderOnCanvas - @param {Object} options Method options. - @param {Canvas} options.canvas Canvas element on which layer-style preview must be rendered. - @param {Object} options.styleSettings Hash containing style settings. - @param {Object} [options.target = 'preview'] Render target ('preview' or 'legend'). + @method calcScale + @param {Object} styleSettings style settings. + @return {Object} Hash containing style settings. */ - renderOnCanvas({ canvas, styleSettings, target }) { - target = target || 'preview'; - - if (Ember.isArray(styleSettings)) { - styleSettings.forEach(settings => { - let type = Ember.get(settings, 'type'); - let style = Ember.get(settings, 'style'); - - let markerStyle = this._getMarkerStyle(type); - if (Ember.isNone(markerStyle)) { - Ember.Logger.error(`Service 'markers-styles-renderer' can't render '${type}' markers-style on canvas.`); - return; + calcScale(styleSettings) { + let top = 0; + let bottom = 0; + let left = 0; + let right = 0; + let result; + if (!Ember.isArray(styleSettings)) { + let style = styleSettings.style; + if (styleSettings.type === 'default') { + style = this.getDefaultMarkerSettings(); + } + + let value = this.transform(style, top, bottom, left, right); + result = this.calcTransform(value.top, value.bottom, value.left, value.right); + } else { + styleSettings.forEach((settings) => { + let style = settings.style; + if (settings.type === 'default') { + style = this.getDefaultMarkerSettings(); } - markerStyle.renderOnCanvas({ canvas, style, target }); + let value = this.transform(style, top, bottom, left, right); + top = value.top; + bottom = value.bottom; + left = value.left; + right = value.right; }); - } else { - let type = Ember.get(styleSettings, 'type'); - let style = Ember.get(styleSettings, 'style'); - let markerStyle = this._getMarkerStyle(type); - if (Ember.isNone(markerStyle)) { - Ember.Logger.error(`Service 'markers-styles-renderer' can't render '${type}' markers-style on canvas.`); - return; - } + result = this.calcTransform(top, bottom, left, right); + } + + return result; + }, - markerStyle.renderOnCanvas({ canvas, style, target }); + getStyle(scale, settings) { + if (settings.cssStyle) { + return; + } + + let size = scale.size; + let style = settings.style; + if (settings.type === 'default') { + style = this.getDefaultMarkerSettings(); } + let iconHeight = style.iconSize[1]; + let iconWidth = style.iconSize[0]; + + let anchorHeight = style.iconAnchor[1]; + let anchorWidth = style.iconAnchor[0]; + + let topOffsetCenter = scale.topOffsetCenter; + let leftOffsetCenter = scale.leftOffsetCenter; + + let top = (topOffsetCenter - ((anchorHeight / size) * 100)).toFixed(2); + let left = (leftOffsetCenter - ((anchorWidth / size) * 100)).toFixed(2); + + let height = ((iconHeight / size) * 100).toFixed(2); + let width = ((iconWidth / size) * 100).toFixed(2); + + let cssStyle = { + style: `height: ${height}%; width: ${width}%; top: ${top}%; left: ${left}%;`, + src: style.iconUrl + }; + + Ember.set(settings, 'cssStyle', cssStyle); } }); diff --git a/addon/styles/addon.less b/addon/styles/addon.less index 761e66bb5..a2563b0e9 100644 --- a/addon/styles/addon.less +++ b/addon/styles/addon.less @@ -39,6 +39,12 @@ } } +.flexberry-validationsummary.ui.gray.message { + box-shadow: none; + color: @greyText; + border-color: @greyText; +} + /** Fix disappearing checkboxes while scrolling */ @@ -76,6 +82,13 @@ display: none !important; } +.leaflet-marker-icon.label.polygon { + display: flex; + justify-content: center; + flex-direction: column; + align-items: center; +} + .leaflet-marker-icon.label.point { display: flex; diff --git a/addon/styles/themes/default/elements/container.overrides b/addon/styles/themes/default/elements/container.overrides index b290ce050..2c1173cfa 100644 --- a/addon/styles/themes/default/elements/container.overrides +++ b/addon/styles/themes/default/elements/container.overrides @@ -122,7 +122,6 @@ line-height: 14px; font-weight: 700; &:hover { - border: none; background: @buttonMenuHoveredBackground; } } diff --git a/addon/styles/themes/default/globals/site.variables b/addon/styles/themes/default/globals/site.variables index dcf669b9c..c6b39d669 100644 --- a/addon/styles/themes/default/globals/site.variables +++ b/addon/styles/themes/default/globals/site.variables @@ -13,7 +13,7 @@ @greencolor: #65A43F; @orangecolor: #EB1C24; @mediumbluecolor: #DDEBFF; - +@greyText: #848E99; /******************************* Components variables diff --git a/addon/styles/themes/default/modules/sidebar.overrides b/addon/styles/themes/default/modules/sidebar.overrides index 8538f86a5..41c2cc018 100644 --- a/addon/styles/themes/default/modules/sidebar.overrides +++ b/addon/styles/themes/default/modules/sidebar.overrides @@ -282,6 +282,17 @@ .layer-legend-zoom { width: 100%; padding: 2px; + display: flex; + .layer-legend-marker { + display: flex; + flex-direction: column; + vertical-align: middle; + align-items: center; + justify-content: center; + position: relative; + width:24px; + height:24px; + } } .layer-legend-image, @@ -290,6 +301,13 @@ float: left; } .layer-legend-image { + position: relative; + max-width: 24px; + max-height: 24px; + .icon-image { + position: absolute; + pointer-events: none; + } } .layer-legend-caption { color: @textColor; diff --git a/addon/templates/components/feature-result-item.hbs b/addon/templates/components/feature-result-item.hbs index 1f63bdfe8..fe0c44197 100644 --- a/addon/templates/components/feature-result-item.hbs +++ b/addon/templates/components/feature-result-item.hbs @@ -1,3 +1,4 @@ +{{yield}}
{{#if _showLoader}}
@@ -113,12 +114,9 @@ {{t "components.feature-result-item.find-intersection-caption"}}
-
- - - {{t "components.feature-result-item.search-satellite"}} - -
+ {{#yield-slot "list-buttons" (block-params feature)}} + {{yield}} + {{/yield-slot}} {{/if}} diff --git a/addon/templates/components/flexberry-identify-file.hbs b/addon/templates/components/flexberry-identify-file.hbs index 95dea46ec..192f54d80 100644 --- a/addon/templates/components/flexberry-identify-file.hbs +++ b/addon/templates/components/flexberry-identify-file.hbs @@ -23,10 +23,12 @@
{{flexberry-dropdown - class=(concat "fluid geometryType") + class=(concat "no-placeholder fluid geometryType") items=_geometryTypes value=_geometryType displayCaptions=true + placeholder="" + onChange=(action 'clearCacheAndPreview') }}
{{/if}} @@ -34,15 +36,19 @@
{{flexberry-dropdown - class=(concat "fluid geometryField1") + class=(concat "no-placeholder fluid geometryField1") items=_availableFields value=geometryField1 + placeholder="" + onChange=(action 'clearCacheAndPreview') }}
{{flexberry-dropdown - class=(concat "field fluid geometryField2" (if disableCrs " disabled" "")) + class=(concat "no-placeholder fluid geometryField2") items=_availableFields value=geometryField2 + placeholder="" + onChange=(action 'clearCacheAndPreview') }} {{/if}} @@ -52,7 +58,7 @@ items=systemCoordinates value=coordinate displayCaptions=true - onChange=(action 'onCoordinateChange') + onChange=(action 'clearCacheAndPreview') class="scale-value fluid" }} @@ -63,7 +69,7 @@ {{flexberry-button iconClass=(if filePreview 'icon-guideline-hide' 'icon-guideline-show') click=(action "showFileLayer") - readonly = (not file) + readonly = (or (not file) (and needCRS (eq coordinate 'auto')) (and needGeometryFieldName (not geometryFieldFile))) tooltip=(t "components.flexberry-identify-panel.file.preview.caption") }} @@ -72,7 +78,7 @@ class='ml-20' iconClass='icon-guideline-layers-info' click=(action "identificationFile") - readonly = (not file) + readonly = (or (not file) (and needCRS (eq coordinate 'auto')) (and needGeometryFieldName (not geometryFieldFile))) tooltip=(t "components.flexberry-identify-panel.file.identify.caption") }} @@ -81,12 +87,23 @@ class='ml-20' iconClass='icon-guideline-goout' click=(action "createLayerByFile") - readonly = (not file) + readonly = (or (not file) (and needCRS (eq coordinate 'auto')) (and needGeometryFieldName (not geometryFieldFile))) tooltip=(t "components.flexberry-identify-panel.file.create-layer.caption") }} {{/if}} {{/if}} + +{{#if (and needCRS (eq coordinate 'auto'))}} + {{ui-message + type="error" + closeable=false + visible=true + class=(concat "flexberry-validationsummary gray") + message=warningMessageAutoCRS + }} +{{/if}} + {{#if _showError}} {{ui-message type="error" @@ -94,4 +111,5 @@ visible=_showError message=_errorMessage }} -{{/if}} \ No newline at end of file +{{/if}} + diff --git a/addon/templates/components/flexberry-maplayer.hbs b/addon/templates/components/flexberry-maplayer.hbs index 724d0b9c0..8d156cf2d 100644 --- a/addon/templates/components/flexberry-maplayer.hbs +++ b/addon/templates/components/flexberry-maplayer.hbs @@ -230,7 +230,7 @@ }} {{/if}} {{#if (and layer.legendCanBeDisplayed hasBeenExpanded)}} - {{component (concat "legends/" layer.type "-legend") + {{component (concat "legends/" layer.legendType "-legend") layer=layer }} {{/if}} diff --git a/addon/templates/components/layer-result-list.hbs b/addon/templates/components/layer-result-list.hbs index 2cde784f0..aebf9f5c3 100644 --- a/addon/templates/components/layer-result-list.hbs +++ b/addon/templates/components/layer-result-list.hbs @@ -1,3 +1,4 @@ +{{yield}} {{#if _showLoader}}
{{t "components.layer-result-list.processing"}} {{else if _noData}} @@ -110,7 +111,7 @@ accessibleMap=accessibleMap }} {{else}} - {{feature-result-item + {{#feature-result-item feature=feature resultObject=result highlightable=enableHighlight @@ -124,7 +125,6 @@ zoomTo=(action "zoomTo") clearSelected=(action "clearSelected") findIntersection=(action 'findIntersection') - searchSatellites=(action "searchSatellites") intersection=intersection zoomToIntersection=(action 'zoomToIntersection') panToIntersection=(action 'panToIntersection') @@ -132,6 +132,8 @@ availableEdit=(and availableEdit (array-contains accessibleData result.layerModel.id)) accessibleMap=accessibleMap }} + {{yield}} + {{/feature-result-item}} {{/if}} {{/if}} {{/each}} @@ -243,7 +245,7 @@ accessibleMap=accessibleMap }} {{else}} - {{feature-result-item + {{#feature-result-item feature=feature resultObject=result displayProperty="displayValue" @@ -256,7 +258,6 @@ zoomTo=(action "zoomTo") clearSelected=(action "clearSelected") findIntersection=(action 'findIntersection') - searchSatellites=(action "searchSatellites") intersection=intersection zoomToIntersection=(action 'zoomToIntersection') panToIntersection=(action 'panToIntersection') @@ -268,6 +269,8 @@ availableEdit=(and availableEdit (array-contains accessibleData result.layerModel.id)) accessibleMap=accessibleMap }} + {{yield}} + {{/feature-result-item}} {{/if}} {{/each}} {{#if result.maxResultsLimitOverage}} diff --git a/addon/templates/components/legends/-private/vector-legend.hbs b/addon/templates/components/legends/-private/vector-legend.hbs index a9a6ed6f9..ab0b26d37 100644 --- a/addon/templates/components/legends/-private/vector-legend.hbs +++ b/addon/templates/components/legends/-private/vector-legend.hbs @@ -1,7 +1,7 @@ {{#if (known-for-type "component" _styleSettingsRelatedComponentName)}} {{component _styleSettingsRelatedComponentName styleSettings=layer.settingsAsObject.styleSettings - legendSettings=layer.settingsAsObject.legendSettings + legendSettings=layer.legendSettings showCaption=showLayerName caption=layer.name styleRules=layer.styleRules diff --git a/addon/templates/components/legends/layers-styles/simple.hbs b/addon/templates/components/legends/layers-styles/simple.hbs index 934529ea4..9347b9706 100644 --- a/addon/templates/components/legends/layers-styles/simple.hbs +++ b/addon/templates/components/legends/layers-styles/simple.hbs @@ -16,18 +16,34 @@ {{/if}} {{#if _markersCanBeDisplayed}} {{#if (and styleRules (gt styleRules.length 0))}} - {{#each styleRules as |styleRule index|}} -
- - + {{#each styleRules as |styleRule index|}} +
+
+
+ {{#each styleRule.styleSettings.style.marker as |settings|}} + + {{/each}} +
- {{/each}} - {{else}} - - {{#if showCaption}} - - {{/if}} + +
+ {{/each}} + {{else}} +
+
+
+ +
+
+
+ {{#if showCaption}} + {{/if}} + {{/if}} {{/if}}
\ No newline at end of file diff --git a/tests/unit/mixins/flexberry-map-model-api-test.js b/tests/unit/mixins/flexberry-map-model-api-test.js index e8694c27e..fb4e18c09 100644 --- a/tests/unit/mixins/flexberry-map-model-api-test.js +++ b/tests/unit/mixins/flexberry-map-model-api-test.js @@ -23,7 +23,9 @@ test('uploadFile should send post request with fileName and data to backend and resolveRegistration() { return { 'APP': { - 'backendUrl': 'stubbackend' + 'backendUrls': { + 'fileUploadUrl': 'stubbackend' + } } }; } @@ -37,7 +39,7 @@ test('uploadFile should send post request with fileName and data to backend and assert.ok(result instanceof Ember.RSVP.Promise); assert.ok(server.requests[0].requestBody.has('testFile')); - assert.equal(server.requests[0].url, 'stubbackend/controls/FileUploaderHandler.ashx?FileName=testFile'); + assert.equal(server.requests[0].url, 'stubbackend?FileName=testFile'); result.then((e) => { assert.equal(e, 'uploadfileresponse'); done(); diff --git a/tests/unit/mixins/layer-label-test.js b/tests/unit/mixins/layer-label-test.js index d27b75a0a..8ff82e14a 100644 --- a/tests/unit/mixins/layer-label-test.js +++ b/tests/unit/mixins/layer-label-test.js @@ -16,6 +16,13 @@ test('test method _createStringLabel', function(assert) { center: [51.505, -0.09], zoom: 13 }); + let styleSettings = { + 'style': { + 'marker': { + 'type': 'default', + } + } + }; let settings = { 'options': { 'captionFontColor': '#000000FF', @@ -47,7 +54,8 @@ test('test method _createStringLabel', function(assert) { let subject = LayerLabelObject.create({ leafletMap: leafletMap, showExisting: false, - labelsLayers: [labelsLayer] + labelsLayers: [labelsLayer], + styleSettings: styleSettings }); let _applyFunctionStub = sinon.stub(subject, '_applyFunction');