-
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new map control
zoomhistory
(#388)
* Add ZoomHistory Map Control * Create ZoomHistoryMapControl.vue component * clean up some code * rename file: `components/ZoomHistoryMapControl.vue` --> `components/MapControlZoomHistory.vue` Use same prefix as: - #329 - #330 * fix computed method: `hasEmptyHistory()` * Add i18n translation as QGIS Desktop tools * update translations * Fix issue on watch history.index. Remove watch property and move to methods last and next because when move map (zoom or pan) index is updated and map back to previous extent * Set new icon * Move zoomhistory according #388 (comment) * 👀 jsdoc tags must be setted above each term... ..otherwise you could break your IDE intellisense * remove duplicated function call: `_addControlToMapControlsLeftBottom` * comments --------- Co-authored-by: Raruto <[email protected]>
- Loading branch information
1 parent
5157386
commit 1746ecf
Showing
14 changed files
with
239 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import MapControlZoomHistory from "components/MapControlZoomHistory.vue"; | ||
|
||
const Control = require('g3w-ol/controls/control'); | ||
|
||
function ZoomHistoryControl() { | ||
const vueElement = Vue.extend(MapControlZoomHistory); | ||
Control.call(this, { | ||
name: "zoomhistory", | ||
tipLabel: "sdk.mapcontrols.addlayer.tooltip", | ||
element: (new vueElement()).$mount().$el | ||
}); | ||
} | ||
|
||
ol.inherits(ZoomHistoryControl, Control); | ||
|
||
const proto = ZoomHistoryControl.prototype; | ||
|
||
proto.setMap = function(map) { | ||
Control.prototype.setMap.call(this,map); | ||
}; | ||
|
||
proto.layout = function(map) { | ||
Control.prototype.layout.call(this, map); | ||
}; | ||
|
||
module.exports = ZoomHistoryControl; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
<!-- | ||
@file | ||
@since v3.8 | ||
--> | ||
|
||
<template> | ||
<div | ||
style="display:flex;gap: 5px; " | ||
class="ol-zoom-history ol-unselectable ol-control"> | ||
|
||
<!-- STEP BACK --> | ||
<div v-t-tooltip:top.create="'sdk.mapcontrols.zoomhistory.zoom_last'"> | ||
<button | ||
@click.stop.prevent="last" | ||
type="button" | ||
v-disabled="history.index === 0"> | ||
<i :class="g3wtemplate.getFontClass('reply')"></i> | ||
</button> | ||
</div> | ||
|
||
|
||
<!-- STEP FORWARD --> | ||
<div v-t-tooltip:top.create="'sdk.mapcontrols.zoomhistory.zoom_next'"> | ||
<button | ||
@click.stop.prevent="next" | ||
type="button" | ||
v-disabled="hasEmptyHistory"> | ||
|
||
<i :class="g3wtemplate.getFontClass('share')"></i> | ||
</button> | ||
</div> | ||
|
||
|
||
</div> | ||
</template> | ||
|
||
|
||
<script> | ||
import GUI from 'services/gui'; | ||
const { debounce } = require('core/utils/utils'); | ||
|
||
export default { | ||
name: "MapControlZoomHistory", | ||
data() { | ||
return { | ||
history: { | ||
index: 0, | ||
items: [] | ||
} | ||
} | ||
}, | ||
methods: { | ||
last(){ | ||
this.history.index--; | ||
this.setMapExtent(); | ||
}, | ||
next(){ | ||
this.history.index++; | ||
this.setMapExtent(); | ||
}, | ||
setMapExtent(){ | ||
GUI.getService('map').getMap().getView().fit(this.history.items[this.history.index]) | ||
} | ||
}, | ||
computed: { | ||
hasEmptyHistory() { | ||
return (0 === this.history.index && 1 === this.history.items.length) || (this.history.items.length - 1 === this.history.index); | ||
} | ||
}, | ||
|
||
/** | ||
* @listens ol.View~change | ||
*/ | ||
created() { | ||
const map = GUI.getService('map').getMap(); | ||
const view = map.getView(); | ||
|
||
this.history.items.push(view.calculateExtent(map.getSize())); | ||
|
||
this.changeKeyEvent = view.on('change' , debounce(evt => { | ||
if (this.history.index !== this.history.items.length -1) { | ||
this.history.items.splice((this.history.index - this.history.items.length) + 1); | ||
} | ||
this.history.items.push(evt.target.calculateExtent(map.getSize())); | ||
this.history.index++; | ||
}, 600)) | ||
}, | ||
|
||
beforeDestroy() { | ||
ol.Object.unByKey(this.changeKeyEvent); | ||
} | ||
|
||
} | ||
</script> | ||
|
||
<style scoped> | ||
|
||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters