More improvements to map rendering issues on sequence edit.

This commit is contained in:
mateuswetah 2023-02-16 12:11:55 -03:00
parent b7bce14671
commit d129e5cb1e
2 changed files with 29 additions and 24 deletions

View File

@ -1591,6 +1591,9 @@ export default {
}, },
onChangeCollapse(event, index) { onChangeCollapse(event, index) {
if (event && !this.metadataCollapses[index] && this.itemMetadata[index].metadatum && this.itemMetadata[index].metadatum['metadata_type'] === "Tainacan\\Metadata_Types\\GeoCoordinate")
eventBusItemMetadata.$emit('itemEditionFormResize');
this.metadataCollapses.splice(index, 1, event); this.metadataCollapses.splice(index, 1, event);
}, },
toggleMetadataSectionCollapse(sectionIndex) { toggleMetadataSectionCollapse(sectionIndex) {

View File

@ -175,22 +175,16 @@
} }
}, },
watch: { watch: {
selectedLatLng: { selectedLatLng() {
handler(newValue) { const mapComponentRef = 'map--' + this.itemMetadatumIdentifier;
const mapComponentRef = 'map--' + this.itemMetadatumIdentifier; this.$nextTick(() => {
if ( this.$refs[mapComponentRef] && this.$refs[mapComponentRef].mapObject && this.selectedLatLng.length != undefined) {
this.$nextTick(() => { if (this.selectedLatLng.length == 1)
if ( this.$refs[mapComponentRef] && this.$refs[mapComponentRef].mapObject && newValue.length != undefined) { this.$refs[mapComponentRef].mapObject.panInsideBounds(this.selectedLatLng, { animate: true, maxZoom: this.maxZoom });
setTimeout(() => { else
if (newValue.length == 1) this.$refs[mapComponentRef].mapObject.flyToBounds(this.selectedLatLng, { animate: true, maxZoom: this.maxZoom });
this.$refs[mapComponentRef].mapObject.panInsideBounds(newValue, { animate: true, maxZoom: this.maxZoom }); }
else });
this.$refs[mapComponentRef].mapObject.flyToBounds(newValue, { animate: true, maxZoom: this.maxZoom });
}, 750);
}
});
},
immediate: false
} }
}, },
created() { created() {
@ -204,12 +198,10 @@
eventBusItemMetadata.$on('itemEditionFormResize', () => this.handleWindowResize(mapComponentRef)); eventBusItemMetadata.$on('itemEditionFormResize', () => this.handleWindowResize(mapComponentRef));
}, },
mounted() { mounted() {
setTimeout(() => { this.$nextTick(() => {
this.$nextTick(() => { const mapComponentRef = 'map--' + this.itemMetadatumIdentifier;
const mapComponentRef = 'map--' + this.itemMetadatumIdentifier; this.handleWindowResize(mapComponentRef);
this.handleWindowResize(mapComponentRef); });
});
}, 500);
}, },
beforeDestroy() { beforeDestroy() {
const mapComponentRef = 'map--' + this.itemMetadatumIdentifier; const mapComponentRef = 'map--' + this.itemMetadatumIdentifier;
@ -321,8 +313,18 @@
this.$emit('input', this.selected); this.$emit('input', this.selected);
}, },
handleWindowResize(mapComponentRef) { handleWindowResize(mapComponentRef) {
if ( this.$refs[mapComponentRef] && this.$refs[mapComponentRef].mapObject ) setTimeout(() => {
this.$refs[mapComponentRef].mapObject.invalidateSize(true); if ( this.$refs[mapComponentRef] && this.$refs[mapComponentRef].mapObject ) {
this.$refs[mapComponentRef].mapObject.invalidateSize(true);
if ( this.selectedLatLng.length != undefined) {
if (this.selectedLatLng.length == 1)
this.$refs[mapComponentRef].mapObject.panInsideBounds(this.selectedLatLng, { animate: true, maxZoom: this.maxZoom });
else
this.$refs[mapComponentRef].mapObject.flyToBounds(this.selectedLatLng, { animate: true, maxZoom: this.maxZoom });
}
}
}, 500);
} }
} }
} }