Commit 76e63767 authored by 耿迪迪's avatar 耿迪迪

地图搜索 gengdidi

parent 56eca651
...@@ -124,7 +124,7 @@ ...@@ -124,7 +124,7 @@
this.map.remove(this.obj); this.map.remove(this.obj);
this.form.deviceId = response.data; this.form.deviceId = response.data;
this.gaoMap.addMarker(this.gaoMap.deviceType,this.form); this.gaoMap.addMarker(this.gaoMap.deviceType,this.form);
this.gaoMap.placeSearch.clear(); //this.gaoMap.placeSearch.clear();
this.gaoMap.closeAddMarker(); this.gaoMap.closeAddMarker();
this.msgSuccess("新增成功"); this.msgSuccess("新增成功");
}else{ }else{
......
...@@ -124,7 +124,7 @@ ...@@ -124,7 +124,7 @@
this.map.remove(this.obj); this.map.remove(this.obj);
this.form.deviceId = response.data; this.form.deviceId = response.data;
this.gaoMap.addMarker(this.gaoMap.deviceType,this.form); this.gaoMap.addMarker(this.gaoMap.deviceType,this.form);
this.gaoMap.placeSearch.clear(); //this.gaoMap.placeSearch.clear();
this.gaoMap.closeAddMarker(); this.gaoMap.closeAddMarker();
this.msgSuccess("新增成功"); this.msgSuccess("新增成功");
}else{ }else{
......
...@@ -126,7 +126,7 @@ ...@@ -126,7 +126,7 @@
this.form.deviceId = response.data; this.form.deviceId = response.data;
console.log(this.gaoMap,"addgaoMap") console.log(this.gaoMap,"addgaoMap")
this.gaoMap.addMarker(this.gaoMap.deviceType,this.form); this.gaoMap.addMarker(this.gaoMap.deviceType,this.form);
this.gaoMap.placeSearch.clear(); //this.gaoMap.placeSearch.clear();
this.gaoMap.closeAddMarker(); this.gaoMap.closeAddMarker();
this.msgSuccess("新增成功"); this.msgSuccess("新增成功");
}else{ }else{
......
...@@ -124,7 +124,7 @@ ...@@ -124,7 +124,7 @@
this.map.remove(this.obj); this.map.remove(this.obj);
this.form.deviceId = response.data; this.form.deviceId = response.data;
this.gaoMap.addMarker(this.gaoMap.deviceType,this.form); this.gaoMap.addMarker(this.gaoMap.deviceType,this.form);
this.gaoMap.placeSearch.clear(); //this.gaoMap.placeSearch.clear();
this.gaoMap.closeAddMarker(); this.gaoMap.closeAddMarker();
this.msgSuccess("新增成功"); this.msgSuccess("新增成功");
}else{ }else{
......
...@@ -802,29 +802,18 @@ class gaodeMap { ...@@ -802,29 +802,18 @@ class gaodeMap {
var autoOptions = { var autoOptions = {
input: inputId input: inputId
}; };
var auto = new AMap.AutoComplete(autoOptions); let auto = new AMap.AutoComplete(autoOptions);
that.placeSearch = new AMap.PlaceSearch({ that.placeSearch = new AMap.PlaceSearch({
map: map map: map
}); });
//构造地点查询类 //构造地点查询类
auto.on("select", function(e) { auto.on("select", function(e) {
console.log(e, "eeeeee========"); that.searchSelectAdcode = e.poi.adcode;
that.placeSearch.clear(); that.searchSelectName = e.poi.name;
that.placeSearch.setCity(e.poi.adcode);
that.placeSearch.search(e.poi.name); //关键字查询查询
}); });
}); });
} }
searchKeyWord(keyWord) {
AMap.plugin(["AMap.AutoComplete"], function() {
var placeSearch = new AMap.PlaceSearch({
map: map
});
placeSearch.search(keyWord); //关键字查询查询
});
}
closeAddMarker(){ closeAddMarker(){
this.mouseTool.close(); this.mouseTool.close();
map.remove(this.markerOverlays); map.remove(this.markerOverlays);
......
<template> <template>
<div> <div>
<div style="width: 100vw; height: 100vh" id="container"></div> <div style="width: 100vw; height: 100vh" id="container"></div>
<!-- <div class="input-card" style='width: 24rem;'>
<div class="input-item">
<input type="radio" name='func' value='marker'><span class="input-text">画点</span>
<input type="radio" name='func' value='polyline'><span class="input-text">画折线</span>
<input type="radio" name='func' value='polygon'><span class="input-text" style='width:5rem;'>画多边形</span>
</div>
<div class="input-item">
<input type="radio" name='func' value='rectangle'><span class="input-text">画矩形</span>
<input type="radio" name='func' value='circle'><span class="input-text">画圆</span>
</div>
<div class="input-item">
<input id="clear" type="button" class="btn" value="清除" />
<input id="close" type="button" class="btn" value="关闭绘图" />
</div>
</div>-->
<div class="btn-wrapper"> <div class="btn-wrapper">
<!-- <el-button type="primary" class="el-btn" icon="el-icon-search" @click="addDevice"
>
新增
</el-button>
<el-button type="primary" class="el-btn" @click="editDevice"
>编辑
</el-button>
<el-button type="primary" class="el-btn" @click="deleteDevice"
>删除
</el-button> -->
<div class="myBtn"> <div class="myBtn">
<div <div
class="el-btn" class="el-btn"
...@@ -88,7 +63,6 @@ ...@@ -88,7 +63,6 @@
</div> </div>
</div> </div>
<!-- <el-select-->
<el-input <el-input
v-model="keyWord" v-model="keyWord"
placeholder="点击输入" placeholder="点击输入"
...@@ -96,43 +70,17 @@ ...@@ -96,43 +70,17 @@
class="search-input" class="search-input"
/> />
<el-button <el-button
type="red"
icon="el-icon-search" icon="el-icon-search"
class="search-but" class="search-but"
@click="search()" @click="search()"
>搜索</el-button >搜索</el-button
> >
<!-- <el-button
type="primary"
style="position: absolute; top: 100px; left: 75%"
@click="addDevice"
>新增</el-button
>
<el-button
type="primary"
style="position: absolute; top: 100px; left: 82%"
@click="editDevice"
>编辑</el-button
>
<el-button <el-button
type="primary" icon="el-icon-refresh"
style="position: absolute; top: 100px; left: 90%" class="refresh-but"
@click="deleteDevice" @click="refreshMap()"
>删除</el-button >重置</el-button
> >
<el-select
v-model="value"
placeholder="请选择..."
@change="selectDeviceType"
style="position: absolute; top: 150px; left: 75%"
v-if="deviceType"
>
<el-option label="管道" value="1"></el-option>
<el-option label="调压箱" value="2"></el-option>
<el-option label="阀门井" value="3"></el-option>
<el-option label="流量计" value="4"></el-option>
<el-option label="值班人员" value="5"></el-option>
</el-select> -->
<div class="leftBar-wrapper"> <div class="leftBar-wrapper">
<div <div
...@@ -164,23 +112,6 @@ export default { ...@@ -164,23 +112,6 @@ export default {
deviceType: false, deviceType: false,
value: "", value: "",
operateType: "", operateType: "",
queryParams: {
enterpriseId: null,
pipeId: null,
deviceName: null,
deviceAddr: null,
deviceModel: null,
deviceType: null,
longitude: null,
latitude: null,
iotNo: null,
iconUrl: null,
linkman: null,
phone: null,
installationTime: null,
inspectionTime: null,
remarks: null,
},
radio1: "", radio1: "",
// 1新建,2编辑,3删除,点按钮变色 // 1新建,2编辑,3删除,点按钮变色
targetNum: 0, targetNum: 0,
...@@ -222,8 +153,11 @@ export default { ...@@ -222,8 +153,11 @@ export default {
}; };
}, },
mounted() { mounted() {
this.initMap();
},
methods: {
initMap(){
let gaoMap = new gaodeMap("石家庄"); let gaoMap = new gaodeMap("石家庄");
this.gaoMap = gaoMap; this.gaoMap = gaoMap;
window.addEventListener("click", this.barClose); window.addEventListener("click", this.barClose);
gaoMap.addMouseTool(); gaoMap.addMouseTool();
...@@ -231,7 +165,6 @@ export default { ...@@ -231,7 +165,6 @@ export default {
this.getDeviceInfo(); this.getDeviceInfo();
this.getPipeList(); this.getPipeList();
}, },
methods: {
// 左边的Bar修改值 // 左边的Bar修改值
leftBarChange(item) { leftBarChange(item) {
// this.leftBarNum= this.leftBarNum != item.value ? item.value:0; // this.leftBarNum= this.leftBarNum != item.value ? item.value:0;
...@@ -294,7 +227,7 @@ export default { ...@@ -294,7 +227,7 @@ export default {
this.deviceType = false; this.deviceType = false;
this.gaoMap.mapOperateType = "edit"; this.gaoMap.mapOperateType = "edit";
this.gaoMap.addMarkerDragg(); this.gaoMap.addMarkerDragg();
this.gaoMap.placeSearch.clear(); // this.gaoMap.placeSearch.clear();
this.gaoMap.closeAddMarker(); this.gaoMap.closeAddMarker();
}, },
deleteDevice() { deleteDevice() {
...@@ -306,7 +239,7 @@ export default { ...@@ -306,7 +239,7 @@ export default {
this.deviceType = false; this.deviceType = false;
this.gaoMap.mapOperateType = "delete"; this.gaoMap.mapOperateType = "delete";
this.gaoMap.removeMarkerDragg(); this.gaoMap.removeMarkerDragg();
this.gaoMap.placeSearch.clear(); //this.gaoMap.placeSearch.clear();
this.gaoMap.closeAddMarker(); this.gaoMap.closeAddMarker();
}, },
selectDeviceType(val) { selectDeviceType(val) {
...@@ -321,9 +254,9 @@ export default { ...@@ -321,9 +254,9 @@ export default {
this.gaoMap.createNewLine(); this.gaoMap.createNewLine();
} }
}, },
getDeviceInfo() { getDeviceInfo(queryParams) {
this.loading = true; this.loading = true;
getAllDeviceInfo(this.queryParams).then((response) => { getAllDeviceInfo(queryParams).then((response) => {
if (response.code == 200) { if (response.code == 200) {
for (var i = 0; i < response.data.length; i++) { for (var i = 0; i < response.data.length; i++) {
if ("1" == response.data[i].deviceType) { if ("1" == response.data[i].deviceType) {
...@@ -346,8 +279,8 @@ export default { ...@@ -346,8 +279,8 @@ export default {
this.loading = false; this.loading = false;
}); });
}, },
getPipeList() { getPipeList(queryParams) {
pipeAllInfoList().then((res) => { pipeAllInfoList(queryParams).then((res) => {
console.log("管道", res); console.log("管道", res);
if (res.code == 200) { if (res.code == 200) {
this.gaoMap.addPolyline(res.data); this.gaoMap.addPolyline(res.data);
...@@ -355,8 +288,23 @@ export default { ...@@ -355,8 +288,23 @@ export default {
}); });
}, },
search() { search() {
map.clearMap();
this.gaoMap.placeSearch.clear(); this.gaoMap.placeSearch.clear();
if(!(!this.gaoMap.searchSelectAdcode && !this.gaoMap.searchSelectName)){
this.gaoMap.placeSearch.setCity(this.gaoMap.searchSelectAdcode);
this.gaoMap.placeSearch.search(this.gaoMap.searchSelectName);
this.getDeviceInfo({"deviceName": this.gaoMap.searchSelectName});
this.gaoMap.polyLines = [];
this.getPipeList({"pipeName": this.gaoMap.searchSelectName});
this.gaoMap.searchSelectAdcode = undefined;
this.gaoMap.searchSelectName = undefined;
}else{
this.gaoMap.placeSearch.search(this.keyWord); this.gaoMap.placeSearch.search(this.keyWord);
this.getDeviceInfo({"deviceName": this.keyWord});
this.gaoMap.polyLines = [];
this.getPipeList({"pipeName": this.keyWord});
}
}, },
// 新建下拉列表关闭 // 新建下拉列表关闭
barClose() { barClose() {
...@@ -371,6 +319,10 @@ export default { ...@@ -371,6 +319,10 @@ export default {
this.gaoMap.lineFlag = false; this.gaoMap.lineFlag = false;
this.gaoMap.createNewLine(); this.gaoMap.createNewLine();
}, },
refreshMap(){
map.clearMap();
this.initMap();
}
}, },
beforeDestroy() { beforeDestroy() {
...@@ -386,7 +338,7 @@ export default { ...@@ -386,7 +338,7 @@ export default {
.leftBar-wrapper { .leftBar-wrapper {
position: fixed; position: fixed;
left: 100px; left: 100px;
top: 100px; top: 150px;
.box { .box {
width: 180px; width: 180px;
height: 48px; height: 48px;
...@@ -601,5 +553,14 @@ input[type="radio"] { ...@@ -601,5 +553,14 @@ input[type="radio"] {
color: white; color: white;
background-color: #053b6a; background-color: #053b6a;
} }
.refresh-but{
position: absolute;
top: 100px;
left: 25%;
width: 85px;
color: white;
background-color: #053b6a;
}
</style> </style>
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