Commit 88b2c0723793a59ea4d1f7f86d8002c5b5c5b4ee
1 parent
4cfbf7ca
Map
Showing
8 changed files
with
109 additions
and
16 deletions
Show diff stats
angular-cli.json
| @@ -23,7 +23,8 @@ | @@ -23,7 +23,8 @@ | ||
| 23 | "../node_modules/@covalent/core/common/platform.css", | 23 | "../node_modules/@covalent/core/common/platform.css", |
| 24 | "../node_modules/@swimlane/ngx-charts/release/ngx-charts.css", | 24 | "../node_modules/@swimlane/ngx-charts/release/ngx-charts.css", |
| 25 | "../node_modules/ag-grid/dist/styles/ag-grid.css", | 25 | "../node_modules/ag-grid/dist/styles/ag-grid.css", |
| 26 | - "../node_modules/ag-grid/dist/styles/theme-blue.css" | 26 | + "../node_modules/ag-grid/dist/styles/theme-blue.css", |
| 27 | + "../node_modules/leaflet/dist/leaflet.css" | ||
| 27 | ], | 28 | ], |
| 28 | "scripts": [ | 29 | "scripts": [ |
| 29 | "../node_modules/hammerjs/hammer.min.js", | 30 | "../node_modules/hammerjs/hammer.min.js", |
src/app/app.module.ts
| @@ -11,10 +11,12 @@ import { AppComponent } from './app.component'; | @@ -11,10 +11,12 @@ import { AppComponent } from './app.component'; | ||
| 11 | import { MainComponent } from './main/main.component'; | 11 | import { MainComponent } from './main/main.component'; |
| 12 | import { LoginComponent } from './login/login.component'; | 12 | import { LoginComponent } from './login/login.component'; |
| 13 | import { DataComponent } from './data/data.component'; | 13 | import { DataComponent } from './data/data.component'; |
| 14 | -import { TemplatesComponent } from './templates/templates.component';; | 14 | +import { TemplatesComponent } from './templates/templates.component'; |
| 15 | import { appRoutes, appRoutingProviders } from './app.routes'; | 15 | import { appRoutes, appRoutingProviders } from './app.routes'; |
| 16 | import { AgGridModule } from 'ag-grid-ng2/main'; | 16 | import { AgGridModule } from 'ag-grid-ng2/main'; |
| 17 | import { ChartComponent } from '../components/chart/chart.component'; | 17 | import { ChartComponent } from '../components/chart/chart.component'; |
| 18 | +import { CandTLeafletComponent } from 'angular2.leaflet.components'; | ||
| 19 | +import { CandTLeafletService } from 'angular2.leaflet.components'; | ||
| 18 | 20 | ||
| 19 | import { RequestInterceptor } from '../config/interceptors/request.interceptor'; | 21 | import { RequestInterceptor } from '../config/interceptors/request.interceptor'; |
| 20 | 22 | ||
| @@ -32,6 +34,7 @@ import { FlowIntensityComponent } from './data/flow-intensity/flow-intensity.com | @@ -32,6 +34,7 @@ import { FlowIntensityComponent } from './data/flow-intensity/flow-intensity.com | ||
| 32 | import { RoadComponent } from './data/road/road.component'; | 34 | import { RoadComponent } from './data/road/road.component'; |
| 33 | import { RoadServiceComponent } from './data/road-service/road-service.component'; | 35 | import { RoadServiceComponent } from './data/road-service/road-service.component'; |
| 34 | import { SettlementAddressLinkComponent } from './data/settlement-address-link/settlement-address-link.component'; | 36 | import { SettlementAddressLinkComponent } from './data/settlement-address-link/settlement-address-link.component'; |
| 37 | +import { MapComponent } from './data/map/map.component'; | ||
| 35 | 38 | ||
| 36 | // Services | 39 | // Services |
| 37 | import { BusStopCreateService } from '../services/bus-stop-create.service'; | 40 | import { BusStopCreateService } from '../services/bus-stop-create.service'; |
| @@ -80,6 +83,8 @@ const httpInterceptorProviders: Type<any>[] = [ | @@ -80,6 +83,8 @@ const httpInterceptorProviders: Type<any>[] = [ | ||
| 80 | CrossSectionComponent, | 83 | CrossSectionComponent, |
| 81 | RoadServiceComponent, | 84 | RoadServiceComponent, |
| 82 | SettlementAddressLinkComponent, | 85 | SettlementAddressLinkComponent, |
| 86 | + MapComponent, | ||
| 87 | + CandTLeafletComponent | ||
| 83 | ], // directives, components, and pipes owned by this NgModule | 88 | ], // directives, components, and pipes owned by this NgModule |
| 84 | imports: [ | 89 | imports: [ |
| 85 | BrowserModule, | 90 | BrowserModule, |
| @@ -135,6 +140,7 @@ const httpInterceptorProviders: Type<any>[] = [ | @@ -135,6 +140,7 @@ const httpInterceptorProviders: Type<any>[] = [ | ||
| 135 | RoadServiceCreateService, | 140 | RoadServiceCreateService, |
| 136 | SettlementAddressLinkService, | 141 | SettlementAddressLinkService, |
| 137 | SettlementAddressLinkCreateService, | 142 | SettlementAddressLinkCreateService, |
| 143 | + CandTLeafletService, | ||
| 138 | ], // additional providers needed for this module | 144 | ], // additional providers needed for this module |
| 139 | entryComponents: [ ], | 145 | entryComponents: [ ], |
| 140 | bootstrap: [ AppComponent ], | 146 | bootstrap: [ AppComponent ], |
src/app/app.routes.ts
| @@ -14,6 +14,7 @@ import { FlowIntensityComponent } from './data/flow-intensity/flow-intensity.com | @@ -14,6 +14,7 @@ import { FlowIntensityComponent } from './data/flow-intensity/flow-intensity.com | ||
| 14 | import { RoadComponent } from './data/road/road.component'; | 14 | import { RoadComponent } from './data/road/road.component'; |
| 15 | import { RoadServiceComponent } from './data/road-service/road-service.component'; | 15 | import { RoadServiceComponent } from './data/road-service/road-service.component'; |
| 16 | import { SettlementAddressLinkComponent } from './data/settlement-address-link/settlement-address-link.component'; | 16 | import { SettlementAddressLinkComponent } from './data/settlement-address-link/settlement-address-link.component'; |
| 17 | +import { MapComponent } from './data/map/map.component'; | ||
| 17 | 18 | ||
| 18 | const routes: Routes = [ | 19 | const routes: Routes = [ |
| 19 | {path: 'login', component: LoginComponent}, | 20 | {path: 'login', component: LoginComponent}, |
| @@ -30,6 +31,7 @@ const routes: Routes = [ | @@ -30,6 +31,7 @@ const routes: Routes = [ | ||
| 30 | {path: 'road-service', component: RoadServiceComponent}, | 31 | {path: 'road-service', component: RoadServiceComponent}, |
| 31 | {path: 'road-to-category', component: RoadToCategoryComponent}, | 32 | {path: 'road-to-category', component: RoadToCategoryComponent}, |
| 32 | {path: 'settlement-address-link', component: SettlementAddressLinkComponent}, | 33 | {path: 'settlement-address-link', component: SettlementAddressLinkComponent}, |
| 34 | + {path: 'map', component: MapComponent}, | ||
| 33 | ]}, | 35 | ]}, |
| 34 | ]}, | 36 | ]}, |
| 35 | ]; | 37 | ]; |
| 1 | +import { Component, ViewEncapsulation, OnInit } from '@angular/core'; | ||
| 2 | +import * as L from 'leaflet'; | ||
| 3 | + | ||
| 4 | +@Component({ | ||
| 5 | + // tslint:disable-next-line:component-selector | ||
| 6 | + selector: 'map-grid', | ||
| 7 | + templateUrl: 'map.component.html', | ||
| 8 | + styleUrls: ['map.scss'], | ||
| 9 | + encapsulation: ViewEncapsulation.None, | ||
| 10 | +}) | ||
| 11 | +export class MapComponent implements OnInit { | ||
| 12 | + public map: L.Map; | ||
| 13 | + public icon: L.Icon; | ||
| 14 | + public markers: L.Marker[] = []; | ||
| 15 | + public circles: L.Circle[] = []; | ||
| 16 | + public polygon: L.Polygon[] = []; | ||
| 17 | + ngOnInit(): void { | ||
| 18 | + this.icon = L.icon({ | ||
| 19 | + iconUrl: '/assets/icons/marker-icon.png', | ||
| 20 | + iconSize: [25, 41], // size of the icon | ||
| 21 | + popupAnchor: [-3, -76], // point from which the popup should open relative to the iconAnchor | ||
| 22 | + }); | ||
| 23 | + this.map = L.map('mapId').setView([51.505, -0.09], 13); | ||
| 24 | + L.tileLayer('https://a.tile.openstreetmap.org/{z}/{x}/{y}.png', { | ||
| 25 | + maxZoom: 18, | ||
| 26 | + }).addTo(this.map); | ||
| 27 | + let x: number = 51.5; | ||
| 28 | + let y: number = -0.09; | ||
| 29 | + for (let i: number = 0; i < 10; i++) { | ||
| 30 | + this.markers.push(L.marker([x + i, y + i], { | ||
| 31 | + icon: this.icon, | ||
| 32 | + }).addTo(this.map)); | ||
| 33 | + } | ||
| 34 | + this.markers.forEach(function(i: L.Marker, y: number, z: L.Marker[]): void { | ||
| 35 | + i.bindPopup('Popup from element #' + y); | ||
| 36 | + i.bindTooltip('Popup from element #' + y); | ||
| 37 | + }); | ||
| 38 | + this.markers.push(L.marker([51.5, -0.09], { | ||
| 39 | + icon: this.icon, | ||
| 40 | + }).addTo(this.map)); | ||
| 41 | + this.circles.push(L.circle([51.508, -0.11], { | ||
| 42 | + color: 'red', | ||
| 43 | + fillColor: '#f03', | ||
| 44 | + fillOpacity: 0.5, | ||
| 45 | + radius: 500, | ||
| 46 | + }).addTo(this.map)); | ||
| 47 | + this.polygon.push(L.polygon([ | ||
| 48 | + [51.509, -0.08], | ||
| 49 | + [51.503, -0.06], | ||
| 50 | + [51.51, -0.047], | ||
| 51 | + ]).addTo(this.map)); | ||
| 52 | + }; | ||
| 53 | +} |
| 1 | +.toolbar button { | ||
| 2 | + margin: 2px; | ||
| 3 | + padding: 0; | ||
| 4 | +} | ||
| 5 | + | ||
| 6 | +#mapId { | ||
| 7 | + height: 100%; | ||
| 8 | +} | ||
| 9 | + | ||
| 10 | +.leaflet-container { | ||
| 11 | + width: 100%; | ||
| 12 | + height: 100%; | ||
| 13 | +} | ||
| 14 | + | ||
| 15 | +.map-container { | ||
| 16 | + height: 100%; | ||
| 17 | +} | ||
| 18 | + | ||
| 19 | +leaf-element { | ||
| 20 | + width: 100%; | ||
| 21 | +} | ||
| 22 | + | ||
| 23 | +.leaflet-pane { | ||
| 24 | + z-index: 0 !important; | ||
| 25 | +} | ||
| 0 | \ No newline at end of file | 26 | \ No newline at end of file |
1.43 KB
src/index.html
| 1 | <!doctype html> | 1 | <!doctype html> |
| 2 | <html> | 2 | <html> |
| 3 | + | ||
| 3 | <head> | 4 | <head> |
| 4 | - <meta charset="utf-8"> | ||
| 5 | - <title>Covalent Quickstart</title> | ||
| 6 | - <base href="/"> | ||
| 7 | - <link rel="icon" type="image/x-icon" href="favicon.ico"> | ||
| 8 | - <link rel="icon" type="image/png" href="favicon.png" sizes="32x32"> | ||
| 9 | - <meta name="theme-color" content="#000000"> | ||
| 10 | - <meta name="viewport" content="width=device-width, initial-scale=1"> | 5 | + <meta charset="utf-8"> |
| 6 | + <title>Covalent Quickstart</title> | ||
| 7 | + <base href="/"> | ||
| 8 | + <link rel="icon" type="image/x-icon" href="favicon.ico"> | ||
| 9 | + <link rel="icon" type="image/png" href="favicon.png" sizes="32x32"> | ||
| 10 | + <meta name="theme-color" content="#000000"> | ||
| 11 | + <meta name="viewport" content="width=device-width, initial-scale=1"> | ||
| 11 | </head> | 12 | </head> |
| 13 | + | ||
| 12 | <body> | 14 | <body> |
| 13 | - <qs-app> | ||
| 14 | - <div style="padding: 20%;text-align:center;"> | ||
| 15 | - <img src="assets/icons/covalent.svg" width="200"> | ||
| 16 | - <div>Quickstart Loading...</div> | ||
| 17 | - </div> | ||
| 18 | - </qs-app> | 15 | + <qs-app> |
| 16 | + <div style="padding: 20%;text-align:center;"> | ||
| 17 | + <img src="assets/icons/covalent.svg" width="200"> | ||
| 18 | + <div>Quickstart Loading...</div> | ||
| 19 | + </div> | ||
| 20 | + </qs-app> | ||
| 19 | </body> | 21 | </body> |
| 20 | -</html> | 22 | + |
| 23 | +</html> | ||
| 21 | \ No newline at end of file | 24 | \ No newline at end of file |