diff --git a/src/app/data/bus-stop/bus-stop.component.ts b/src/app/data/bus-stop/bus-stop.component.ts index 19427cf..b1b1f42 100644 --- a/src/app/data/bus-stop/bus-stop.component.ts +++ b/src/app/data/bus-stop/bus-stop.component.ts @@ -1,4 +1,4 @@ -import { Component, ViewEncapsulation, AfterViewInit } from '@angular/core'; +import { Component, ViewEncapsulation, AfterViewInit,ViewChild } from '@angular/core'; import { TdLoadingService } from '@covalent/core'; import { GridOptions, IGetRowsParams, IRowModel } from 'ag-grid/main'; @@ -18,7 +18,7 @@ import { RoadSelectList } from '../../../models/road-select-list'; import { BooleanSelectList } from '../../../models/boolean-select-list'; import { SettlementSelectList } from '../../../models/settlement-select-list'; import { SurfaceTypeSelectList } from '../../../models/surface-type-select-list'; - +import { MapItemsComponent } from '../map-items/map-items.component'; import { routerTransition } from '../../../animations/router.animation'; @Component({ @@ -29,7 +29,7 @@ import { routerTransition } from '../../../animations/router.animation'; encapsulation: ViewEncapsulation.None, }) export class BusStopComponent extends StatementBase { - + @ViewChild(MapItemsComponent) mapItems: MapItemsComponent public regions: RegionSelectList[]; public states: StateCommonSelectList[]; public surfaceTypes: SurfaceTypeSelectList[]; @@ -205,7 +205,19 @@ export class BusStopComponent extends StatementBase { } protected onCellFocused($event: any): void { - console.log($event); + console.log($event); + // let model = this.gridOptions.api.getModel(); + // let row = model.getRow($event.rowIndex); + // console.log(row); + // this.mapItems.refreshMap(row); + } + + protected onSelectionChanged() { + console.log('onSelectionChanged'); + super.onSelectionChanged(); + let rows: IRowModel[] = this.gridOptions.api.getSelectedRows(); + console.log(rows); + this.mapItems.refreshMap(rows); } } diff --git a/src/app/data/map-items/map-items.component.ts b/src/app/data/map-items/map-items.component.ts index e113eb3..723f1e7 100644 --- a/src/app/data/map-items/map-items.component.ts +++ b/src/app/data/map-items/map-items.component.ts @@ -13,7 +13,7 @@ export class MapItemsComponent implements OnInit{ @Input() position: string; public map: L.Map; public icon: L.Icon; - + public markersGroup: L.FeatureGroup; ngOnInit(){ this.icon = L.icon({ iconUrl: '/assets/icons/marker-icon.png', @@ -24,15 +24,36 @@ export class MapItemsComponent implements OnInit{ L.tileLayer('https://a.tile.openstreetmap.org/{z}/{x}/{y}.png', { maxZoom: 18, }).addTo(this.map); - if(this.position != null){ - let options = { - draggable:true, - icon: this.icon, - }; - let latLng = this.position.split(','); - let marker = L.marker(new L.LatLng(parseInt(latLng[0]),parseInt(latLng[1])),options); - this.map.addLayer(marker); + // if(this.position != null){ + // let options = { + // draggable:true, + // icon: this.icon, + // }; + // let latLng = this.position.split(','); + // let marker = L.marker(new L.LatLng(parseInt(latLng[0]),parseInt(latLng[1])),options); + // this.map.addLayer(marker); + // + // } + } + refreshMap(rows): void{ + if(this.markersGroup != null){ + this.map.removeLayer(this.markersGroup); } + let options = { + draggable:true, + icon: this.icon, + }; + let markers = []; + rows.map((row)=>{ + if(row != null){ + let latLng = row.position.split(','); + console.log(parseFloat(latLng[0]) +' '+parseFloat(latLng[1])); + markers.push(L.marker(new L.LatLng(parseFloat(latLng[0]),parseFloat(latLng[1])),options)); + //markers.addLayer(marker); + } + }); + this.markersGroup = new L.FeatureGroup(markers); + this.map.addLayer(this.markersGroup); } } \ No newline at end of file diff --git a/src/models/statement.base.ts b/src/models/statement.base.ts index 15b350d..81bbf69 100644 --- a/src/models/statement.base.ts +++ b/src/models/statement.base.ts @@ -216,9 +216,7 @@ export abstract class StatementBase implements AfterViewInit, OnInit { console.log('onCellContextMenu: ' + $event.rowIndex + ' ' + $event.colDef.field); } - protected onCellFocused($event: any): void { - console.log('onCellFocused: (' + $event.rowIndex + ',' + $event.colIndex + ')'); - } + protected onRowSelected($event: any): void { // taking out, as when we 'select all', it prints to much to the console!! -- libgit2 0.21.4