Commit cc298077 authored by 张泽丹's avatar 张泽丹 💻

feat:线型选择

parent 4b118e61
...@@ -2,7 +2,8 @@ ...@@ -2,7 +2,8 @@
<div class="edit-line"> <div class="edit-line">
<div class="style"> <div class="style">
<editor-title title="样式"></editor-title> <editor-title title="样式"></editor-title>
<shape shapeType="line" @change="handleShapeChange"></shape> <shape shapeType="line" :line="layerStyle['LineSymbolizer']['stroke-dasharray']"
@change="updateStyle('LineSymbolizer', 'stroke-dasharray', ...arguments)"></shape>
<!-- 矢量类型 --> <!-- 矢量类型 -->
<template v-if="shapeStyle === 'vector'"> <template v-if="shapeStyle === 'vector'">
<color-setting label="线条" <color-setting label="线条"
......
...@@ -6,9 +6,10 @@ ...@@ -6,9 +6,10 @@
label="填充" label="填充"
:editType="1" :editType="1"
:color="layerStyle['PolygonSymbolizer']['fill']" :color="layerStyle['PolygonSymbolizer']['fill']"
type="rgba"
@update:color="updateStyle('PolygonSymbolizer', 'fill', ...arguments)"> @update:color="updateStyle('PolygonSymbolizer', 'fill', ...arguments)">
</color-setting> </color-setting>
<color-setting label="边框" <color-setting v-if="layerStyle['LineSymbolizer']" label="边框"
:color="layerStyle['LineSymbolizer']['stroke']" :color="layerStyle['LineSymbolizer']['stroke']"
@update:color="updateStyle('LineSymbolizer', 'stroke', ...arguments)"></color-setting> @update:color="updateStyle('LineSymbolizer', 'stroke', ...arguments)"></color-setting>
</div> </div>
...@@ -42,11 +43,11 @@ export default { ...@@ -42,11 +43,11 @@ export default {
}, },
computed: { computed: {
layerStyle () { layerStyle () {
if (!this.layer.LineSymbolizer) { // if (!this.layer.LineSymbolizer) {
this.layer.LineSymbolizer = { // this.layer.LineSymbolizer = {
stroke: 'rgba(0,0,0,0)' // stroke: 'rgba(0,0,0,0)'
} // }
} // }
return this.layer return this.layer
} }
}, },
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
<template slot="content"> <template slot="content">
<!-- 统一颜色 --> <!-- 统一颜色 -->
<simple-color v-if="editType === 1" :color="color" v-on="$listeners"></simple-color> <simple-color :type="type" v-if="editType === 1" :color="color" v-on="$listeners"></simple-color>
<!-- 分段颜色 --> <!-- 分段颜色 -->
<complex-color v-if="editType === 2" :color="color" v-on="$listeners"></complex-color> <complex-color v-if="editType === 2" :color="color" v-on="$listeners"></complex-color>
</template> </template>
...@@ -41,6 +41,10 @@ export default { ...@@ -41,6 +41,10 @@ export default {
color: { color: {
type: String, type: String,
default: '' default: ''
},
type: {
type: String,
default: 'rgb'
} }
}, },
components: { components: {
......
...@@ -4,8 +4,8 @@ ...@@ -4,8 +4,8 @@
<a-popover :overlayStyle="{width: '300px'}" trigger="click" placement="rightTop"> <a-popover :overlayStyle="{width: '300px'}" trigger="click" placement="rightTop">
<div class="shape-block"> <div class="shape-block">
<div class="shape-inner" :class="{ 'shape-inner-line': shapeType === 'line' }"> <div class="shape-inner" :class="{ 'shape-inner-line': shapeType === 'line' }">
<!-- {{iconUrl}} --> <div class="shape-icon" v-if="shapeType === 'line'" :style="{backgroundImage: iconUrl}"></div>
<div class="shape-icon" v-html="iconUrl"></div> <div class="shape-icon" v-else v-html="iconUrl"></div>
</div> </div>
</div> </div>
<template slot="content"> <template slot="content">
...@@ -18,7 +18,8 @@ ...@@ -18,7 +18,8 @@
:key="icon.name" :key="icon.name"
:title="icon.title" :title="icon.title"
@click="useIcon(icon)"> @click="useIcon(icon)">
<div class="icon-inner" v-html="icon.url"></div> <div class="icon-inner" v-if="shapeType === 'line'" :style="{backgroundImage: getImagePath(icon)}"></div>
<div class="icon-inner" v-else v-html="icon.url"></div>
</li> </li>
</ul> </ul>
</div> </div>
...@@ -53,6 +54,10 @@ export default { ...@@ -53,6 +54,10 @@ export default {
icon: { icon: {
type: String, type: String,
default: '' default: ''
},
line: {
type: String,
default: ''
} }
}, },
data () { data () {
...@@ -64,7 +69,8 @@ export default { ...@@ -64,7 +69,8 @@ export default {
}, },
created () { created () {
if (this.shapeType === 'line') { if (this.shapeType === 'line') {
this.iconUrl = `url(${this.publicPath}shapeIcons/straightLine.png)` const checkedLine = lineShape[0].icons.find(item => item.dasharray.join(' ') === this.line)
this.iconUrl = this.getImagePath(checkedLine)
} else { } else {
this.getData() this.getData()
// this.iconUrl = `url(${this.publicPath}shapeIcons/circle.png)` // this.iconUrl = `url(${this.publicPath}shapeIcons/circle.png)`
...@@ -136,10 +142,16 @@ export default { ...@@ -136,10 +142,16 @@ export default {
} }
}, },
useIcon (icon) { useIcon (icon) {
if (this.shapeType === 'line') {
this.iconUrl = this.getImagePath(icon)
const dasharray = icon.dasharray.join(' ')
this.$emit('change', dasharray)
} else {
this.iconUrl = icon.url this.iconUrl = icon.url
this.$emit('change', icon.name) this.$emit('change', icon.name)
} }
} }
}
} }
</script> </script>
...@@ -184,6 +196,8 @@ export default { ...@@ -184,6 +196,8 @@ export default {
width: 100%; width: 100%;
height: 1px; height: 1px;
margin-top: 12px; margin-top: 12px;
background-repeat: repeat;
background-size: auto 100%;
} }
} }
} }
...@@ -234,8 +248,8 @@ export default { ...@@ -234,8 +248,8 @@ export default {
width: 100%; width: 100%;
height: 6px; height: 6px;
margin: 0 auto; margin: 0 auto;
background-repeat: no-repeat; background-repeat: repeat;
background-size: cover; background-size: auto 100%;
} }
} }
} }
......
...@@ -15,12 +15,20 @@ export default { ...@@ -15,12 +15,20 @@ export default {
color: { color: {
type: String, type: String,
default: 'rgba(0, 0, 0, 0.1)' default: 'rgba(0, 0, 0, 0.1)'
},
type: {
type: String,
default: 'rgb'
} }
}, },
methods: { methods: {
handleChange (info) { handleChange (info) {
const color = info.rgba const color = info.rgba
if (this.type === 'rgb') {
this.$emit('update:color', `rgb(${color.r},${color.g},${color.b})`) this.$emit('update:color', `rgb(${color.r},${color.g},${color.b})`)
} else {
this.$emit('update:color', `rgba(${color.r},${color.g},${color.b},${color.a})`)
}
} }
}, },
components: { components: {
......
...@@ -20,8 +20,8 @@ export default { ...@@ -20,8 +20,8 @@ export default {
fill: '#d81e06', fill: '#d81e06',
opacity: 0.5, opacity: 0.5,
stroke: '#000000', stroke: '#000000',
'stroke-width': 10, 'stroke-width': 0,
radius: 20 radius: 4
} }
}, },
{ {
...@@ -44,8 +44,8 @@ export default { ...@@ -44,8 +44,8 @@ export default {
fill: '#2c2c2c', fill: '#2c2c2c',
opacity: 0.5, opacity: 0.5,
stroke: '#000000', stroke: '#000000',
'stroke-width': 10, 'stroke-width': 0,
radius: 20 radius: 4
} }
}, },
{ {
...@@ -68,8 +68,8 @@ export default { ...@@ -68,8 +68,8 @@ export default {
fill: '#2c2c2c', fill: '#2c2c2c',
opacity: 0.5, opacity: 0.5,
stroke: '#000000', stroke: '#000000',
'stroke-width': 10, 'stroke-width': 0,
radius: 20 radius: 4
} }
}, },
{ {
...@@ -92,8 +92,8 @@ export default { ...@@ -92,8 +92,8 @@ export default {
fill: '#2c2c2c', fill: '#2c2c2c',
opacity: 0.5, opacity: 0.5,
stroke: '#000000', stroke: '#000000',
'stroke-width': 10, 'stroke-width': 0,
radius: 20 radius: 4
} }
} }
], ],
...@@ -193,7 +193,8 @@ export default { ...@@ -193,7 +193,8 @@ export default {
{ {
LineSymbolizer: { LineSymbolizer: {
stroke: 'rgb(0,175,255)', stroke: 'rgb(0,175,255)',
'stroke-width': 0.15 'stroke-width': 0.15,
'stroke-dasharray': "10 0"
} }
} }
], ],
...@@ -201,7 +202,8 @@ export default { ...@@ -201,7 +202,8 @@ export default {
{ {
LineSymbolizer: { LineSymbolizer: {
stroke: 'rgb(0,175,255)', stroke: 'rgb(0,175,255)',
'stroke-width': 0.15 'stroke-width': 0.15,
'stroke-dasharray': "10 0"
} }
} }
], ],
...@@ -209,7 +211,8 @@ export default { ...@@ -209,7 +211,8 @@ export default {
{ {
LineSymbolizer: { LineSymbolizer: {
stroke: 'rgb(10,175,235)', stroke: 'rgb(10,175,235)',
'stroke-width': 0.6 'stroke-width': 0.6,
'stroke-dasharray': "10 0"
} }
} }
], ],
...@@ -220,7 +223,8 @@ export default { ...@@ -220,7 +223,8 @@ export default {
}, },
LineSymbolizer: { LineSymbolizer: {
stroke: 'rgb(10,175,235)', stroke: 'rgb(10,175,235)',
'stroke-width': 0.28 'stroke-width': 0.28,
'stroke-dasharray': "10 0"
} }
} }
] ]
......
...@@ -76,36 +76,46 @@ export const lineShape = [ ...@@ -76,36 +76,46 @@ export const lineShape = [
dasharray: [10, 0] dasharray: [10, 0]
}, },
{ {
name: 'dotLine1', name: 'boul_g_1.jpg',
type: 'vector', type: 'vector',
title: '虚线1', title: '未定国界',
url: '', url: '',
dasharray: [5, 5] dasharray: [5, 5]
}, },
{ {
name: 'dotLine2', name: 'boul_g_2.jpg',
type: 'vector', type: 'vector',
title: '虚线2', title: '国界',
url: '', url: '',
dasharray: [2, 2] dasharray: [1, 2, 5, 2]
}, },
{ {
name: 'dotLine3', name: 'boul_s_1.jpg',
type: 'vector', type: 'vector',
title: '虚线3', title: '省界',
url: '', url: '',
dasharray: [10, 10] dasharray: [6, 2, 1, 2]
}
]
}, },
{ {
groupName: '交通', name: 'boul_s_2.jpg',
icons: [ type: 'vector',
title: '香港',
url: '',
dasharray: [5, 1, 3, 1]
},
{ {
name: 'dotLine5', name: 'boul_d.jpg',
type: 'img', type: 'vector',
title: '虚线5', title: '市界',
url: '' url: '',
dasharray: [7, 2, 1, 2, 1, 2]
},
{
name: 'boul_x.jpg',
type: 'vector',
title: '县界',
url: '',
dasharray: [5, 1, 5, 1, 0.5, 1]
} }
] ]
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment