Commit b4e8113b24d11fc8ddd4137fa75a433dd4e2701f

Authored by Administrator
1 parent 7d0da8c3

virtual page fix

src/app/data/bus-stop/bus-stop.component.ts
1 -import { Component, ViewEncapsulation, AfterViewInit } from '@angular/core'; 1 +import { Component, ViewEncapsulation, AfterViewInit,ViewChild } from '@angular/core';
2 import { TdLoadingService } from '@covalent/core'; 2 import { TdLoadingService } from '@covalent/core';
3 import { GridOptions, IGetRowsParams, IRowModel } from 'ag-grid/main'; 3 import { GridOptions, IGetRowsParams, IRowModel } from 'ag-grid/main';
4 4
@@ -18,7 +18,7 @@ import { RoadSelectList } from '../../../models/road-select-list'; @@ -18,7 +18,7 @@ import { RoadSelectList } from '../../../models/road-select-list';
18 import { BooleanSelectList } from '../../../models/boolean-select-list'; 18 import { BooleanSelectList } from '../../../models/boolean-select-list';
19 import { SettlementSelectList } from '../../../models/settlement-select-list'; 19 import { SettlementSelectList } from '../../../models/settlement-select-list';
20 import { SurfaceTypeSelectList } from '../../../models/surface-type-select-list'; 20 import { SurfaceTypeSelectList } from '../../../models/surface-type-select-list';
21 - 21 +import { MapItemsComponent } from '../map-items/map-items.component';
22 import { routerTransition } from '../../../animations/router.animation'; 22 import { routerTransition } from '../../../animations/router.animation';
23 23
24 @Component({ 24 @Component({
@@ -29,7 +29,7 @@ import { routerTransition } from '../../../animations/router.animation'; @@ -29,7 +29,7 @@ import { routerTransition } from '../../../animations/router.animation';
29 encapsulation: ViewEncapsulation.None, 29 encapsulation: ViewEncapsulation.None,
30 }) 30 })
31 export class BusStopComponent extends StatementBase { 31 export class BusStopComponent extends StatementBase {
32 - 32 + @ViewChild(MapItemsComponent) mapItems: MapItemsComponent
33 public regions: RegionSelectList[]; 33 public regions: RegionSelectList[];
34 public states: StateCommonSelectList[]; 34 public states: StateCommonSelectList[];
35 public surfaceTypes: SurfaceTypeSelectList[]; 35 public surfaceTypes: SurfaceTypeSelectList[];
@@ -205,7 +205,19 @@ export class BusStopComponent extends StatementBase { @@ -205,7 +205,19 @@ export class BusStopComponent extends StatementBase {
205 } 205 }
206 206
207 protected onCellFocused($event: any): void { 207 protected onCellFocused($event: any): void {
208 - console.log($event); 208 + console.log($event);
  209 + // let model = this.gridOptions.api.getModel();
  210 + // let row = model.getRow($event.rowIndex);
  211 + // console.log(row);
  212 + // this.mapItems.refreshMap(row);
  213 + }
  214 +
  215 + protected onSelectionChanged() {
  216 + console.log('onSelectionChanged');
  217 + super.onSelectionChanged();
  218 + let rows: IRowModel[] = this.gridOptions.api.getSelectedRows();
  219 + console.log(rows);
  220 + this.mapItems.refreshMap(rows);
209 } 221 }
210 222
211 } 223 }
src/app/data/map-items/map-items.component.ts
@@ -13,7 +13,7 @@ export class MapItemsComponent implements OnInit{ @@ -13,7 +13,7 @@ export class MapItemsComponent implements OnInit{
13 @Input() position: string; 13 @Input() position: string;
14 public map: L.Map; 14 public map: L.Map;
15 public icon: L.Icon; 15 public icon: L.Icon;
16 - 16 + public markersGroup: L.FeatureGroup;
17 ngOnInit(){ 17 ngOnInit(){
18 this.icon = L.icon({ 18 this.icon = L.icon({
19 iconUrl: '/assets/icons/marker-icon.png', 19 iconUrl: '/assets/icons/marker-icon.png',
@@ -24,15 +24,36 @@ export class MapItemsComponent implements OnInit{ @@ -24,15 +24,36 @@ export class MapItemsComponent implements OnInit{
24 L.tileLayer('https://a.tile.openstreetmap.org/{z}/{x}/{y}.png', { 24 L.tileLayer('https://a.tile.openstreetmap.org/{z}/{x}/{y}.png', {
25 maxZoom: 18, 25 maxZoom: 18,
26 }).addTo(this.map); 26 }).addTo(this.map);
27 - if(this.position != null){  
28 - let options = {  
29 - draggable:true,  
30 - icon: this.icon,  
31 - };  
32 - let latLng = this.position.split(',');  
33 - let marker = L.marker(new L.LatLng(parseInt(latLng[0]),parseInt(latLng[1])),options);  
34 - this.map.addLayer(marker); 27 + // if(this.position != null){
  28 + // let options = {
  29 + // draggable:true,
  30 + // icon: this.icon,
  31 + // };
  32 + // let latLng = this.position.split(',');
  33 + // let marker = L.marker(new L.LatLng(parseInt(latLng[0]),parseInt(latLng[1])),options);
  34 + // this.map.addLayer(marker);
  35 + //
  36 + // }
  37 + }
35 38
  39 + refreshMap(rows): void{
  40 + if(this.markersGroup != null){
  41 + this.map.removeLayer(this.markersGroup);
36 } 42 }
  43 + let options = {
  44 + draggable:true,
  45 + icon: this.icon,
  46 + };
  47 + let markers = [];
  48 + rows.map((row)=>{
  49 + if(row != null){
  50 + let latLng = row.position.split(',');
  51 + console.log(parseFloat(latLng[0]) +' '+parseFloat(latLng[1]));
  52 + markers.push(L.marker(new L.LatLng(parseFloat(latLng[0]),parseFloat(latLng[1])),options));
  53 + //markers.addLayer(marker);
  54 + }
  55 + });
  56 + this.markersGroup = new L.FeatureGroup(markers);
  57 + this.map.addLayer(this.markersGroup);
37 } 58 }
38 } 59 }
39 \ No newline at end of file 60 \ No newline at end of file
src/models/statement.base.ts
@@ -216,9 +216,7 @@ export abstract class StatementBase implements AfterViewInit, OnInit { @@ -216,9 +216,7 @@ export abstract class StatementBase implements AfterViewInit, OnInit {
216 console.log('onCellContextMenu: ' + $event.rowIndex + ' ' + $event.colDef.field); 216 console.log('onCellContextMenu: ' + $event.rowIndex + ' ' + $event.colDef.field);
217 } 217 }
218 218
219 - protected onCellFocused($event: any): void {  
220 - console.log('onCellFocused: (' + $event.rowIndex + ',' + $event.colIndex + ')');  
221 - } 219 +
222 220
223 protected onRowSelected($event: any): void { 221 protected onRowSelected($event: any): void {
224 // taking out, as when we 'select all', it prints to much to the console!! 222 // taking out, as when we 'select all', it prints to much to the console!!