|
@@ -0,0 +1,141 @@
|
|
|
|
|
+<template>
|
|
|
|
|
+ <div>
|
|
|
|
|
+ <div class="flex flex-center">
|
|
|
|
|
+ <el-input class="mr-10" placeholder="请选择项目地址"></el-input>
|
|
|
|
|
+ <el-button type="primary" plain @click="show = true">查看地图</el-button>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <el-dialog v-model="show" :width="960">
|
|
|
|
|
+ <template #header
|
|
|
|
|
+ ><h4 class="full-width text-left">地理位置</h4></template
|
|
|
|
|
+ >
|
|
|
|
|
+ <div class="flex flex-center flex-justify-start flex-col">
|
|
|
|
|
+ <div id="container" class="map"></div>
|
|
|
|
|
+ <el-divider />
|
|
|
|
|
+ <div class="flex flex-center flex-justify-start full-width">
|
|
|
|
|
+ <div class="text-left bold-500 black mr-10">相关图片</div>
|
|
|
|
|
+ <filepicker :project-id="projectId" />
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <div class="img-content flex flex-justify-start hide-scrollbar mt-20">
|
|
|
|
|
+ <img src="../../../assets/svg/folder.svg" v-for="i in 20" />
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <div class="full-width flex flex-center flex-justify-end">
|
|
|
|
|
+ <el-button type="primary" plain @click="show = false"
|
|
|
|
|
+ >取 消
|
|
|
|
|
+ </el-button>
|
|
|
|
|
+ <el-button type="primary">确 定</el-button>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </el-dialog>
|
|
|
|
|
+ </div>
|
|
|
|
|
+</template>
|
|
|
|
|
+
|
|
|
|
|
+<script>
|
|
|
|
|
+import filepicker from '@/components/filepicker/index.vue'
|
|
|
|
|
+import AMapLoader from '@amap/amap-jsapi-loader'
|
|
|
|
|
+import { shallowRef } from 'vue'
|
|
|
|
|
+
|
|
|
|
|
+export default {
|
|
|
|
|
+ components: {
|
|
|
|
|
+ filepicker
|
|
|
|
|
+ },
|
|
|
|
|
+ setup() {
|
|
|
|
|
+ const map = shallowRef(null)
|
|
|
|
|
+ return {
|
|
|
|
|
+ map
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ watch: {
|
|
|
|
|
+ show: {
|
|
|
|
|
+ handler(val) {
|
|
|
|
|
+ if (val) {
|
|
|
|
|
+ this.initMap()
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ immediate: true
|
|
|
|
|
+ },
|
|
|
|
|
+ latitude: {
|
|
|
|
|
+ handler(val) {
|
|
|
|
|
+ if (val.length > 0 && this.show) {
|
|
|
|
|
+ this.addMarker()
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ props: {
|
|
|
|
|
+ projectId: {
|
|
|
|
|
+ required: true,
|
|
|
|
|
+ type: String,
|
|
|
|
|
+ default: ''
|
|
|
|
|
+ },
|
|
|
|
|
+ latitude: {
|
|
|
|
|
+ type: Number,
|
|
|
|
|
+ default: 0
|
|
|
|
|
+ },
|
|
|
|
|
+ longitude: {
|
|
|
|
|
+ type: Number,
|
|
|
|
|
+ default: 0
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ data() {
|
|
|
|
|
+ return {
|
|
|
|
|
+ show: false,
|
|
|
|
|
+ aMap: null
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ methods: {
|
|
|
|
|
+ initMap() {
|
|
|
|
|
+ AMapLoader.load({
|
|
|
|
|
+ key: '6577c6fd4841e6c69d5fb1bd15bd4696', // 申请好的Web端开发者Key,首次调用 load 时必填
|
|
|
|
|
+ version: '2.0', // 指定要加载的 JSAPI 的版本,缺省时默认为 1.4.15
|
|
|
|
|
+ plugins: ['AMap.Scale', 'AMap.Marker'] // 需要使用的的插件列表,如比例尺'AMap.Scale'等
|
|
|
|
|
+ })
|
|
|
|
|
+ .then(AMap => {
|
|
|
|
|
+ this.aMap = AMap
|
|
|
|
|
+ this.map = new AMap.Map('container', {
|
|
|
|
|
+ // 设置地图容器id
|
|
|
|
|
+ viewMode: '2D', // 是否为3D地图模式
|
|
|
|
|
+ zoom: 15, // 初始化地图级别
|
|
|
|
|
+ mapStyle: 'amap://styles/whitesmoke',
|
|
|
|
|
+ center: [this.latitude, this.longitude] // 初始化地图中心点位置
|
|
|
|
|
+ })
|
|
|
|
|
+ this.addMarker()
|
|
|
|
|
+ this.addEvent()
|
|
|
|
|
+ })
|
|
|
|
|
+ .catch(e => {
|
|
|
|
|
+ console.log(e)
|
|
|
|
|
+ })
|
|
|
|
|
+ },
|
|
|
|
|
+ addMarker() {
|
|
|
|
|
+ console.log('addMark')
|
|
|
|
|
+ const marker = new this.aMap.Marker({
|
|
|
|
|
+ position: new this.aMap.LngLat(this.latitude, this.longitude), // 经纬度对象,也可以是经纬度构成的一维数组[116.39, 39.9]
|
|
|
|
|
+ title: '大理'
|
|
|
|
|
+ })
|
|
|
|
|
+ this.map.add(marker)
|
|
|
|
|
+ },
|
|
|
|
|
+ addEvent() {
|
|
|
|
|
+ this.map.on('click', event => {
|
|
|
|
|
+ console.log(event)
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+</script>
|
|
|
|
|
+
|
|
|
|
|
+<style lang="scss" scoped>
|
|
|
|
|
+.map {
|
|
|
|
|
+ width: 100%;
|
|
|
|
|
+ height: 400px;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+.img-content {
|
|
|
|
|
+ width: 100%;
|
|
|
|
|
+ height: 140px;
|
|
|
|
|
+ overflow-x: scroll;
|
|
|
|
|
+
|
|
|
|
|
+ img {
|
|
|
|
|
+ width: 120px;
|
|
|
|
|
+ height: 120px;
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+</style>
|