diff --git a/src/app/key-unit/basicinfo/basicinfo.component.html b/src/app/key-unit/basicinfo/basicinfo.component.html
index 0927268..5e9f5f9 100644
--- a/src/app/key-unit/basicinfo/basicinfo.component.html
+++ b/src/app/key-unit/basicinfo/basicinfo.component.html
@@ -144,6 +144,15 @@
place 位置
+
diff --git a/src/app/key-unit/basicinfo/basicinfo.component.scss b/src/app/key-unit/basicinfo/basicinfo.component.scss
index cb6cf21..7ffed03 100644
--- a/src/app/key-unit/basicinfo/basicinfo.component.scss
+++ b/src/app/key-unit/basicinfo/basicinfo.component.scss
@@ -86,7 +86,6 @@
}
.gistopbox{
position: absolute;
-
box-shadow: 0px 3px 6px rgba(0, 0, 0, 0.16);
border-radius: 4px;
left: 5%;
@@ -125,9 +124,31 @@
align-items: center;
justify-content: center;
}
-
+ .inputBox{
+ width: 63%;
+ display: flex;
+ align-items: center;
+ .positionInput{
+ border: 0;
+ border-radius: 6px;
+ width: 90%;
+ height: 34px;
+ background: #F2F2F2;
+ margin-left: 8px;
+ box-sizing: border-box;
+ padding-left: 10px;
+ }
+ }
}
+ .hidden{
+ opacity: 0;
+ z-index: -1;
+ }
+ .show{
+ opacity: 1;
+ z-index: 1;
+ }
}
}
diff --git a/src/app/key-unit/basicinfo/basicinfo.component.ts b/src/app/key-unit/basicinfo/basicinfo.component.ts
index 1fd8443..550178f 100644
--- a/src/app/key-unit/basicinfo/basicinfo.component.ts
+++ b/src/app/key-unit/basicinfo/basicinfo.component.ts
@@ -104,6 +104,7 @@ export class BasicinfoComponent implements OnInit {
markerPosition:any = {x: 0, y: 0}//单位坐标
map:any //地图实例
isGisTopBox:boolean = false//点击位置按钮
+ isGisTopBoxTwo:boolean = false//点击位置按钮
oldPositionMarker:any //旧位置marker实例
newPositionMarker:any //新位置marker实例
@@ -121,13 +122,48 @@ export class BasicinfoComponent implements OnInit {
'
' +
''
//初始化地图
+ searchTitle:any//搜索内容
+ placeSearch:any//地址搜索类
+ search(){
+ this.placeSearch.search(this.searchTitle, (status, result) => {
+ // 搜索成功时,result即是对应的匹配数据
+ console.log(146,this.searchTitle)
+ console.log(147,result)
+ if(result.info == "OK"){
+ this.newPositionMarker.setPosition([result.poiList.pois[0].location.lng,result.poiList.pois[0].location.lat])
+ this.markerPosition2 = {x: result.poiList.pois[0].location.lng, y: result.poiList.pois[0].location.lat}
+ this.map.setCenter([result.poiList.pois[0].location.lng,result.poiList.pois[0].location.lat]); //设置地图中心点
+ }
+
+ })
+
+ }
labelGis(){
this.map = new AMap.Map('container', {
zoom:12
})
+
+
this.map.on('complete', () => {
this.isGisTopBox = true
});
+ //输入提示
+ var autoOptions = {
+ input: "tipinput"
+ };
+ AMap.plugin(['AMap.PlaceSearch','AMap.AutoComplete'], ()=>{
+ var auto = new AMap.AutoComplete(autoOptions);
+ this.placeSearch = new AMap.PlaceSearch(); //构造地点查询类
+ auto.on("select", (e)=>{
+ console.log(e)
+ console.log( this.newPositionMarker)
+ this.newPositionMarker.setPosition([e.poi.location.lng,e.poi.location.lat])
+ this.markerPosition2 = {x: e.poi.location.lng, y: e.poi.location.lat}
+ this.map.setCenter([e.poi.location.lng,e.poi.location.lat]); //设置地图中心点
+ });//注册监听,当选中某条记录时会触发
+
+ });
+
if(this.isMapLabel){//如果已经标注单位坐标
console.log('已标注单位位置')
this.map.setCenter([this.unitinfo.location.x,this.unitinfo.location.y]);
@@ -143,9 +179,15 @@ export class BasicinfoComponent implements OnInit {
this.map.setCity('上海市');
}
}
+
+
+ markerPosition2
//点击位置按钮
setPosition(){
+
+
this.isGisTopBox = false
+ this.isGisTopBoxTwo = true
if(this.isMapLabel){//如果已经标注单位坐标
console.log('已标注单位位置')
@@ -165,36 +207,38 @@ export class BasicinfoComponent implements OnInit {
this.map.add(this.newPositionMarker);
- let markerPosition
if(this.markerPosition.x && this.markerPosition.x != 0){
- markerPosition = {x: this.markerPosition.x,y: this.markerPosition.y}
+ this.markerPosition2 = {x: this.markerPosition.x,y: this.markerPosition.y}
}else{
- markerPosition = {x: this.map.getCenter().lng,y: this.map.getCenter().lat} //获取当前地图中心位置
+ this.markerPosition2 = {x: this.map.getCenter().lng,y: this.map.getCenter().lat} //获取当前地图中心位置
}
this.newPositionMarker.on('dragend', (e)=>{
- markerPosition = {x: e.lnglat.lng, y: e.lnglat.lat}
+ this.markerPosition2 = {x: e.lnglat.lng, y: e.lnglat.lat}
})
//点击确定
this.renderer2.listen(this.elementRef.nativeElement.querySelector('#setPositionOk'),'click',(event)=>{
this.map.clearMap();
this.isGisTopBox = true
+ this.isGisTopBoxTwo = false
this.newPositionMarker = new AMap.Marker({
- position: [markerPosition.x,markerPosition.y],
+ position: [this.markerPosition2.x,this.markerPosition2.y],
content: this.newPositionMarkerContent,
offset: new AMap.Pixel(-15, -18)
});
- this.markerPosition = markerPosition
+ this.markerPosition = this.markerPosition2
this.map.add(this.newPositionMarker);
})
//点击取消
this.renderer2.listen(this.elementRef.nativeElement.querySelector('#setPositionClose'),'click',(event)=>{
this.isGisTopBox = true
+ this.isGisTopBoxTwo = false
this.map.clearMap();
this.newPositionMarker = new AMap.Marker({
position: [this.markerPosition.x,this.markerPosition.y],
content: this.newPositionMarkerContent,
offset: new AMap.Pixel(-15, -18)
});
+ this.map.setCenter([this.markerPosition.x,this.markerPosition.y]); //设置地图中心点
this.map.add(this.newPositionMarker);
})
@@ -219,19 +263,20 @@ export class BasicinfoComponent implements OnInit {
});
this.map.add(this.newPositionMarker);
- let markerPosition
+ // let markerPosition
if(this.markerPosition.x && this.markerPosition.x != 0){
- markerPosition = {x: this.markerPosition.x,y: this.markerPosition.y}
+ this.markerPosition2 = {x: this.markerPosition.x,y: this.markerPosition.y}
}else{
- markerPosition = {x: this.map.getCenter().lng,y: this.map.getCenter().lat} //获取当前地图中心位置
+ this.markerPosition2 = {x: this.map.getCenter().lng,y: this.map.getCenter().lat} //获取当前地图中心位置
}
this.newPositionMarker.on('dragend', (e)=>{
- markerPosition = {x: e.lnglat.lng, y: e.lnglat.lat}
+ this.markerPosition2 = {x: e.lnglat.lng, y: e.lnglat.lat}
})
//点击确定
this.renderer2.listen(this.elementRef.nativeElement.querySelector('#setPositionOk'),'click',(event)=>{
this.isGisTopBox = true
- this.markerPosition = markerPosition
+ this.isGisTopBoxTwo = false
+ this.markerPosition = this.markerPosition2
this.map.clearMap();
this.newPositionMarker = new AMap.Marker({
position: [this.markerPosition.x,this.markerPosition.y],
@@ -243,19 +288,19 @@ export class BasicinfoComponent implements OnInit {
this.renderer2.listen(this.elementRef.nativeElement.querySelector('#setPositionClose'),'click',(event)=>{
this.map.clearMap();
this.isGisTopBox = true
+ this.isGisTopBoxTwo = false
if(this.markerPosition.x && this.markerPosition.x != 0){//说明之前标过点
this.newPositionMarker = new AMap.Marker({
position: [this.markerPosition.x,this.markerPosition.y],
content: this.newPositionMarkerContent,
offset: new AMap.Pixel(-15, -18)
});
+ this.map.setCenter([this.markerPosition.x,this.markerPosition.y]); //设置地图中心点
this.map.add(this.newPositionMarker);
}
})//取消
}
-
-
}
//获得所有单位类型
@@ -278,7 +323,9 @@ export class BasicinfoComponent implements OnInit {
}else{//未标注
_this.isMapLabel = false
}
+
this.labelGis()
+
})
}
)