| | |
| | | <template> |
| | | <div class="location-lon-and-lat"> |
| | | <el-row class="place-box"> |
| | | <div class="place-left"> |
| | | <el-form :model="LongLatPos" label-width="90px"> |
| | | <!-- <el-row>--> |
| | | <!-- <el-form :model="lonlatpos" label-width="60px">--> |
| | | <!-- <el-col :span="12">--> |
| | | <!-- <el-form-item label="经度:">--> |
| | | <!-- <el-input type="text" v-model="lonlatpos.longPos"></el-input>--> |
| | | <!-- </el-form-item>--> |
| | | <!-- </el-col>--> |
| | | <!-- <el-col :span="12">--> |
| | | <!-- <el-form-item label="纬度:">--> |
| | | <!-- <el-input type="text" v-model="lonlatpos.latPos"></el-input>--> |
| | | <!-- </el-form-item>--> |
| | | <!-- </el-col>--> |
| | | <!-- </el-form>--> |
| | | <!-- <el-row>--> |
| | | <!-- <el-col :span="12" style="text-align: center;margin: 5px 0">--> |
| | | <!-- <el-button type="primary" size="small" @click="mapPoints">精确定位</el-button>--> |
| | | <!-- </el-col>--> |
| | | <!-- <el-col :span="12" style="text-align: center;margin: 5px 0">--> |
| | | <!-- <el-button type="primary" size="small" @click="dataPoints">数据识取</el-button>--> |
| | | <!-- </el-col>--> |
| | | <!-- </el-row>--> |
| | | <!-- </el-row>--> |
| | | <el-form :model="lonlatpos" label-width="60px"> |
| | | <el-row class="pipe-line-search"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="经度:"> |
| | | <el-input v-model="LongLatPos.longPos"></el-input> |
| | | <el-input v-model="lonlatpos.longPos"></el-input> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="纬度:"> |
| | | <el-input v-model="LongLatPos.latPos"></el-input> |
| | | <el-input v-model="lonlatpos.latPos"></el-input> |
| | | </el-form-item> |
| | | </el-form> |
| | | </div> |
| | | <div class="place-right"> |
| | | <el-button type="primary" size="small" @click="mapPoints">点击定位</el-button> |
| | | <el-button type="primary" size="small" @click="dataPoints">数据定位</el-button> |
| | | </div> |
| | | </el-col> |
| | | </el-row> |
| | | </el-form> |
| | | <el-row> |
| | | <el-col :span="12" style="text-align: center;margin: 5px 0"> |
| | | <el-button type="primary" size="small" @click="mapPoints">精确定位</el-button> |
| | | </el-col> |
| | | <el-col :span="12" style="text-align: center;margin: 5px 0"> |
| | | <el-button type="primary" size="small" @click="dataPoints">数据识取</el-button> |
| | | </el-col> |
| | | </el-row> |
| | | <div class="place-bottom" style="text-align: right;margin: 5px"> |
| | | <el-button type="primary" @click="confirm">确认</el-button> |
| | | </div> |
| | | <el-row class="place-bottom" style="text-align: right;margin: 5px"> |
| | | <el-button type="primary" @click="confirm" size="small">确认</el-button> |
| | | </el-row> |
| | | </div> |
| | | </template> |
| | | |
| | | <script> |
| | | import { pulseEffect } from '../../../../utils/utils' |
| | | import iconUrl from '../../../../../public/assets/images/map/loc.png' |
| | | import iconUrl from '../../../../../public/assets/images/map/marker-icon.png' |
| | | import eventBus from '../../../../eventBus' |
| | | |
| | | export default { |
| | |
| | | data () { |
| | | return { |
| | | // 经纬度定位 |
| | | LongLatPos: { |
| | | lonlatpos: { |
| | | longPos: '', |
| | | latPos: '' |
| | | }, |
| | | marker: null |
| | | marker: window.L.layerGroup().addTo(window.map), |
| | | layersGroupArrList: [] |
| | | } |
| | | }, |
| | | methods: { |
| | | // 点击定位 |
| | | // 精确定位 |
| | | mapPoints () { |
| | | window.map.on('click', (e) => { |
| | | this.LongLatPos.longPos = parseFloat(e.latlng.lng).toFixed(6) |
| | | this.LongLatPos.latPos = parseFloat(e.latlng.lat).toFixed(6) |
| | | const as = [this.LongLatPos.latPos, this.LongLatPos.longPos] |
| | | this.lonlatpos.longPos = parseFloat(e.latlng.lng).toFixed(8) |
| | | this.lonlatpos.latPos = parseFloat(e.latlng.lat).toFixed(8) |
| | | const as = [e.latlng.lat, e.latlng.lng] |
| | | // console.log(as) |
| | | window.map.setView(as, 17) |
| | | pulseEffect(as) |
| | | this.marker = window.L.marker(as, { |
| | | icon: window.L.icon({ |
| | | iconUrl: iconUrl, |
| | | iconSize: [30, 30], |
| | | iconAnchor: [15, 15] |
| | | iconSize: [26, 40], |
| | | iconAnchor: [13, 20] |
| | | }) |
| | | }) |
| | | window.map.addLayer(this.marker) |
| | | this.layersGroupArrList.push(this.marker) |
| | | window.map.off('click') |
| | | }) |
| | | }, |
| | | // 通过数据定位 |
| | | dataPoints () { |
| | | const as = [this.LongLatPos.latPos, this.LongLatPos.longPos] |
| | | // console.log(as) |
| | | window.map.setView(as, 17) |
| | | pulseEffect(as) |
| | | this.marker = window.L.marker(as, { |
| | | icon: window.L.icon({ |
| | | iconUrl: iconUrl, |
| | | iconSize: [30, 30], |
| | | iconAnchor: [15, 15] |
| | | // this.lonlatpos.latPos = '' |
| | | // this.lonlatpos.longPos = '' |
| | | if (this.lonlatpos.latPos !== '' && this.lonlatpos.longPos !== '') { |
| | | const as = [this.lonlatpos.latPos, this.lonlatpos.longPos] |
| | | window.map.setView(as, 17) |
| | | pulseEffect(as) |
| | | this.marker = window.L.marker(as, { |
| | | icon: window.L.icon({ |
| | | iconUrl: iconUrl, |
| | | iconSize: [26, 40], |
| | | iconAnchor: [13, 20] |
| | | }) |
| | | }) |
| | | }) |
| | | window.map.addLayer(this.marker) |
| | | this.LongLatPos.latPos = '' |
| | | this.LongLatPos.longPos = '' |
| | | window.map.addLayer(this.marker) |
| | | this.layersGroupArrList.push(this.marker) |
| | | } else { |
| | | this.$message('请输入识取经纬度') |
| | | } |
| | | }, |
| | | // 点击确认按钮事件 |
| | | confirm () { |
| | | for (let i = 0; i < this.layersGroupArrList.length; i++) { |
| | | window.map.removeLayer(this.layersGroupArrList[i]) |
| | | } |
| | | window.mapManager.clearHighlight() |
| | | window.map.removeLayer(this.marker) |
| | | // window.map.removeLayer(this.marker) |
| | | eventBus.$emit('location-setChange', true) |
| | | this.LongLatPos.longPos = '' |
| | | this.LongLatPos.latPos = '' |
| | | this.lonlatpos.longPos = '' |
| | | this.lonlatpos.latPos = '' |
| | | } |
| | | } |
| | | } |