From 6f1ab8e489e791734a2c63550b63ad1cb74b4f57 Mon Sep 17 00:00:00 2001 From: fengxiang <110431245@qq.com> Date: Wed, 04 Jul 2018 17:19:29 +0800 Subject: [PATCH] 设备页面bug 修复 --- src/app/routes/map/coordinates-picker/coordinates-picker.component.ts | 18 +++++++++++------- 1 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/app/routes/map/coordinates-picker/coordinates-picker.component.ts b/src/app/routes/map/coordinates-picker/coordinates-picker.component.ts index 146c9c7..726a069 100644 --- a/src/app/routes/map/coordinates-picker/coordinates-picker.component.ts +++ b/src/app/routes/map/coordinates-picker/coordinates-picker.component.ts @@ -1,6 +1,6 @@ import { NzModalSubject } from 'ng-zorro-antd'; import { ReactiveFormsModule } from '@angular/forms'; -import { ViewEncapsulation, Component, ViewChild, ElementRef, NgZone } from '@angular/core'; +import { ViewEncapsulation, Component, ViewChild, ElementRef, NgZone, OnInit } from '@angular/core'; import { MapOptions, Point, MarkerOptions, ControlAnchor, NavigationControlOptions, NavigationControlType, BMapInstance } from 'angular2-baidu-map'; import { CoorPicker } from '@business/entity/data'; import { CoorPickerService } from 'app/routes/map/coordinates-picker/coordinates-picker.service'; @@ -13,7 +13,7 @@ templateUrl: './coordinates-picker.component.html', styleUrls: [ './coordinates-picker.component.css' ], }) -export class CoordinatesPickerComponent { +export class CoordinatesPickerComponent implements OnInit { Default_LNG = 121; Default_LAT = 31.4; isSaving = false; @@ -30,6 +30,9 @@ _BMap: any = null; constructor(private subject: NzModalSubject, private coorPickerService: CoorPickerService) { + + } + ngOnInit(): void { this.data = this.coorPickerService.data; let lng = this.data.longitude; lng = lng === 0 || lng == null ? this.Default_LNG : lng; @@ -69,7 +72,7 @@ width: -15 } }; - } + } private _marker: any = null; loadMarker(marker) { if (this._marker == null) { @@ -84,18 +87,19 @@ this._map.addEventListener( 'tilesloaded', (type, fn) => { - this._map.clearOverlays(); + // this._map.clearOverlays(); this._map.addOverlay(this._marker); } ); this._localSearch = new this._BMap.LocalSearch(map, { renderOptions: {map: map} }); - if (this.data.latitude === this.Default_LAT && this.data.longitude === this.Default_LNG - && this.data.address != null) { + if (this.data.latitude === this.Default_LAT + && this.data.longitude === this.Default_LNG + && !!this.data.address + && !!this.data.address.trim()) { this._localSearch.search(this.data.address); } - } queryTest: string; mapSearch(param: any) { -- Gitblit v1.8.0