So I've tried using the Places Library from the Google Maps Platform, but I've been getting incorrect results when doing more than one request on locations near me. Basically, my code is trying to find nearby basketball courts based on a latitude and longitude. I've been getting the CORS error and I've been using a Chrome extension to get around it as a temporary fix (and it works fine). Now, I'm trying to set the headers to Access-Control-Allow-Origin: * to try and get around the error. The header info is likely not doing this correctly. My code is below (I want to keep using json and not jsonp because I saw that it's not as safe to use).
bask_preqdata = {
key: myKey,
radius: radi,
location: lati + "," + longi,
keyword: "basketball court",
headers: {'Access-Control-Allow-Origin': '*'}
}
$.get("https://maps.googleapis.com/maps/api/place/nearbysearch/json?", bask_preqdata,
function placeData(data) {
gotPlaceData(data);
},
"json");
I'm trying to stick to the $.get call format. I've tried the $.ajax(settings)... call with the modified headers but it also didn't get around the CORS error. Any help would be greatly appreciated!