I want to pass in an array of google place id values and output the formatted addresses of each one onto a google map marker (multiple markers). My question is similar to this one: Multiple markers Google Map API v3 from array of addresses and avoid OVER_QUERY_LIMIT while geocoding on pageLoad
but the big difference is that I only have the place id and not any address. I wish to convert it into an address so that I can use the method showed in the link above from the other stackoverflow method.
So far, I tried using a getJSon method to retrieve the place id url:
$.getJSON('https://maps.googleapis.com/maps/api/place/details/json?placeid=somethingsomething&key=mykey, null, function (data) { var p = data.results[0].geometry.location;
var latlng = new google.maps.LatLng(p.lat, p.lng);
new google.maps.Marker({
position: latlng,
map: map,
});
});
This does not appear to be working as I cannot retrieve the json object due to CORS problems. If I format as a ajax call with JSONP format, it throws a unexpected token error (because the string itself is JSON). Im just looking for a simple way to take place id values, put it into a function, and spit out the formatted address. Thanks!