How to display google coordinates from a request

#1

I want to display the location base on the value that I get from getLocation but all I get is a blue screen if I assign for example
this.lat=25.7777, this.lng=26,777; but it does not if a did like this this.lat=this.LAT; this.lng=this.LNG; and it works fine one last thing l would like to mention that the datatype in the database is double and I have tried testing a text as well

lat:number;
  lng:number;
  LAT:any;
   LNG:any;

  constructor(public dataservice:DataService,private geolocation: Geolocation) {
this.dataservice.getLocation(ID)
  .subscribe(data =>{this.LAT = data[0].lat,
    this. LNG=data[0].lng
    
   this.lat=tthis.LAT;
         this.lng=this.LNG;


  });

<agm-map [latitude]="lat"[longitude]="lng" [zoom]="10"
      [zoomControl]="true">
  <agm-marker  [latitude]="lat" [longitude]="lng"></agm-marker>
</agm-map>
#2

Why do you have two sets of properties for the same data?

#3

well because I need one property to store the latitude value and another for the longitude

#4

I am asking why you need two latitude and two longitude.

#5

ah yeah I try adding the LAT and LNG properties in latitude]=“LAT”[longitude]=“LNG” and it doesn’t work I still get the blue screen so I thought maybe if I ass to another property it may work I was testing some ideas hoping one would work

#6

What? A screen with blue background or are you talking about Windows blue screen for fatal errors?

console.log(data); before you work with it to see if it contains what you want at all.

Also: Your code indentation sucks and makes it very hard to read.

What is this?

Why do you need lat/lng on both the map and the marker?

#7

first, this is the blue screen I am talking about
second I am really sorry about my indentation and yes I have try to log the data and it contains the correct data

the [quote=“Sujan12, post:6, topic:98594”]
<agm-map
[/quote]
this is an Angular Google Maps (AGM)

the first lat/lng will initial center position for the map
and the second is for the marker

#8

That looks like water to me. What does it show when you zoom out?

I would output the data in your page as well, or at least console.log it and show us the result. Maybe these values are actually somewhere in the middle of the ocean?

Provide a link please.

#9

So this is a little embarrassing it was water but the the coordinate are not in the middle of the ocean
so I don’t know why is there 47.6205099,-122.3514661

https://angular-maps.com

#10

Where exactly are you logging this? If this is your data returned by the subcribe, this could be your root problem: This doesn’t seem to have any lat or lng properties but just two entries - so it seems to be an array with 2 values?

#11

From the example on the homepage:

export class AppComponent {
  lat: number = 51.678418;
  lng: number = 7.809007;
}

Seems lat and lng should be of type number, not string as you seem to have. (at least that’s what I get from the console output of data)

#12

yeah that right I add parseFloat(this.Code) and it work