Commit 20fc3cf8 by 胡悦
2 parents 1cb01107 3ad9672b
<template>
<div class="map-box" :style="{height: mapHeight+ 'px'}">
<div class="map-box" :style="{ height: mapHeight + 'px' }">
<div id="container" style="width: 100%; height: 100%"></div>
<div class="map-address">{{ address }}</div>
<div id="myPageTop" style="position: absolute; top: 10px; width: 50%; left: 25%">
......@@ -11,10 +11,9 @@
</template>
<script>
import AMap from "AMap";
let map,marker, placeSearch;
let map, marker, placeSearch
export default {
name: "map",
name: 'map',
props: {
mapHeight: {
type: Number,
......@@ -24,83 +23,95 @@ export default {
data() {
return {
input: "",
address: "",
lnglat: [],
};
input: '',
address: '',
lnglat: []
}
},
methods: {
mapInit() {
map = new AMap.Map("container", {
map = new AMap.Map('container', {
resizeEnable: true,
zoom: 15,
});
AMap.plugin(["AMap.PlaceSearch"], function () {
zoom: 20
})
AMap.plugin(['AMap.PlaceSearch'], function () {
//构造地点查询类
placeSearch = new AMap.PlaceSearch({
pageSize: 8, // 单页显示结果条数
pageIndex: 1, // 页码
citylimit: false, //是否强制限制在设置的城市内搜索
map: map, // 展现结果的地图实例
// panel: "panel", // 结果列表将在此容器中进行展示。
autoFitView: true, // 是否自动调整地图视野使绘制的 Marker点都处于视口的可见范围
renderStyle: "default",
});
});
renderStyle: 'default'
})
})
// 添加列表点选监听事件
map.on("click", this.getAddress);
placeSearch.on("markerClick", this.getAddress);
map.on('click', this.getAddress)
},
searchAddress() {
let _this = this
placeSearch.search(this.input, function (status, result) {
console.log(result)
if (status === 'complete' && result.poiList.pois.length) {
let lnglat = result.poiList.pois[0].location
_this.getAddress(lnglat)
}
})
},
addMarker(lnglat) {
let position = [lnglat.lng,lnglat.lat]
marker = new AMap.Marker({
icon: new AMap.Icon({
image: "//a.amap.com/jsapi_demos/static/demo-center/icons/poi-marker-default.png",
size: new AMap.Size(27, 34), //图标大小
imageSize: new AMap.Size(27,34)
}),
position:position,
offset: new AMap.Pixel(-13, -30)
});
marker.setMap(map);
addMarker(lnglat) {
let position
if (lnglat.lng) {
position = [lnglat.lng, lnglat.lat]
} else {
position = lnglat
}
console.log(position)
marker = new AMap.Marker({
icon: new AMap.Icon({
image: '//a.amap.com/jsapi_demos/static/demo-center/icons/poi-marker-default.png',
size: new AMap.Size(27, 34), //图标大小
imageSize: new AMap.Size(27, 34)
}),
position: position,
offset: new AMap.Pixel(-10, -10)
})
map.add(marker);
map.setFitView();
},
getAddress(e) {
let self = this;
let lnglat;
if (e.type == "click") {
console.log(e)
let self = this
let lnglat
if (e.type == 'click') {
lnglat = e.lnglat
} else {
let { lng, lat } = e.data.entr_location?e.data.entr_location:e.data.location;
lnglat = [lng, lat];
let { lng, lat } = e
lnglat = [lng, lat]
}
if (marker) {
marker.setMap(null)
marker = null
}
if (marker) {
marker.setMap(null);
marker = null;
}
self.addMarker(lnglat)
AMap.plugin("AMap.Geocoder", () => {
const geocoder = new AMap.Geocoder();
geocoder.getAddress(lnglat, (status, result) => {
self.lnglat = lnglat;
self.address = result.regeocode.formattedAddress;
});
});
},
searchAddress() {
placeSearch.search(this.input, function (status, result) {
if (status == "complete") {
// console.log(result.poiList.pois);
}
});
AMap.plugin('AMap.Geocoder', () => {
const geocoder = new AMap.Geocoder()
geocoder.getAddress(lnglat, (status, result) => {
self.lnglat = lnglat
self.address = result.regeocode.formattedAddress
})
})
},
selectAddress(e) {
//这里获得点选地点的经纬度
this.getAddress();
this.getAddress()
}
},
mounted() {
this.mapInit();
this.mapInit()
}
};
}
</script>
<style scoped lang="scss">
......
......@@ -12,16 +12,15 @@ import apis from './api'
import './public-path'
// import 'glsx-components/dist/glsx-components.css'
import { start } from '@/setup'
// import VueAMap from "vue-amap";
import VueAMap from "vue-amap";
import filters from './utils/filters' //新增过滤器
// Vue.use(VueAMap);
// // 初始化vue-amap
// VueAMap.initAMapApiLoader({
// key: "bd290dc27d0945959280753215ddda71", // 这里写你申请的高德地图的key
// plugin: ["AMap.Autocomplete", "AMap.Geocoder", "AMap.Geolocation"],
// v: "1.4.15",
// uiVersion: "1.1"
// });
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.prototype.$apis = apis
start()
......
......@@ -98,6 +98,9 @@ export default {
// 设置全选
var arr = tabMenu.find(i => i.accounttypeId == tabName).products.find(j => j.productId == productTab).merchantProTreeResponses
this.$refs[`tree_${tabName}_${productTab}`] ? this.$refs[`tree_${tabName}_${productTab}`][0].setCheckedKeys(this.getAllId(arr)) : ''
this.$nextTick(() => {
this.addStyle()
})
},
productClick(productId) {
this.productTab = productId
......@@ -129,9 +132,6 @@ export default {
}
})
this.tabMenu_r = util.deepClone(tabMenu)
this.$nextTick(() => {
this.addStyle()
})
this.accountTypes = tabMenu.map(item => {
return {
products: null,
......@@ -184,6 +184,7 @@ export default {
if (i.productId == j.productId) {
itm.productsArr.push(j)
this.$nextTick(() => {
this.addStyle()
this.$refs[`tree_${itm.accounttypeId}_${j.productId}`][0].setCheckedKeys(i.idList)
})
}
......@@ -207,6 +208,7 @@ export default {
if (i.productId == j.productId) {
itm.productsArr.push(j)
this.$nextTick(() => {
this.addStyle()
this.$refs[`tree_${itm.accounttypeId}_${j.productId}`] ? this.$refs[`tree_${itm.accounttypeId}_${j.productId}`][0].setCheckedKeys(i.menuIds) : ''
})
}
......
......@@ -18,10 +18,10 @@
<el-input size="small" disabled style="width: 40%" v-model="ruleForm.merchantName"></el-input>
</el-form-item>
<el-form-item label="角色名称" prop="roleName">
<el-input size="small" maxlength="20" show-word-limit style="width: 40%;padding-right:50px" v-model="ruleForm.roleName" placeholder="请输入角色名称"></el-input>
<el-input size="small" maxlength="20" style="width: 40%;padding-right:50px" v-model="ruleForm.roleName" placeholder="请输入角色名称"></el-input>
</el-form-item>
<el-form-item label="角色说明" prop="roleDesc">
<el-input size="small" maxlength="50" show-word-limit style="width: 40%;padding-right:50px" v-model="ruleForm.roleDesc" placeholder="请输入角色说明"></el-input>
<el-input size="small" maxlength="50" style="width: 40%;padding-right:50px" v-model="ruleForm.roleDesc" placeholder="请输入角色说明"></el-input>
</el-form-item>
<!-- <el-form-item label="角色权限" prop="roleRoot">
<div class="custom_element">
......
......@@ -14,7 +14,7 @@ const cdn = {
`${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`,
'http://webapi.amap.com/maps?v=2.0&key=bd290dc27d0945959280753215ddda71&plugin=AMap.Geocoder'
// 'https://webapi.amap.com/maps?v=1.3&key=bd290dc27d0945959280753215ddda71&plugin=AMap.Geocoder'
]
}
module.exports = {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!