Created
August 23, 2020 05:19
-
-
Save pankajkrr/015ab0cd033b0c18af12769c71b4fa62 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component } from '@angular/core'; | |
@Component({ | |
selector: 'app-root', | |
template: `<agm-map | |
[latitude]="latitude" | |
[longitude]="longitude" | |
[zoom]="2" | |
(mapClick)="addMarker($event.coords.lat, $event.coords.lng)" | |
> | |
<agm-marker | |
*ngFor="let marker of markers" | |
[latitude]="marker.lat" | |
[longitude]="marker.lng" | |
[opacity]="marker.alpha" | |
[markerDraggable]="true" | |
(markerClick)="selectMarker($event)" | |
> | |
</agm-marker> | |
</agm-map> | |
<p *ngIf="selectedMarker"> | |
Lat: {{ selectedMarker.lat }} Lng: {{ selectedMarker.lng }} | |
</p>`, | |
styles: ['agm-map { height: 500px; }'], | |
}) | |
export class AppComponent { | |
lat = 43.879078; | |
lng = -103.4615581; | |
selectedMarker; | |
markers = [ | |
{ lat: 54.2166845, lng:-13.4547512 , alpha: 1 }, | |
{ lat: 51.8679575, lng: 14.6368418, alpha: 1 }, | |
{ lat: 59.881411, lng: 20.867694, alpha: 1 }, | |
{ lat: 8.720884, lng: 77.479315, alpha: 1 } | |
]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment