diff --git a/src/app/ui/basicinfo/basicinfo.component.html b/src/app/ui/basicinfo/basicinfo.component.html
index 1d678ec..5e0206a 100644
--- a/src/app/ui/basicinfo/basicinfo.component.html
+++ b/src/app/ui/basicinfo/basicinfo.component.html
@@ -144,6 +144,15 @@
place 位置
+
diff --git a/src/app/ui/basicinfo/basicinfo.component.scss b/src/app/ui/basicinfo/basicinfo.component.scss
index bff8fa3..a2e7969 100644
--- a/src/app/ui/basicinfo/basicinfo.component.scss
+++ b/src/app/ui/basicinfo/basicinfo.component.scss
@@ -87,7 +87,6 @@
}
.gistopbox{
position: absolute;
-
box-shadow: 0px 3px 6px rgba(0, 0, 0, 0.16);
border-radius: 4px;
left: 5%;
@@ -126,9 +125,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/ui/basicinfo/basicinfo.component.ts b/src/app/ui/basicinfo/basicinfo.component.ts
index 412ac0b..aee0f92 100644
--- a/src/app/ui/basicinfo/basicinfo.component.ts
+++ b/src/app/ui/basicinfo/basicinfo.component.ts
@@ -98,6 +98,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实例
@@ -114,6 +115,23 @@ export class BasicinfoComponent implements OnInit {
'' +
'

' +
'
'
+ //初始化地图
+ searchTitle:any//搜索内容
+ placeSearch:any//地址搜索类
+ search(){
+ this.placeSearch.search(this.searchTitle, (status, result) => {
+ // 搜索成功时,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]); //设置地图中心点
+ }else{
+ alert('查询不到输入地址信息')
+ }
+
+ })
+
+ }
//初始化地图
labelGis(){
this.map = new AMap.Map('container', {
@@ -122,24 +140,43 @@ export class BasicinfoComponent implements OnInit {
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);
+ 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]);
+ 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('上海市');
+ }
}
+ markerPosition2
//点击位置按钮
setPosition(){
this.isGisTopBox = false
+ this.isGisTopBoxTwo = true
if(this.isMapLabel){//如果已经标注单位坐标
console.log('已标注单位位置')
@@ -159,36 +196,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);
})
@@ -213,19 +252,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],
@@ -237,16 +277,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);
}
})//取消
}
+