Search
 
SCRIPT & CODE EXAMPLE
 

TYPESCRIPT

angular get user location

public lat;
  public lng;

  public ngOnInit(): void {
    this.getLocation();
  }

  getLocation() {
    if (navigator.geolocation) {
      navigator.geolocation.getCurrentPosition((position: Position) => {
        if (position) {
          console.log("Latitude: " + position.coords.latitude +
            "Longitude: " + position.coords.longitude);
          this.lat = position.coords.latitude;
          this.lng = position.coords.longitude;
          console.log(this.lat);
          console.log(this.lat);
        }
      },
        (error: PositionError) => console.log(error));
    } else {
      alert("Geolocation is not supported by this browser.");
    }
  }
Comment

PREVIOUS NEXT
Code Example
Typescript :: typescript class interface 
Typescript :: avoid intertwining subplots in python 
Typescript :: prisma user model 
Typescript :: Emotion: Using both a class and the "css" method in "className" prop 
Typescript :: ternary operator in typescript 
Typescript :: typescript array of object with types 
Typescript :: check already exists from non deleted rows laravel 
Typescript :: angular typescript filter array group by attribute 
Typescript :: number of elements in list in python 
Typescript :: laravel validation check if email exists forget password 
Typescript :: type casting in typescript 
Typescript :: jquery select multiple elements with same class 
Typescript :: dotnet cli sln add all projects 
Typescript :: check anagramm in typescript 
Typescript :: go through each element of a dictionary typescript 
Typescript :: path react native 
Typescript :: how to clear known_hosts in ssh 
Typescript :: what is test data 
Typescript :: factory design pattern typescript 
Typescript :: git squash commits on branch 
Typescript :: props vue typescript 
Typescript :: how to use if statemnts c# 
Typescript :: create CSS class in directive angular 
Typescript :: global declaration css ts 
Typescript :: reverse mongo results order 
Typescript :: typescript one of array 
Typescript :: cypress with typescript 
Typescript :: Start Angular App In Localhost 
Typescript :: invoke lambda after cdk deploy 
Typescript :: What kind of projects is suitable for the Agile methodology 
ADD CONTENT
Topic
Content
Source link
Name
2+3 =