Forward & Reverse Geocoding

על ידי Geocoding | מְעוּדכָּן לפני חודש | Mapping

9.9 / 10



רמת שירות


חזרה לכל הדיונים

How can I obtain lat and Long from the response ?

לפני שנתיים

The response is in json format
[{“importance”:0.88028949865446,“licence”:“Data © OpenStreetMap contributors, ODbL 1.0.",“class”:“place”,“osm_id”:2702400314,“display_name”:"Delhi, Kotwali Tehsil, Central Delhi, Delhi, 110006, India”,“osm_type”:“node”,“lon”:“77.2219388”,“place_id”:28014618,“boundingbox”:[“28.4917178”,“28.8117178”,“77.0619388”,“77.3819388”],“lat”:“28.6517178”,“type”:“city”},{“importance”:0.88028949865446,“licence”:“Data © OpenStreetMap contributors, ODbL 1.0.",“class”:“boundary”,“osm_id”:1942586,“display_name”:"Delhi, India”,“osm_type”:“relation”,“lon”:“77.1716954”,“place_id”:248434451,“boundingbox”:[“28.4046285”,“28.8834464”,“76.8388351”,“77.346601”],“lat”:“28.6273928”,“type”:“administrative”},{“importance”:0.495,“licence”:“Data © OpenStreetMap contributors, ODbL 1.0.",“class”:“waterway”,“osm_id”:301750823,“display_name”:"Delhi, Akkalkuwa, Nandubar, Maharashtra, 393025, India”,“osm_type”:“way”,“lon”:“73.934463”,“place_id”:162052895,“boundingbox”:[“21.4584209”,“21.6565955”,“73.9133997”,“73.9519009”],“lat”:“21.5766266”,“type”:“river”},{“importance”:0.221,“licence”:“Data © OpenStreetMap contributors, ODbL 1.0.",“class”:“shop”,“osm_id”:7741582801,“display_name”:"Delhi, Kolathur Road, Kolathur Chanthapadi, Kolathur, Perinthalmanna, Malappuram, Kerala, 679338, India”,“osm_type”:“node”,“lon”:“76.1376047”,“place_id”:290058681,“boundingbox”:[“10.9472113”,“10.9473113”,“76.1375547”,“76.1376547”],“lat”:“10.9472613”,“type”:“clothes”}]

How can I split to obtain lat and long from first object ?

GeocodeSupport commented לפני שנתיים

Hi Ishan,
you’ll just have to parse the json in your application for the lon and lat objects.

In your example, you’ve an array of objects and you would just parse along to get the lat and long from the first array element.

If you are unfamiliar with JSON but familiar with xml, you may as well switch to an xml response output by using format=xml.

As we can’t see what app/software or programming language you use you’ll have to state further details to get some direct help.

E.g. in JavaScript you could save the response in a response var and than use response[0].lat resp. response[0].lon . Other programming languages (may) have JSON parser libraries to translate the json response into an object in your used programming language.

הצטרף לדיון - הוסף תגובה למטה:

התחבר / הירשם כדי לפרסם תגובות חדשות
דירוג: 3.7 - הצבעות: 3