add new component to seperate content of marker-popup
* ng generate new component * add dummy binding to give component a bike-station
This commit is contained in:
parent
18ceed31b1
commit
22cd28e2b3
@ -10,11 +10,13 @@ import {FlexLayoutModule} from '@angular/flex-layout';
|
||||
import {MatIconModule} from '@angular/material/icon';
|
||||
import {MatButtonModule} from '@angular/material/button';
|
||||
import {HttpClientModule} from '@angular/common/http';
|
||||
import { PopupComponent } from './map/popup/popup.component';
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
AppComponent,
|
||||
MapComponent
|
||||
MapComponent,
|
||||
PopupComponent
|
||||
],
|
||||
imports: [
|
||||
BrowserModule,
|
||||
|
@ -0,0 +1 @@
|
||||
<b>{{station.commonName}}</b>
|
@ -0,0 +1,25 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { PopupComponent } from './popup.component';
|
||||
|
||||
describe('PopupComponent', () => {
|
||||
let component: PopupComponent;
|
||||
let fixture: ComponentFixture<PopupComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [ PopupComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(PopupComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
@ -0,0 +1,23 @@
|
||||
import {Component, OnInit} from '@angular/core';
|
||||
import {BikeStation, IBikeStation} from '../../service/domain/bike-station';
|
||||
|
||||
@Component({
|
||||
selector: 'app-popup',
|
||||
templateUrl: './popup.component.html',
|
||||
styleUrls: ['./popup.component.scss']
|
||||
})
|
||||
export class PopupComponent implements OnInit {
|
||||
station: IBikeStation;
|
||||
|
||||
constructor() {
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
}
|
||||
|
||||
public bindStation(bikeStation: IBikeStation): void {
|
||||
this.station = bikeStation;
|
||||
console.log(this.station);
|
||||
}
|
||||
|
||||
}
|
@ -3,6 +3,7 @@ import * as L from 'leaflet';
|
||||
import 'leaflet.markercluster';
|
||||
import {HttpClient} from '@angular/common/http';
|
||||
import {environment} from '../../environments/environment';
|
||||
import {PopupComponent} from '../map/popup/popup.component';
|
||||
|
||||
const dummyData = [
|
||||
{
|
||||
@ -55,7 +56,7 @@ export class MapService {
|
||||
zoomToBoundsOnClick: true
|
||||
});
|
||||
for (const station of dummyData) {
|
||||
const marker = L.marker([station.lat, station.lon], {icon: createIcon});
|
||||
const marker = L.marker([station.lat, station.lon], {icon: createIcon}).bindPopup(new PopupComponent().bindStation(station));
|
||||
markerClusters.addLayer(marker);
|
||||
}
|
||||
this.map.addLayer(markerClusters);
|
||||
|
Loading…
Reference in New Issue
Block a user