import { stringify } from '@angular/compiler/src/util'; import { Component, ElementRef, OnInit, ViewChild } from '@angular/core'; import { FormGroup, FormBuilder, FormArray } from '@angular/forms'; import { ActivatedRoute, Router } from '@angular/router'; import { Subject } from 'rxjs'; import { ProjectInformation } from '../../../../models/building-project/project-information/project-information'; import { ProjectInformationService } from '../../../../services/building-project/project-information/project-information.service'; import { CommonService } from '../../../../services/common.service'; @Component({ selector: 'app-project-information-add', templateUrl: './project-information-add.component.html', styleUrls: ['./project-information-add.component.css'] }) export class ProjectInformationAddComponent implements OnInit { modelProjectInformation = new ProjectInformation(); ProjectInformationForm = FormGroup; @ViewChild("mapContainer", { static: false }) gmap: ElementRef; map: google.maps.Map; UserId: number = 1; IpAddress: string = "192.168.1"; CompanyId: number = 1; lat = 23.033924614154763; lng = 72.52440501753121; coordinates = new google.maps.LatLng(this.lat, this.lng); constructor(private formBuilder: FormBuilder, private route: ActivatedRoute, private router: Router, private service: ProjectInformationService, private common: CommonService) { } ngOnInit(): void { this.map = new google.maps.Map(document.getElementById("mapWindow") as HTMLElement, { center: this.coordinates, zoom: 8 }); google.maps.event.addListener(this.map, "click", (event) => { this.addMarker(event.latLng, this.map); }); //this.setFormBuilder(); } addMarker(location: google.maps.LatLngLiteral, map: google.maps.Map) { // Add the marker at the clicked location, and add the next-available label // from the array of alphabetical characters. new google.maps.Marker({ position: location, label: 'test', map: map, }); } }