Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
saas
/
scrm-micro-marketing
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit de245bb9
authored
Sep 19, 2022
by
chenwq
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
地图组件
1 parent
4039d976
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
129 additions
and
66 deletions
package.json
src/components/glsx-combi-form/images/icon-map.png
src/components/glsx-combi-form/index.vue
src/components/glsx-combi-form/mapView.vue
src/main.js
vue.config.js
package.json
View file @
de245bb
...
@@ -17,7 +17,6 @@
...
@@ -17,7 +17,6 @@
"lodash"
:
"^4.17.21"
,
"lodash"
:
"^4.17.21"
,
"node-sass"
:
"^4.0.0"
,
"node-sass"
:
"^4.0.0"
,
"vue"
:
"^2.6.10"
,
"vue"
:
"^2.6.10"
,
"vue-amap"
:
"^0.5.10"
,
"vue-router"
:
"^3.1.3"
,
"vue-router"
:
"^3.1.3"
,
"vuedraggable"
:
"^2.24.3"
,
"vuedraggable"
:
"^2.24.3"
,
"vuex"
:
"^3.1.2"
,
"vuex"
:
"^3.1.2"
,
...
...
src/components/glsx-combi-form/images/icon-map.png
0 → 100644
View file @
de245bb
1.22 KB
src/components/glsx-combi-form/index.vue
View file @
de245bb
...
@@ -101,7 +101,7 @@
...
@@ -101,7 +101,7 @@
</div>
</div>
</GLDialog>
</GLDialog>
<GLDialog
bigTitle=
"选择地址"
mode=
"big"
:visible
.
sync=
"dialogMapVisible"
@
onOk=
"getAddress"
@
onCancel=
"dialogMapVisible = false"
>
<GLDialog
bigTitle=
"选择地址"
mode=
"big"
:visible
.
sync=
"dialogMapVisible"
@
onOk=
"getAddress"
@
onCancel=
"dialogMapVisible = false"
>
<map-view
ref=
"mapForm"
:mapHeight=
"mapHeight
"
></map-view>
<map-view
v-if=
"dialogMapVisible"
ref=
"mapForm
"
></map-view>
<!-- <span slot="footer" class="dialog-footer">
<!-- <span slot="footer" class="dialog-footer">
<el-button @click="">取 消</el-button>
<el-button @click="">取 消</el-button>
<el-button type="primary" @click="getAddress">确 定</el-button>
<el-button type="primary" @click="getAddress">确 定</el-button>
...
@@ -124,7 +124,6 @@ export default {
...
@@ -124,7 +124,6 @@ export default {
afterRangePickerOptions
:
afterRangePickerOptions
afterRangePickerOptions
:
afterRangePickerOptions
},
},
subdistrict
:
2
,
subdistrict
:
2
,
mapHeight
:
450
,
dialogMapVisible
:
false
,
dialogMapVisible
:
false
,
targetItem
:
{},
targetItem
:
{},
isImgVisible
:
false
,
isImgVisible
:
false
,
...
@@ -284,7 +283,8 @@ export default {
...
@@ -284,7 +283,8 @@ export default {
this
.
$nextTick
(()
=>
{
this
.
$nextTick
(()
=>
{
if
(
this
.
formObj
[
targetItem
.
attrObj
.
fullAddress
]
&&
!
this
.
$refs
.
mapForm
.
address
)
{
if
(
this
.
formObj
[
targetItem
.
attrObj
.
fullAddress
]
&&
!
this
.
$refs
.
mapForm
.
address
)
{
this
.
$refs
.
mapForm
.
address
=
this
.
formObj
[
targetItem
.
attrObj
.
fullAddress
]
this
.
$refs
.
mapForm
.
address
=
this
.
formObj
[
targetItem
.
attrObj
.
fullAddress
]
this
.
$refs
.
mapForm
.
addMarker
([
this
.
formObj
[
targetItem
.
attrObj
.
lng
],
this
.
formObj
[
targetItem
.
attrObj
.
lat
]])
this
.
$refs
.
mapForm
.
lnglat
=
this
.
formObj
[
targetItem
.
attrObj
.
lng
]
?
[
this
.
formObj
[
targetItem
.
attrObj
.
lng
],
this
.
formObj
[
targetItem
.
attrObj
.
lat
]]
:
[]
// this.$refs.mapForm.addMarker([this.formObj[targetItem.attrObj.lng], this.formObj[targetItem.attrObj.lat]])
}
}
})
})
},
},
...
@@ -299,8 +299,8 @@ export default {
...
@@ -299,8 +299,8 @@ export default {
return
return
}
}
this
.
formObj
[
this
.
targetItem
.
attrObj
.
fullAddress
]
=
mapInfo
.
address
this
.
formObj
[
this
.
targetItem
.
attrObj
.
fullAddress
]
=
mapInfo
.
address
this
.
formObj
[
this
.
targetItem
.
attrObj
.
lat
]
=
mapInfo
.
lnglat
.
lat
this
.
formObj
[
this
.
targetItem
.
attrObj
.
lat
]
=
mapInfo
.
lnglat
[
1
]
this
.
formObj
[
this
.
targetItem
.
attrObj
.
lng
]
=
mapInfo
.
lnglat
.
lng
this
.
formObj
[
this
.
targetItem
.
attrObj
.
lng
]
=
mapInfo
.
lnglat
[
0
]
// var fullAddress = mapInfo.geocoderAddress.addressComponent || this.formObj[this.targetItem.attrObj.fullAddress]
// var fullAddress = mapInfo.geocoderAddress.addressComponent || this.formObj[this.targetItem.attrObj.fullAddress]
var
fullAddress
=
mapInfo
.
geocoderAddress
.
addressComponent
var
fullAddress
=
mapInfo
.
geocoderAddress
.
addressComponent
var
provincecode
=
mapInfo
.
geocoderAddress
.
adcode
||
this
.
formObj
[
this
.
targetItem
.
attrObj
.
provinceCode
]
var
provincecode
=
mapInfo
.
geocoderAddress
.
adcode
||
this
.
formObj
[
this
.
targetItem
.
attrObj
.
provinceCode
]
...
...
src/components/glsx-combi-form/mapView.vue
View file @
de245bb
<
template
>
<
template
>
<div
class=
"map-box"
:style=
"
{ height: mapHeight + 'px' }">
<div
class=
"map-box"
:style=
"
{ height: mapHeight + 'px', width: mapWidth + 'xp' }">
<div
id=
"container"
style=
"width: 100%; height: 100%"
></div>
<div
id=
"container"
>
<div
class=
"map-address"
>
{{
address
}}
</div>
<el-select
v-model=
"input"
class=
"map-input"
filterable
remote
reserve-keyword
placeholder=
"请输入"
:remote-method=
"remoteMethod"
@
change=
"handleChangeAdr"
:loading=
"loading"
>
<div
id=
"myPageTop"
style=
"position: absolute; top: 10px; width: 50%; left: 25%"
>
<el-option
v-for=
"item in adrList"
:key=
"item.id"
:label=
"item.address"
:value=
"item.id"
></el-option>
<el-input
placeholder=
"请输入关键字"
v-model=
"input"
class=
"input-with-select"
>
</el-select>
<el-button
slot=
"append"
icon=
"el-icon-search"
@
click=
"searchAddress"
></el-button>
</div>
</el-input>
<div
class=
"map-address"
>
<img
class=
"icon-map"
src=
"./images/icon-map.png"
/>
{{
address
}}
</div>
</div>
</div>
</div>
</
template
>
</
template
>
...
@@ -16,43 +18,90 @@ export default {
...
@@ -16,43 +18,90 @@ export default {
props
:
{
props
:
{
mapHeight
:
{
mapHeight
:
{
type
:
Number
,
type
:
Number
,
default
:
300
default
:
460
},
mapWidth
:
{
type
:
Number
,
default
:
740
}
}
},
},
data
()
{
data
()
{
return
{
return
{
input
:
''
,
input
:
[]
,
address
:
''
,
address
:
''
,
adrList
:
[],
lnglat
:
[],
lnglat
:
[],
geocoderAddress
:
{}
geocoderAddress
:
{}
}
}
},
},
mounted
()
{
this
.
mapInit
()
},
methods
:
{
methods
:
{
// initMap() {
// console.log(document.getElementsByTagName('head'))
// var script = document.createElement('script')
// script.type = 'text/javascript'
// script.src = 'https://webapi.amap.com/loader.js'
// document.getElementsByTagName('head')[0].appendChild(script)
// },
mapInit
()
{
mapInit
()
{
map
=
new
AMap
.
Map
(
'container'
,
{
/* eslint-disable */
resizeEnable
:
true
,
AMapLoader
.
load
({
zoom
:
20
/* eslint-enable */
key
:
'44cc16e43ad7ed3358df507bd0618181'
,
// 申请好的Web端开发者Key,首次调用 load 时必填
version
:
'2.0'
,
// 指定要加载的 JSAPI 的版本,缺省时默认为 1.4.15
// 需要使用的的插件列表
plugins
:
[
'AMap.ToolBar'
,
'AMap.Scale'
,
'AMap.Geocoder'
],
AMapUI
:
{
// 是否加载 AMapUI,缺省不加载
version
:
'1.1'
,
// AMapUI 版本
plugins
:
[
'overlay/SimpleMarker'
]
// 需要加载的 AMapUI ui插件
},
Loca
:
{
// 是否加载 Loca, 缺省不加载
version
:
'2.0'
// Loca 版本
}
})
})
AMap
.
plugin
([
'AMap.PlaceSearch'
],
function
()
{
.
then
(
AMap
=>
{
//构造地点查询类
map
=
new
AMap
.
Map
(
'container'
,
{
placeSearch
=
new
AMap
.
PlaceSearch
({
zoom
:
20
,
pageSize
:
8
,
// 单页显示结果条数
autoFitView
:
true
,
pageIndex
:
1
,
// 页码
resizeEnable
:
true
,
citylimit
:
false
,
//是否强制限制在设置的城市内搜索
cursor
:
'move'
// panel: "panel", // 结果列表将在此容器中进行展示。
})
autoFitView
:
true
,
// 是否自动调整地图视野使绘制的 Marker点都处于视口的可见范围
if
(
this
.
lnglat
.
length
)
{
renderStyle
:
'default'
this
.
addMarker
(
this
.
lnglat
)
}
map
.
addControl
(
new
AMap
.
Scale
())
map
.
addControl
(
new
AMap
.
ToolBar
())
this
.
geocoder
=
new
AMap
.
Geocoder
()
map
.
setDefaultCursor
(
'pointer'
)
AMap
.
plugin
([
'AMap.PlaceSearch'
],
function
()
{
//构造地点查询类
placeSearch
=
new
AMap
.
PlaceSearch
({
pageSize
:
8
,
// 单页显示结果条数
pageIndex
:
1
,
// 页码
citylimit
:
false
,
//是否强制限制在设置的城市内搜索
// panel: "panel", // 结果列表将在此容器中进行展示。
autoFitView
:
true
,
// 是否自动调整地图视野使绘制的 Marker点都处于视口的可见范围
renderStyle
:
'default'
})
})
map
.
on
(
'click'
,
this
.
getAddress
)
})
.
catch
(
e
=>
{
console
.
error
(
e
)
//加载错误提示
})
})
})
// 添加列表点选监听事件
map
.
on
(
'click'
,
this
.
getAddress
)
},
},
searchAddress
()
{
remoteMethod
(
query
)
{
if
(
query
==
''
)
{
return
true
}
let
_this
=
this
let
_this
=
this
placeSearch
.
search
(
this
.
input
,
function
(
status
,
result
)
{
placeSearch
.
search
(
query
,
function
(
status
,
result
)
{
if
(
status
===
'complete'
&&
result
.
poiList
.
pois
.
length
)
{
if
(
status
===
'complete'
&&
result
.
poiList
.
pois
.
length
)
{
let
lnglat
=
result
.
poiList
.
pois
[
0
].
location
_this
.
adrList
=
result
.
poiList
.
pois
_this
.
getAddress
(
lnglat
)
}
}
})
})
},
},
...
@@ -63,63 +112,76 @@ export default {
...
@@ -63,63 +112,76 @@ export default {
}
else
{
}
else
{
position
=
lnglat
position
=
lnglat
}
}
this
.
lnglat
=
position
marker
=
new
AMap
.
Marker
({
marker
=
new
AMap
.
Marker
({
map
:
map
,
icon
:
new
AMap
.
Icon
({
icon
:
new
AMap
.
Icon
({
image
:
'//a.amap.com/jsapi_demos/static/demo-center/icons/poi-marker-default.png'
,
image
:
'//a.amap.com/jsapi_demos/static/demo-center/icons/poi-marker-default.png'
,
size
:
new
AMap
.
Size
(
27
,
34
),
//图标大小
size
:
new
AMap
.
Size
(
27
,
34
),
//图标大小
imageSize
:
new
AMap
.
Size
(
27
,
34
)
imageSize
:
new
AMap
.
Size
(
27
,
34
)
}),
}),
// draggable: true,
position
:
position
,
position
:
position
,
offset
:
new
AMap
.
Pixel
(
-
10
,
-
10
)
offset
:
new
AMap
.
Pixel
(
-
10
,
-
10
)
})
})
map
.
setCenter
(
position
)
map
.
add
(
marker
)
map
.
add
(
marker
)
map
.
setFitView
()
marker
.
setMap
(
map
)
// this.map.setFitView()
},
},
getAddress
(
e
)
{
getAddress
(
e
)
{
let
self
=
this
let
self
=
this
let
lnglat
let
position
if
(
e
.
type
==
'click'
)
{
if
(
e
.
type
==
'click'
)
{
lnglat
=
e
.
lnglat
position
=
e
.
lnglat
}
else
{
}
else
{
let
{
lng
,
lat
}
=
e
let
{
lng
,
lat
}
=
e
lnglat
=
[
lng
,
lat
]
position
=
[
lng
,
lat
]
}
}
if
(
marker
)
{
if
(
marker
)
{
map
.
remove
(
marker
)
marker
.
setMap
(
null
)
marker
.
setMap
(
null
)
marker
=
null
marker
=
null
}
}
self
.
addMarker
(
lnglat
)
self
.
addMarker
(
position
)
AMap
.
plugin
(
'AMap.Geocoder'
,
()
=>
{
AMap
.
plugin
(
'AMap.Geocoder'
,
()
=>
{
const
geocoder
=
new
AMap
.
Geocoder
()
const
geocoder
=
new
AMap
.
Geocoder
()
geocoder
.
getAddress
(
lnglat
,
(
status
,
result
)
=>
{
geocoder
.
getAddress
(
position
,
(
status
,
result
)
=>
{
self
.
lnglat
=
lnglat
self
.
address
=
result
.
regeocode
.
formattedAddress
self
.
address
=
result
.
regeocode
.
formattedAddress
geocoder
.
getLocation
(
self
.
address
,
(
status
,
result
)
=>
{
geocoder
.
getLocation
(
self
.
address
,
(
status
,
result
)
=>
{
if
(
status
===
'complete'
&&
result
.
info
===
'OK'
)
{
if
(
status
===
'complete'
&&
result
.
info
===
'OK'
)
{
this
.
geocoderAddress
=
result
.
geocodes
[
0
]
self
.
geocoderAddress
=
result
.
geocodes
[
0
]
}
}
})
})
})
})
})
})
},
},
selectAddress
(
e
)
{
handleChangeAdr
(
val
)
{
//这里获得点选地点的经纬度
if
(
val
)
{
this
.
getAddress
()
var
location
=
this
.
adrList
.
find
(
item
=>
item
.
id
==
val
)
this
.
getAddress
(
location
.
location
)
this
.
input
=
''
this
.
adrList
=
[]
}
}
}
},
mounted
()
{
this
.
mapInit
()
}
}
}
}
</
script
>
</
script
>
<
style
scoped
lang=
"scss"
>
<
style
scoped
lang=
"scss"
>
.map-box
{
.map-box
{
position
:
relative
;
display
:
flex
;
width
:
100%
;
#container
{
}
position
:
relative
;
#container
{
width
:
calc
(
100%
-
284px
-
16px
);
position
:
absolute
;
height
:
100%
;
height
:
100%
;
}
.map-input
{
position
:
absolute
;
top
:
32px
;
width
:
60%
;
left
:
25%
;
z-index
:
2
;
}
}
}
#panel
{
#panel
{
position
:
absolute
;
position
:
absolute
;
...
@@ -130,8 +192,18 @@ export default {
...
@@ -130,8 +192,18 @@ export default {
width
:
280px
;
width
:
280px
;
}
}
.map-address
{
.map-address
{
position
:
absolute
;
display
:
flex
;
box-sizing
:
border-box
;
width
:
284px
;
height
:
100%
;
background-color
:
#f9f9f9
;
padding
:
20px
;
margin-left
:
16px
;
line-height
:
20px
;
line-height
:
20px
;
bottom
:
-30px
;
.icon-map
{
width
:
16px
;
height
:
16px
;
margin-right
:
6px
;
}
}
}
</
style
>
\ No newline at end of file
\ No newline at end of file
</
style
>
src/main.js
View file @
de245bb
...
@@ -15,14 +15,6 @@ import '@/components'
...
@@ -15,14 +15,6 @@ import '@/components'
// import 'glsx-components/dist/glsx-components.css'
// import 'glsx-components/dist/glsx-components.css'
import
{
start
}
from
'@/setup'
import
{
start
}
from
'@/setup'
import
{
setMinHeight
}
from
'@/common/constant'
import
{
setMinHeight
}
from
'@/common/constant'
import
VueAMap
from
'vue-amap'
Vue
.
use
(
VueAMap
)
// 初始化vue-amap
VueAMap
.
initAMapApiLoader
({
key
:
'bd290dc27d0945959280753215ddda71'
,
// 这里写你申请的高德地图的key
plugin
:
[
'AMap.PlaceSearch'
,
'AMap.Geocoder'
,
'AMap.Geolocation'
],
v
:
'1.4.15'
})
Vue
.
config
.
productionTip
=
false
Vue
.
config
.
productionTip
=
false
Vue
.
prototype
.
$apis
=
apis
Vue
.
prototype
.
$apis
=
apis
Vue
.
prototype
.
size
=
'small'
Vue
.
prototype
.
size
=
'small'
...
...
vue.config.js
View file @
de245bb
...
@@ -6,7 +6,7 @@ const resolve = dir => path.join(__dirname, dir)
...
@@ -6,7 +6,7 @@ const resolve = dir => path.join(__dirname, dir)
const
CDN_DOMAIN
=
'https://img02.glsx.com.cn/'
const
CDN_DOMAIN
=
'https://img02.glsx.com.cn/'
const
cdn
=
{
const
cdn
=
{
css
:
[
`
${
CDN_DOMAIN
}
ajax/libs/element-ui/2.11.1/theme-chalk/index.css`
],
css
:
[
`
${
CDN_DOMAIN
}
ajax/libs/element-ui/2.11.1/theme-chalk/index.css`
],
js
:
[
`
${
CDN_DOMAIN
}
ajax/libs/vue/2.6.11/vue.min.js`
,
`
${
CDN_DOMAIN
}
ajax/libs/vue-router/3.2.0/vue-router.min.js`
,
`
${
CDN_DOMAIN
}
ajax/libs/element-ui/2.11.1/index.js`
,
`
${
CDN_DOMAIN
}
ajax/libs/vuex/3.6.2/vuex.min.js`
,
`
${
CDN_DOMAIN
}
ajax/libs/echarts/5.1.2/echarts.min.js`
,
`
${
CDN_DOMAIN
}
ajax/libs/moment/2.24.0/moment.js`
]
js
:
[
`
${
CDN_DOMAIN
}
ajax/libs/vue/2.6.11/vue.min.js`
,
`
${
CDN_DOMAIN
}
ajax/libs/vue-router/3.2.0/vue-router.min.js`
,
`
${
CDN_DOMAIN
}
ajax/libs/element-ui/2.11.1/index.js`
,
`
${
CDN_DOMAIN
}
ajax/libs/vuex/3.6.2/vuex.min.js`
,
`
${
CDN_DOMAIN
}
ajax/libs/echarts/5.1.2/echarts.min.js`
,
`
${
CDN_DOMAIN
}
ajax/libs/moment/2.24.0/moment.js`
,
'https://webapi.amap.com/loader.js'
]
}
}
module
.
exports
=
{
module
.
exports
=
{
outputDir
:
`../dist/
${
packageName
}
`
,
outputDir
:
`../dist/
${
packageName
}
`
,
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment