0

I created a map on my website. User can add multiple markers. And on the other page I created a call to these markers. Here is a string:

string '[{"lat":"40.7181193798","lng":"-84.4847297668","label":"A"},{"lat":"40.9530752681","lng":"-83.9779055864","label":"A"}]'

How to make it display only the address. Like "USA,NY,gikalo street ..." And created a link to Google maps with this location. Thank you in advance

1

2 Answers 2

2
var z='[{"lat":"40.7181193798","lng":"-84.4847297668","label":"A"},{"lat":"40.9530752681","lng":"-83.9779055864","label":"A"}]'

var JSONArray=JSON.parse(z);
var lat=JSONArray[0].lat;//For first obj
var long=JSONArray[0].long;//For first obj

var dataURL="http://maps.googleapis.com/maps/api/geocode/json?latlng="+lat+","+long+"&sensor=true";

You can fetch your data by using this url Just you need to parse your JSON in response you wil get appropriate result.

Sign up to request clarification or add additional context in comments.

5 Comments

Ty, may be u now how to create link to GM?
may be u now, can I add 2 location in one request?
basically location is depend on location code. you can't add it one request. you can make two different request. and merget it in one request
The Google Maps docs have been updated and as of June 2014 and the &sensor parameter is no longer required for JavaScript or Web Service API calls. See docs - developers.google.com/maps/documentation/javascript/tutorial
1

You will need API key inorder to make the Google Map API request everytime.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.