|
|
|
@ -22,6 +22,8 @@ import { ActivatedRoute } from '@angular/router';
|
|
|
|
|
import { TabbarAndScoreService } from 'src/app/http-interceptors/tabbar-and-score.service'; |
|
|
|
|
declare var AMap: any; |
|
|
|
|
import Viewer from 'viewerjs'; |
|
|
|
|
import { IMap, IMarker, IPlaceSearch } from '@src/modules/map/declare/map'; |
|
|
|
|
import { MapFactory } from '@src/modules/map/declare/factory'; |
|
|
|
|
@Component({ |
|
|
|
|
selector: 'app-basicinfo', |
|
|
|
|
templateUrl: './basicinfo.component.html', |
|
|
|
@ -129,11 +131,11 @@ export class BasicinfoComponent implements OnInit {
|
|
|
|
|
isMapLabel: boolean |
|
|
|
|
//地图标注位置
|
|
|
|
|
markerPosition: any = { x: 0, y: 0 }//单位坐标
|
|
|
|
|
map: any //地图实例
|
|
|
|
|
map: IMap //地图实例
|
|
|
|
|
isGisTopBox: boolean = false//点击位置按钮
|
|
|
|
|
isGisTopBoxTwo: boolean = false//点击位置按钮
|
|
|
|
|
oldPositionMarker: any //旧位置marker实例
|
|
|
|
|
newPositionMarker: any //新位置marker实例
|
|
|
|
|
oldPositionMarker: IMarker //旧位置marker实例
|
|
|
|
|
newPositionMarker: IMarker //新位置marker实例
|
|
|
|
|
|
|
|
|
|
newPositionMarkerContent: any = |
|
|
|
|
'<div class="custom-content-marker">' + |
|
|
|
@ -152,7 +154,7 @@ export class BasicinfoComponent implements OnInit {
|
|
|
|
|
'</div>' |
|
|
|
|
//初始化地图
|
|
|
|
|
searchTitle: any//搜索内容
|
|
|
|
|
placeSearch: any//地址搜索类
|
|
|
|
|
placeSearch: IPlaceSearch//地址搜索类
|
|
|
|
|
search() { |
|
|
|
|
this.placeSearch.search(this.searchTitle, (status, result) => { |
|
|
|
|
// 搜索成功时,result即是对应的匹配数据
|
|
|
|
@ -169,7 +171,7 @@ export class BasicinfoComponent implements OnInit {
|
|
|
|
|
} |
|
|
|
|
//初始化地图
|
|
|
|
|
labelGis() { |
|
|
|
|
this.map = new AMap.Map('container', { |
|
|
|
|
this.map = MapFactory.MapInstance('container', { |
|
|
|
|
zoom: 12 |
|
|
|
|
}) |
|
|
|
|
this.map.on('complete', () => { |
|
|
|
@ -179,12 +181,10 @@ export class BasicinfoComponent implements OnInit {
|
|
|
|
|
var autoOptions = { |
|
|
|
|
input: "tipinput" |
|
|
|
|
}; |
|
|
|
|
AMap.plugin(['AMap.PlaceSearch', 'AMap.AutoComplete'], () => { |
|
|
|
|
var auto = new AMap.AutoComplete(autoOptions); |
|
|
|
|
this.placeSearch = new AMap.PlaceSearch(); //构造地点查询类
|
|
|
|
|
this.map.plugin(['AMap.PlaceSearch', 'AMap.AutoComplete'], () => { |
|
|
|
|
var auto = MapFactory.AutocompleteInstance(autoOptions); |
|
|
|
|
this.placeSearch = MapFactory.PlaceSearchInstance(); //构造地点查询类
|
|
|
|
|
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]); //设置地图中心点
|
|
|
|
@ -195,10 +195,10 @@ export class BasicinfoComponent implements OnInit {
|
|
|
|
|
if (this.isMapLabel) {//如果已经标注单位坐标
|
|
|
|
|
// console.log('已标注单位位置')
|
|
|
|
|
this.map.setCenter([this.unitinfo.location.x, this.unitinfo.location.y]); |
|
|
|
|
this.oldPositionMarker = new AMap.Marker({ |
|
|
|
|
this.oldPositionMarker = MapFactory.MarkerInstance({ |
|
|
|
|
position: [this.unitinfo.location.x, this.unitinfo.location.y], |
|
|
|
|
content: this.newPositionMarkerContent, |
|
|
|
|
offset: new AMap.Pixel(-34, -36) |
|
|
|
|
offset: MapFactory.PixelInstance(-34, -36) |
|
|
|
|
}) |
|
|
|
|
// 将 markers 添加到地图
|
|
|
|
|
this.map.add(this.oldPositionMarker); |
|
|
|
@ -222,11 +222,11 @@ export class BasicinfoComponent implements OnInit {
|
|
|
|
|
this.newPositionMarker.setContent(this.oldPositionMarkerContent) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
this.newPositionMarker = new AMap.Marker({ |
|
|
|
|
this.newPositionMarker = MapFactory.MarkerInstance({ |
|
|
|
|
draggable: true, |
|
|
|
|
position: [this.markerPosition.x, this.markerPosition.y], |
|
|
|
|
content: this.newPositionMarkerContentBtn, |
|
|
|
|
offset: new AMap.Pixel(-34, -36) |
|
|
|
|
offset: MapFactory.PixelInstance(-34, -36) |
|
|
|
|
}); |
|
|
|
|
this.map.add(this.newPositionMarker); |
|
|
|
|
|
|
|
|
@ -251,10 +251,10 @@ export class BasicinfoComponent implements OnInit {
|
|
|
|
|
this.map.clearMap(); |
|
|
|
|
this.isGisTopBox = true |
|
|
|
|
this.isGisTopBoxTwo = false |
|
|
|
|
this.newPositionMarker = new AMap.Marker({ |
|
|
|
|
this.newPositionMarker = MapFactory.MarkerInstance({ |
|
|
|
|
position: [this.markerPosition2.x, this.markerPosition2.y], |
|
|
|
|
content: this.newPositionMarkerContent, |
|
|
|
|
offset: new AMap.Pixel(-34, -36) |
|
|
|
|
offset: MapFactory.PixelInstance(-34, -36) |
|
|
|
|
}); |
|
|
|
|
this.markerPosition = this.markerPosition2 |
|
|
|
|
this.map.add(this.newPositionMarker); |
|
|
|
@ -264,10 +264,10 @@ export class BasicinfoComponent implements OnInit {
|
|
|
|
|
this.isGisTopBox = true |
|
|
|
|
this.isGisTopBoxTwo = false |
|
|
|
|
this.map.clearMap(); |
|
|
|
|
this.newPositionMarker = new AMap.Marker({ |
|
|
|
|
this.newPositionMarker = MapFactory.MarkerInstance({ |
|
|
|
|
position: [this.markerPosition.x, this.markerPosition.y], |
|
|
|
|
content: this.newPositionMarkerContent, |
|
|
|
|
offset: new AMap.Pixel(-34, -36) |
|
|
|
|
offset: MapFactory.PixelInstance(-34, -36) |
|
|
|
|
}); |
|
|
|
|
this.map.setCenter([this.markerPosition.x, this.markerPosition.y]); //设置地图中心点
|
|
|
|
|
this.map.add(this.newPositionMarker); |
|
|
|
@ -277,10 +277,10 @@ export class BasicinfoComponent implements OnInit {
|
|
|
|
|
this.map.clearMap(); |
|
|
|
|
this.isGisTopBox = true |
|
|
|
|
this.isGisTopBoxTwo = false |
|
|
|
|
this.newPositionMarker = new AMap.Marker({ |
|
|
|
|
this.newPositionMarker = MapFactory.MarkerInstance({ |
|
|
|
|
position: [this.markerPosition2.x, this.markerPosition2.y], |
|
|
|
|
content: this.newPositionMarkerContent, |
|
|
|
|
offset: new AMap.Pixel(-34, -36) |
|
|
|
|
offset: MapFactory.PixelInstance(-34, -36) |
|
|
|
|
}); |
|
|
|
|
this.markerPosition = this.markerPosition2 |
|
|
|
|
this.map.add(this.newPositionMarker); |
|
|
|
@ -290,10 +290,10 @@ export class BasicinfoComponent implements OnInit {
|
|
|
|
|
this.isGisTopBox = true |
|
|
|
|
this.isGisTopBoxTwo = false |
|
|
|
|
this.map.clearMap(); |
|
|
|
|
this.newPositionMarker = new AMap.Marker({ |
|
|
|
|
this.newPositionMarker = MapFactory.MarkerInstance({ |
|
|
|
|
position: [this.markerPosition.x, this.markerPosition.y], |
|
|
|
|
content: this.newPositionMarkerContent, |
|
|
|
|
offset: new AMap.Pixel(-34, -36) |
|
|
|
|
offset: MapFactory.PixelInstance(-34, -36) |
|
|
|
|
}); |
|
|
|
|
this.map.setCenter([this.markerPosition.x, this.markerPosition.y]); //设置地图中心点
|
|
|
|
|
this.map.add(this.newPositionMarker); |
|
|
|
@ -311,11 +311,11 @@ export class BasicinfoComponent implements OnInit {
|
|
|
|
|
this.map.setCenter(center); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
this.newPositionMarker = new AMap.Marker({ |
|
|
|
|
this.newPositionMarker = MapFactory.MarkerInstance({ |
|
|
|
|
draggable: true, |
|
|
|
|
position: center, |
|
|
|
|
content: this.newPositionMarkerContentBtn, |
|
|
|
|
offset: new AMap.Pixel(-34, -36) |
|
|
|
|
offset: MapFactory.PixelInstance(-34, -36) |
|
|
|
|
}); |
|
|
|
|
this.map.add(this.newPositionMarker); |
|
|
|
|
|
|
|
|
@ -341,10 +341,10 @@ export class BasicinfoComponent implements OnInit {
|
|
|
|
|
this.isGisTopBoxTwo = false |
|
|
|
|
this.markerPosition = this.markerPosition2 |
|
|
|
|
this.map.clearMap(); |
|
|
|
|
this.newPositionMarker = new AMap.Marker({ |
|
|
|
|
this.newPositionMarker = MapFactory.MarkerInstance({ |
|
|
|
|
position: [this.markerPosition.x, this.markerPosition.y], |
|
|
|
|
content: this.newPositionMarkerContent, |
|
|
|
|
offset: new AMap.Pixel(-34, -36) |
|
|
|
|
offset: MapFactory.PixelInstance(-34, -36) |
|
|
|
|
}); |
|
|
|
|
this.map.add(this.newPositionMarker); |
|
|
|
|
}) |
|
|
|
@ -353,10 +353,10 @@ export class BasicinfoComponent implements OnInit {
|
|
|
|
|
this.isGisTopBoxTwo = false |
|
|
|
|
this.markerPosition = this.markerPosition2 |
|
|
|
|
this.map.clearMap(); |
|
|
|
|
this.newPositionMarker = new AMap.Marker({ |
|
|
|
|
this.newPositionMarker = MapFactory.MarkerInstance({ |
|
|
|
|
position: [this.markerPosition.x, this.markerPosition.y], |
|
|
|
|
content: this.newPositionMarkerContent, |
|
|
|
|
offset: new AMap.Pixel(-34, -36) |
|
|
|
|
offset: MapFactory.PixelInstance(-34, -36) |
|
|
|
|
}); |
|
|
|
|
this.map.add(this.newPositionMarker); |
|
|
|
|
}) |
|
|
|
@ -365,10 +365,10 @@ export class BasicinfoComponent implements OnInit {
|
|
|
|
|
this.isGisTopBox = true |
|
|
|
|
this.isGisTopBoxTwo = false |
|
|
|
|
if (this.markerPosition.x && this.markerPosition.x != 0) {//说明之前标过点
|
|
|
|
|
this.newPositionMarker = new AMap.Marker({ |
|
|
|
|
this.newPositionMarker = MapFactory.MarkerInstance({ |
|
|
|
|
position: [this.markerPosition.x, this.markerPosition.y], |
|
|
|
|
content: this.newPositionMarkerContent, |
|
|
|
|
offset: new AMap.Pixel(-34, -36) |
|
|
|
|
offset: MapFactory.PixelInstance(-34, -36) |
|
|
|
|
}); |
|
|
|
|
this.map.setCenter([this.markerPosition.x, this.markerPosition.y]); //设置地图中心点
|
|
|
|
|
this.map.add(this.newPositionMarker); |
|
|
|
@ -379,10 +379,10 @@ export class BasicinfoComponent implements OnInit {
|
|
|
|
|
this.isGisTopBox = true |
|
|
|
|
this.isGisTopBoxTwo = false |
|
|
|
|
if (this.markerPosition.x && this.markerPosition.x != 0) {//说明之前标过点
|
|
|
|
|
this.newPositionMarker = new AMap.Marker({ |
|
|
|
|
this.newPositionMarker = MapFactory.MarkerInstance({ |
|
|
|
|
position: [this.markerPosition.x, this.markerPosition.y], |
|
|
|
|
content: this.newPositionMarkerContent, |
|
|
|
|
offset: new AMap.Pixel(-34, -36) |
|
|
|
|
offset: MapFactory.PixelInstance(-34, -36) |
|
|
|
|
}); |
|
|
|
|
this.map.setCenter([this.markerPosition.x, this.markerPosition.y]); //设置地图中心点
|
|
|
|
|
this.map.add(this.newPositionMarker); |
|
|
|
|