diff --git a/src/components/project.vue b/src/components/project.vue index 9eb5879..a245f1e 100644 --- a/src/components/project.vue +++ b/src/components/project.vue @@ -169,9 +169,6 @@ export default { this.api.get('geojson', {id_project: this.currProject.id}) ]); - //Get default basemap - this.baseMap = this.baseMaps.find((asBM) => asBM.default_map)?.codename ?? null; - //Build Map if(this.map) this.map.remove(); this.map = new Map({ @@ -195,6 +192,9 @@ export default { attributionControl: false }); + //Get default basemap + this.baseMap = this.baseMaps.find((asBM) => asBM.default_map)?.codename ?? null; + //Force wait for load event await new Promise((resolve) => { if(this.map.loaded()) resolve(); diff --git a/src/components/projectPost.vue b/src/components/projectPost.vue index 5fdd62b..f02f645 100644 --- a/src/components/projectPost.vue +++ b/src/components/projectPost.vue @@ -64,14 +64,28 @@ relTime() { return this.modeHisto?(this.options.formatted_time || '').substr(0, 10):this.options.relative_time; }, - lngLat() { - return ( + relatedMarker() { + //Find corresponding marker + if(!this.options.longitude && !this.options.latitude && this.options.type == 'media') { + return this.project.markers.find((marker) => { + return (marker.medias || []).some((media) => { + return media.id_media == this.options.id_media; + }); + }) || null; + } + else if( ['message', 'media'].includes(this.options.type) && this.options.longitude && this.options.latitude - )?(new LngLat(this.options.longitude, this.options.latitude)):null; + ) { + return this.options; + } + else return null; + }, + relatedMarkerLatLng() { + let oRelatedMarker = this.relatedMarker; + return new LngLat(oRelatedMarker.longitude, oRelatedMarker.latitude); } - }, inject: ['api', 'lang', 'project', 'user', 'map', 'hash', 'consts', 'isMobile'], methods: { @@ -85,18 +99,23 @@ }, 5000); }, panMapToMarker(iAnimDuration=500) { + if(typeof iAnimDuration !== 'number') iAnimDuration = 500; //panMapToMarker will provide event on direct call in vue template + this.popupRequested = true; if(this.isMobile()) this.project.toggleFeedPanel(false, 'panToInstant'); this.hash.items = [this.hash.items[0], this.options.type, this.options.id]; - return this.map.panToBetweenPanels(this.lngLat, this.focusZoomLevel, iAnimDuration).then(() => { + return this.map.panToBetweenPanels(this.relatedMarkerLatLng, this.focusZoomLevel, iAnimDuration).then(() => { this.openMarkerPopup(false); }); }, openMarkerPopup(bMouseEvent=true) { + const oRelatedMarker = this.relatedMarker; this.mouseOverDrill = bMouseEvent; - if(this.map.isMarkerVisible(this.lngLat)) this.map.openMarkerPopup(this.options.id, this.options.type); + if(oRelatedMarker && this.map.isMarkerVisible(this.relatedMarkerLatLng)) { + this.map.openMarkerPopup(oRelatedMarker.id, oRelatedMarker.type); + } }, closeMarkerPopup() { this.mouseOverDrill = false; @@ -130,7 +149,7 @@ return this.openMarkerPopup(false); case 'media': this.$refs.medialink.openMedia(); - if(this.lngLat) return this.openMarkerPopup(false); + if(this.relatedMarker) return this.openMarkerPopup(false); default: return Promise.resolve(); } @@ -161,7 +180,7 @@
-