parent
cd501175f5
commit
d520d982b5
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,50 @@
|
||||
<template>
|
||||
<div id="BLABLA">
|
||||
<EditButton icon="fas fa-edit" v-on:click="edit" :show="!editing" tooltip="Edit"></EditButton>
|
||||
<EditButton icon="fas fa-undo" v-on:click="undo" :show="editing" tooltip="Undo"></EditButton>
|
||||
<EditButton icon="fas fa-save" v-on:click="save" :show="editing" tooltip="Save"></EditButton>
|
||||
|
||||
<EditButton icon="fas fa-draw-polygon" :show="editing" tooltip="Draw Taxiline"></EditButton>
|
||||
<EditButton icon="fas fas fa-parking" :show="editing" tooltip="Draw Parking"></EditButton>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="js">
|
||||
import EditButton from './EditButton'
|
||||
export default {
|
||||
components: { EditButton },
|
||||
data () {
|
||||
return {isEditing: false}
|
||||
},
|
||||
created () {
|
||||
},
|
||||
methods: {
|
||||
edit () {
|
||||
this.editing = true
|
||||
this.$parent.$parent.$refs.editLayer.enableEdit()
|
||||
},
|
||||
undo () {
|
||||
this.editing = false
|
||||
this.$parent.$parent.$refs.editLayer.disableEdit()
|
||||
},
|
||||
save () {
|
||||
this.editing = false
|
||||
this.$parent.$parent.$refs.editLayer.disableEdit()
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
editing: {
|
||||
// getter
|
||||
get: function () {
|
||||
console.log(`Getting Visible : ${this.isEditing}`)
|
||||
return this.isEditing
|
||||
},
|
||||
// setter
|
||||
set: function (newValue) {
|
||||
this.isEditing = newValue
|
||||
console.log(`Setting Visible : ${this.isEditing}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
@ -0,0 +1,64 @@
|
||||
<template></template>
|
||||
|
||||
<script lang="js">
|
||||
import L from 'leaflet'
|
||||
import '@fortawesome/fontawesome-free/css/all.css'
|
||||
import EditBar from '../leaflet/EditControl.js'
|
||||
export default {
|
||||
name: 'edit-bar',
|
||||
props: {
|
||||
icon: String,
|
||||
show: Boolean,
|
||||
tooltip: String
|
||||
},
|
||||
watch: {
|
||||
show: function (newVal, oldVal) { // watch it
|
||||
console.log('Prop changed: ', newVal, ' | was: ', oldVal)
|
||||
if (newVal) {
|
||||
this.add()
|
||||
} else {
|
||||
this.remove()
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted () {
|
||||
console.debug(L)
|
||||
console.debug(EditBar)
|
||||
this.add()
|
||||
},
|
||||
beforeDestroy () {
|
||||
this.remove()
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
deferredMountedTo (parent) {
|
||||
this.editbutton = new L.EditControl({html: `<i class="${this.icon}"></i>`, callback: this.click, tooltip: this.tooltip})
|
||||
if (this.show) {
|
||||
parent.addControl(this.editbutton)
|
||||
}
|
||||
},
|
||||
click () {
|
||||
// console.log(parent)
|
||||
this.$emit('click')
|
||||
},
|
||||
remove () {
|
||||
if (this.editbutton) {
|
||||
this.$parent.$parent.mapObject.removeControl(this.editbutton)
|
||||
}
|
||||
},
|
||||
add () {
|
||||
if (this.$parent.$parent._isMounted) {
|
||||
this.deferredMountedTo(this.$parent.$parent.mapObject)
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
</style>
|
@ -0,0 +1,37 @@
|
||||
/* eslint-disable */
|
||||
L.EditControl = L.Control.extend({
|
||||
|
||||
options: {
|
||||
position: 'topleft',
|
||||
callback: null,
|
||||
kind: '',
|
||||
html: '<i class="fas fa-draw-polygon"></i>',
|
||||
tooltip: 'tooltip'
|
||||
},
|
||||
|
||||
onAdd: function (map) {
|
||||
var container = L.DomUtil.create('div', 'leaflet-control leaflet-bar'),
|
||||
link = L.DomUtil.create('a', '', container);
|
||||
|
||||
link.href = '#';
|
||||
link.title = this.options.tooltip;
|
||||
link.innerHTML = this.options.html;
|
||||
L.DomEvent.on(link, 'click', L.DomEvent.stop)
|
||||
.on(link, 'click', function () {
|
||||
window.LAYER = this.options.callback.call(map.editTools);
|
||||
}, this);
|
||||
|
||||
return container;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
L.NewMarkerControl = L.EditControl.extend({
|
||||
options: {
|
||||
position: 'topright',
|
||||
callback: null,
|
||||
kind: 'marker',
|
||||
html: '🖈'
|
||||
}
|
||||
|
||||
});
|
Loading…
Reference in new issue