Changeset 28d7d35 for Farmatiko/ClientApp/src/app/dialogs/pharmacy-dialog
- Timestamp:
- 01/31/21 06:27:26 (4 years ago)
- Branches:
- master
- Children:
- de9d697
- Parents:
- 7520f88
- Location:
- Farmatiko/ClientApp/src/app/dialogs/pharmacy-dialog
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
Farmatiko/ClientApp/src/app/dialogs/pharmacy-dialog/pharmacy-dialog.component.css
r7520f88 r28d7d35 1 button { 2 float: right; 3 } 4 5 div { 6 white-space: nowrap; 7 } -
Farmatiko/ClientApp/src/app/dialogs/pharmacy-dialog/pharmacy-dialog.component.html
r7520f88 r28d7d35 1 <h3>Повеќе инфо</h3> 1 <h3>Повеќе информации</h3> 2 <table class="table table-striped"> 3 <tbody> 4 <tr> 5 <td>Име</td> 6 <td>{{pharmacy?.name}}</td> 7 </tr> 8 <tr> 9 <td>Општина</td> 10 <td>{{pharmacy?.location}}</td> 11 </tr> 12 <tr> 13 <td>Адреса</td> 14 <td>{{pharmacy?.address}}</td> 15 </tr> 16 <tr> 17 <td>Работи 24/7</td> 18 <td><div *ngIf="pharmacy.workAllTime == true">Да</div><div *ngIf="pharmacy.workAllTime != true">Не</div></td> 19 </tr> 20 <tr> 21 <td>Компанија</td> 22 <td>{{pharmacy?.headName}}</td> 23 </tr> 24 </tbody> 25 </table> 26 27 <div style="height: 200px;" leaflet [leafletOptions]="options" *ngIf="mapShown"></div> 2 28 <br> 3 <p>ИД: {{pharmacy.id}}</p> 4 <p>Име: {{pharmacy.name}}</p> 5 <p>Општина: {{pharmacy.location}}</p> 6 <p>Адреса: {{pharmacy.address}}</p> 7 <p>Работи 24/7: {{pharmacy.workAllTime}}</p> 8 <br> 9 <p><a (click)="close()">Затвори</a></p> 29 <p><button mat-button color="primary" (click)="close()">Затвори</button></p> -
Farmatiko/ClientApp/src/app/dialogs/pharmacy-dialog/pharmacy-dialog.component.ts
r7520f88 r28d7d35 1 import { Component, OnInit, Inject } from '@angular/core';1 import { Component, OnInit, Inject, AfterViewInit } from '@angular/core'; 2 2 import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; 3 3 import { IPharmacy } from '../../shared/interfaces'; 4 import { latLng, LatLng, tileLayer, marker, icon } from 'leaflet'; 5 import { HttpClient } from '@angular/common/http'; 4 6 5 7 @Component({ … … 10 12 export class PharmacyDialogComponent implements OnInit { 11 13 pharmacy: IPharmacy; 14 mapShown: boolean = true; 15 options = { 16 layers: [ 17 tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors' }) 18 ], 19 zoom: 7, 20 center: latLng(41.61807, 21.74348) 21 } 12 22 13 constructor(private dialogRef: MatDialogRef<PharmacyDialogComponent>, @Inject(MAT_DIALOG_DATA) data ) {23 constructor(private dialogRef: MatDialogRef<PharmacyDialogComponent>, @Inject(MAT_DIALOG_DATA) data, private http: HttpClient) { 14 24 this.pharmacy = data; 25 if(this.pharmacy) { 26 this.addMarkers(); 27 } 15 28 } 16 29 17 30 ngOnInit(): void { 31 } 32 33 addMarkers() { 34 this.http.get<any>('https://nominatim.openstreetmap.org/search/?country=Macedonia&city='+this.pharmacy?.location+'&street='+this.pharmacy?.address+'&format=json').subscribe(obj => { 35 console.log(obj); 36 if(obj.length) { 37 let layer = marker([ obj[0]?.lat, obj[0]?.lon ], { 38 icon: icon({ 39 iconSize: [ 25, 41 ], 40 iconAnchor: [ 13, 41 ], 41 iconUrl: 'assets/pharmacy-icon.png' 42 }) 43 }).bindPopup("Аптека: "+this.pharmacy?.name); 44 this.options.layers.push(layer); 45 this.options.center = latLng(obj[0]?.lat, obj[0]?.lon); 46 this.options.zoom = 13; 47 } 48 }, error => console.error(error)); 49 this.mapShown = false; 50 setTimeout(() => this.mapShown = true, 300); 18 51 } 19 52 … … 22 55 } 23 56 57 24 58 }
Note:
See TracChangeset
for help on using the changeset viewer.