|
|
|
@ -1,4 +1,4 @@
|
|
|
|
|
import { Component, OnInit, Inject ,ViewChild} from '@angular/core'; |
|
|
|
|
import { Component, OnInit, Inject ,ViewChild, Renderer2, ElementRef} from '@angular/core'; |
|
|
|
|
import { MatTreeFlatDataSource, MatTreeFlattener } from '@angular/material/tree'; |
|
|
|
|
import { FlatTreeControl } from '@angular/cdk/tree'; |
|
|
|
|
import { HttpClient,HttpHeaders, HttpEventType } from '@angular/common/http'; |
|
|
|
@ -84,74 +84,176 @@ export class BasicinfoComponent implements OnInit {
|
|
|
|
|
buildingCustomData:any //存储当前建筑的自定义信息
|
|
|
|
|
allunittype: any //所有单位类型
|
|
|
|
|
allorganizing:any = [] //所有组织机构
|
|
|
|
|
constructor(private http: HttpClient, private tree: TreeService, private sanitizer: DomSanitizer, public dialog: MatDialog,public snackBar: MatSnackBar) { } |
|
|
|
|
constructor(private elementRef: ElementRef,public renderer2: Renderer2,private http: HttpClient, private tree: TreeService, private sanitizer: DomSanitizer, public dialog: MatDialog,public snackBar: MatSnackBar) { } |
|
|
|
|
|
|
|
|
|
isMapLabel:boolean |
|
|
|
|
|
|
|
|
|
ngOnInit(): void { |
|
|
|
|
this.getallunittype() |
|
|
|
|
this.getorganization() |
|
|
|
|
// this.getunitinfo()
|
|
|
|
|
this.getunitallbuilding() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
isMapLabel:boolean |
|
|
|
|
//地图标注位置
|
|
|
|
|
marker:any//单位点标记
|
|
|
|
|
markerPosition:any = {x: 0, y: 0}//单位坐标
|
|
|
|
|
map:any //地图实例
|
|
|
|
|
isGisTopBox:boolean = false//点击位置按钮
|
|
|
|
|
oldPositionMarker:any //旧位置marker实例
|
|
|
|
|
newPositionMarker:any //新位置marker实例
|
|
|
|
|
|
|
|
|
|
newPositionMarkerContent:any =
|
|
|
|
|
'<div class="custom-content-marker">' + |
|
|
|
|
' <img src="/assets/images/newposition.png">' + |
|
|
|
|
'</div>' |
|
|
|
|
newPositionMarkerContentBtn:any =
|
|
|
|
|
'<div class="custom-content-marker">' + |
|
|
|
|
' <img src="/assets/images/newposition.png">' + |
|
|
|
|
' <div class="btnbox"><img id="setPositionOk" src="/assets/images/ok.png"><span>|</span><img id="setPositionClose" src="/assets/images/close.png"></div>' + |
|
|
|
|
'</div>' |
|
|
|
|
oldPositionMarkerContent:any =
|
|
|
|
|
'<div class="custom-content-marker">' + |
|
|
|
|
' <img src="/assets/images/oldposition.png">' + |
|
|
|
|
'</div>' |
|
|
|
|
//初始化地图
|
|
|
|
|
labelGis(){ |
|
|
|
|
var map = new AMap.Map('container', { |
|
|
|
|
this.map = new AMap.Map('container', { |
|
|
|
|
zoom:12 |
|
|
|
|
}) |
|
|
|
|
if(this.isMapLabel){ |
|
|
|
|
this.marker = new AMap.Marker({ |
|
|
|
|
position: [this.unitinfo.location.x,this.unitinfo.location.y], // 经纬度对象,也可以是经纬度构成的一维数组[116.39, 39.9]
|
|
|
|
|
draggable: true |
|
|
|
|
}); |
|
|
|
|
map.add(this.marker); |
|
|
|
|
map.setFitView(); |
|
|
|
|
this.marker.on('dragging', (e)=>{ |
|
|
|
|
this.markerPosition = {x: e.lnglat.lng, y: e.lnglat.lat} |
|
|
|
|
this.map.on('complete', () => { |
|
|
|
|
this.isGisTopBox = true |
|
|
|
|
}); |
|
|
|
|
if(this.isMapLabel){//如果已经标注单位坐标
|
|
|
|
|
console.log('已标注单位位置') |
|
|
|
|
this.map.setCenter([this.unitinfo.location.x,this.unitinfo.location.y]); |
|
|
|
|
this.oldPositionMarker = new AMap.Marker({ |
|
|
|
|
position: [this.unitinfo.location.x,this.unitinfo.location.y], |
|
|
|
|
content: this.newPositionMarkerContent, |
|
|
|
|
offset: new AMap.Pixel(-15, -18) |
|
|
|
|
}) |
|
|
|
|
// 将 markers 添加到地图
|
|
|
|
|
this.map.add(this.oldPositionMarker); |
|
|
|
|
}else{ |
|
|
|
|
console.log('未标注单位位置') |
|
|
|
|
this.map.setCity('上海市'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//输入提示
|
|
|
|
|
var autoOptions = { |
|
|
|
|
input: "tipinput" |
|
|
|
|
}; |
|
|
|
|
AMap.plugin(['AMap.PlaceSearch','AMap.AutoComplete'], () =>{ |
|
|
|
|
var auto = new AMap.AutoComplete(autoOptions); |
|
|
|
|
var placeSearch = new AMap.PlaceSearch({ |
|
|
|
|
// map: map
|
|
|
|
|
// pageSize: 5, // 单页显示结果条数
|
|
|
|
|
// pageIndex: 1 // 页码
|
|
|
|
|
}); //构造地点查询类
|
|
|
|
|
auto.on("select", (e)=>{ |
|
|
|
|
placeSearch.search(e.poi.name, (status, result) => { |
|
|
|
|
if(this.marker){ |
|
|
|
|
map.remove(this.marker); |
|
|
|
|
} |
|
|
|
|
this.isMapLabel = true |
|
|
|
|
// 查询成功时,result即对应匹配的POI信息
|
|
|
|
|
var poi = result.poiList.pois[0]; |
|
|
|
|
this.markerPosition = {x: poi.location.lng, y: poi.location.lat} |
|
|
|
|
this.marker = new AMap.Marker({ |
|
|
|
|
position: poi.location, // 经纬度对象,也可以是经纬度构成的一维数组[116.39, 39.9]
|
|
|
|
|
title: poi.name, |
|
|
|
|
draggable: true |
|
|
|
|
}); |
|
|
|
|
map.add(this.marker); |
|
|
|
|
map.setFitView(); |
|
|
|
|
this.marker.on('dragend', (e)=>{ |
|
|
|
|
this.markerPosition = {x: e.lnglat.lng, y: e.lnglat.lat} |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
//点击位置按钮
|
|
|
|
|
setPosition(){ |
|
|
|
|
this.isGisTopBox = false |
|
|
|
|
if(this.isMapLabel){//如果已经标注单位坐标
|
|
|
|
|
console.log('已标注单位位置') |
|
|
|
|
|
|
|
|
|
if(this.oldPositionMarker){ |
|
|
|
|
this.oldPositionMarker.setContent(this.oldPositionMarkerContent) |
|
|
|
|
} |
|
|
|
|
if(this.newPositionMarker){ |
|
|
|
|
this.newPositionMarker.setContent(this.oldPositionMarkerContent) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
this.newPositionMarker = new AMap.Marker({ |
|
|
|
|
draggable: true, |
|
|
|
|
position: [this.markerPosition.x,this.markerPosition.y], |
|
|
|
|
content: this.newPositionMarkerContentBtn, |
|
|
|
|
offset: new AMap.Pixel(-15, -18) |
|
|
|
|
}); |
|
|
|
|
this.map.add(this.newPositionMarker); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let markerPosition
|
|
|
|
|
if(this.markerPosition.x && this.markerPosition.x != 0){ |
|
|
|
|
markerPosition = {x: this.markerPosition.x,y: this.markerPosition.y} |
|
|
|
|
}else{ |
|
|
|
|
markerPosition = {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.renderer2.listen(this.elementRef.nativeElement.querySelector('#setPositionOk'),'click',(event)=>{
|
|
|
|
|
this.map.clearMap(); |
|
|
|
|
this.isGisTopBox = true |
|
|
|
|
this.newPositionMarker = new AMap.Marker({ |
|
|
|
|
position: [markerPosition.x,markerPosition.y], |
|
|
|
|
content: this.newPositionMarkerContent, |
|
|
|
|
offset: new AMap.Pixel(-15, -18) |
|
|
|
|
}); |
|
|
|
|
this.markerPosition = markerPosition |
|
|
|
|
this.map.add(this.newPositionMarker); |
|
|
|
|
}) |
|
|
|
|
//点击取消
|
|
|
|
|
this.renderer2.listen(this.elementRef.nativeElement.querySelector('#setPositionClose'),'click',(event)=>{
|
|
|
|
|
this.isGisTopBox = true |
|
|
|
|
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.add(this.newPositionMarker);
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
}else{ |
|
|
|
|
console.log('未标注单位位置') |
|
|
|
|
if(this.newPositionMarker){ |
|
|
|
|
this.newPositionMarker.setContent(this.oldPositionMarkerContent) |
|
|
|
|
} |
|
|
|
|
let center |
|
|
|
|
if(this.markerPosition.x && this.markerPosition.x != 0){ |
|
|
|
|
center = [this.markerPosition.x,this.markerPosition.y] |
|
|
|
|
}else{ |
|
|
|
|
center = this.map.getCenter(); //获取当前地图中心位置
|
|
|
|
|
this.map.setCenter(center); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
this.newPositionMarker = new AMap.Marker({ |
|
|
|
|
draggable: true, |
|
|
|
|
position: center, |
|
|
|
|
content: this.newPositionMarkerContentBtn, |
|
|
|
|
offset: new AMap.Pixel(-15, -18) |
|
|
|
|
}); |
|
|
|
|
this.map.add(this.newPositionMarker); |
|
|
|
|
|
|
|
|
|
let markerPosition
|
|
|
|
|
if(this.markerPosition.x && this.markerPosition.x != 0){ |
|
|
|
|
markerPosition = {x: this.markerPosition.x,y: this.markerPosition.y} |
|
|
|
|
}else{ |
|
|
|
|
markerPosition = {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.renderer2.listen(this.elementRef.nativeElement.querySelector('#setPositionOk'),'click',(event)=>{
|
|
|
|
|
this.isGisTopBox = true |
|
|
|
|
this.markerPosition = markerPosition |
|
|
|
|
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.add(this.newPositionMarker); |
|
|
|
|
}) |
|
|
|
|
this.renderer2.listen(this.elementRef.nativeElement.querySelector('#setPositionClose'),'click',(event)=>{
|
|
|
|
|
this.map.clearMap(); |
|
|
|
|
this.isGisTopBox = true |
|
|
|
|
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.add(this.newPositionMarker); |
|
|
|
|
} |
|
|
|
|
})//取消
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//获得所有单位类型
|
|
|
|
|
getallunittype() { |
|
|
|
|
this.http.get("/api/BuildingTypes/Simple").subscribe(data => { |
|
|
|
|