By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,364 Members | 1,147 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,364 IT Pros & Developers. It's quick & easy.

How to return value of Longitude and latitude from json using angular 7?

P: 5
How to return value of Longitude and latitude from json using angular 7?

my url as following :

http://192.168.7.xxx:9200/location/_doc/27737

json returned from url above is :

Expand|Select|Wrap|Line Numbers
  1. {"_index":"location","_type":"_doc","_id":"27737","_version":1,"_seq_no":5577,"_primary_term":1,"found":true,"_source":{"Locid":27737,"GPS1":"25.0173, 121.462","GPS2":"2501'02.2\"N 12127'44.8\"E","CompanyID":1005070,"ads":"142 Sec. 1, HsIn Nan Rd cung Ko Dst, New Taipei City, Taiwan","Crid":75,"con":"Taiwan","Ctid":5894,"Cn":"Zhonghe District","pushdate":"2019-12-26T03:38:20.883"}}  
I need to return two values from GPS1 :

longtiude : 25.0173

latitude : 121.462

Based on LocationId parameter :27737

So that I need to create service

take location id parameters

and return two values of GPS1
Longtude
And
latitude

then set values returned of longtude and latitude

on ngOinInit Event

How to create service then call it on ngOnInit

Expand|Select|Wrap|Line Numbers
  1. ngOnInit  
  2. {  
  3. call service here  
  4. }  
Dec 28 '19 #1
Share this Question
Share on Google+
1 Reply


gits
Expert Mod 5K+
P: 5,389
if your return is json-formatted already then you just need to JSON.parse it and then it is a regular JavaScript object where you can access the properties in standard way.

or are you asking about how to make a xmlhttp-request at all?
Dec 30 '19 #2

Post your reply

Sign in to post your reply or Sign up for a free account.