From a24523385c9eebc97ad7184f6723c0de58fc2856 Mon Sep 17 00:00:00 2001 From: circus2271 Date: Thu, 2 Mar 2023 16:17:20 +0300 Subject: [PATCH 1/2] Show other markers on the map in the edit mode Resolves #482 --- public/js/module/map/map.js | 24 ++++++++++++++++++++++-- public/style/map/map.less | 20 ++++++++++++++++++++ views/module/map/map.pug | 2 +- 3 files changed, 43 insertions(+), 3 deletions(-) diff --git a/public/js/module/map/map.js b/public/js/module/map/map.js index a480ed12..de8806e1 100644 --- a/public/js/module/map/map.js +++ b/public/js/module/map/map.js @@ -626,10 +626,30 @@ define([ // Обработчик переключения режима редактирования editHandler: function (edit) { + const self = this; + if (edit) { - this.pointHighlightDestroy().pointEditCreate().markerManager.disable(); + let highlightedPhotoLayer; + + this.markerManager.layerPhotos.eachLayer(function (marker) { + if (_.isEqual(self.point.geo(), marker.options.data.obj.geo)) { + highlightedPhotoLayer = marker; + } + + marker + .off('click') + .off('mouseover'); + }); + + if (highlightedPhotoLayer) { + this.markerManager.layerPhotos.removeLayer(highlightedPhotoLayer); + } + + this.pointHighlightDestroy().pointEditCreate(); } else { - this.pointEditDestroy().pointHighlightCreate().markerManager.enable(); + this.markerManager.disable(); + this.pointEditDestroy().pointHighlightCreate(); + this.markerManager.enable(); } }, // Включает режим редактирования diff --git a/public/style/map/map.less b/public/style/map/map.less index 06915555..9062e964 100644 --- a/public/style/map/map.less +++ b/public/style/map/map.less @@ -892,6 +892,26 @@ } .mapContainer.embedded { + &.editing { + .clusterIcon { + display: none !important; + } + + .clusterIconLocal, + .photoIcon { + opacity: 0.4; + cursor: grab; + } + + .photoIcon:hover { + width: 8px !important; + height: 8px !important; + margin-left: -4px !important; + margin-top: -4px !important; + .box-shadow(0 0 1px 1px #fff); + } + } + .mapNavigation { top: -33px; left: -13px; diff --git a/views/module/map/map.pug b/views/module/map/map.pug index f645311f..29d1f01f 100644 --- a/views/module/map/map.pug +++ b/views/module/map/map.pug @@ -1,5 +1,5 @@ .mapModuleWrapper(data-bind="with: repository[M!M]") - .mapContainer(data-bind="css: {embedded: embedded}") + .mapContainer(data-bind="css: {embedded: embedded, editing: editing}") .map //ko if: embedded From 295609a6ac4cef7425f212aff20cd684289a5dca Mon Sep 17 00:00:00 2001 From: circus2271 Date: Sat, 10 Jun 2023 04:56:15 +0300 Subject: [PATCH 2/2] temp --- public/js/module/map/map.js | 29 +++++++++++------------------ public/js/module/map/marker.js | 12 ++++++++++++ public/js/module/photo/photo.js | 2 +- 3 files changed, 24 insertions(+), 19 deletions(-) diff --git a/public/js/module/map/map.js b/public/js/module/map/map.js index de8806e1..fcb9fa67 100644 --- a/public/js/module/map/map.js +++ b/public/js/module/map/map.js @@ -540,6 +540,7 @@ define([ openNewTab: this.openNewTab(), isPainting: this.isPainting(), embedded: this.embedded, + editing: this.editing, year: this.yearLow, year2: this.yearHigh, }); @@ -626,30 +627,22 @@ define([ // Обработчик переключения режима редактирования editHandler: function (edit) { - const self = this; + this.markerManager.enable(); if (edit) { - let highlightedPhotoLayer; - - this.markerManager.layerPhotos.eachLayer(function (marker) { - if (_.isEqual(self.point.geo(), marker.options.data.obj.geo)) { - highlightedPhotoLayer = marker; - } - - marker - .off('click') - .off('mouseover'); - }); - - if (highlightedPhotoLayer) { - this.markerManager.layerPhotos.removeLayer(highlightedPhotoLayer); - } + const currentPointCid = this.point.cid(); + const currentPhoto = this.markerManager.mapObjects.photos[currentPointCid]; + // const currentPhotoMarker = currentPhoto?.marker; + this.currentPhotoMarker = currentPhoto.marker; + this.markerManager.layerPhotos.removeLayer(this.currentPhotoMarker); this.pointHighlightDestroy().pointEditCreate(); } else { - this.markerManager.disable(); + if (this.currentPhotoMarker) { + this.markerManager.layerPhotos.addLayer(this.currentPhotoMarker); + } + this.pointEditDestroy().pointHighlightCreate(); - this.markerManager.enable(); } }, // Включает режим редактирования diff --git a/public/js/module/map/marker.js b/public/js/module/map/marker.js index d8ae74cd..0f2cc50f 100644 --- a/public/js/module/map/marker.js +++ b/public/js/module/map/marker.js @@ -32,6 +32,7 @@ define([ this.openNewTab = options.openNewTab; this.embedded = options.embedded; this.isPainting = options.isPainting; + this.editing = options.editing; this.year = options.year || undefined; this.year2 = options.year2 || undefined; @@ -963,6 +964,10 @@ define([ * @param {Event} evt */ MarkerManager.prototype.clickMarker = function (evt) { + if (this.editing()) { + return; + } + const marker = evt.target; const object = marker.options.data.obj; const eventPoint = this.map.mouseEventToContainerPoint(evt.originalEvent); @@ -1086,6 +1091,13 @@ define([ } }; MarkerManager.prototype.popupPhotoOver = function (evt) { + if (this.editing()) { + console.log(this.editing()); + return; + } + + console.log(this.editing()); + const type = evt.target.options.data.type; window.clearTimeout(this.popupTimeout); diff --git a/public/js/module/photo/photo.js b/public/js/module/photo/photo.js index 7f8cc2e4..13460d11 100644 --- a/public/js/module/photo/photo.js +++ b/public/js/module/photo/photo.js @@ -528,7 +528,7 @@ define(['underscore', 'Utils', 'socket!', 'Params', 'knockout', 'knockout.mappin this.mapVM.setPoint(this.genMapPoint(), this.isPainting()); }, genMapPoint: function () { - return _.pick(this.p, 'geo', 'year', 'dir', 'title', 'regions'); + return _.pick(this.p, 'geo', 'year', 'cid', 'dir', 'title', 'regions'); }, editGeoChange: function (geo) { if (geo) {