0

While requesting nearby place api it gave me cors error then I added JSONP in request

$.ajax(
    {
        url:"https://maps.googleapis.com/maps/api/place/nearbysearch/json? 
        location="+city_lat+","+city_lon+"&radius=500&type=restaurant&key=********", 
        type: "GET",   
        dataType: 'jsonp',
        cache: false,
        success: function(response){                          
            alert(response);                   
        }           
    });

above code i used to hit google map api

response error:- {
   "html_attributions" : [],
   "results" : [
      {
         "geometry" : {
            "location" : {
               "lat" : 37.1294494,
               "lng" : -84.0838904
            },
            "viewport" : {
               "northeast" : {
                  "lat" : 37.1307232802915,
                  "lng" : -84.0826656697085
               },
               "southwest" : {
                  "lat" : 37.1280253197085,
                  "lng" : -84.08536363029151
               }
            }
         },

I have used ajax request first time it gave me cors error therfore i have used jsonp.so how should I request google maps nearby api.

Graham
  • 7,431
  • 18
  • 59
  • 84
I_Tech_Avi
  • 23
  • 4

0 Answers0