Origin url is not allowed by Access-Control-Allow-Origin with Google Direction API

前端 未结 1 1839
無奈伤痛
無奈伤痛 2021-01-21 18:57

I know this question has already been asked and answered, but it didn\'t help me.

Here is my jQuery code:

var gmapsurl = \'http://maps.googleapis.com/map         


        
相关标签:
1条回答
  • 2021-01-21 19:07

    You should use the Google Maps API for geocoding:

    var geocoder = new google.maps.Geocoder();
    var geocoderRequest = { address: "MountainView, CA" };
    geocoder.geocode(geocoderRequest, function(results, status){
    //do your result related activities here, maybe push the coordinates to the backend for later use, etc.
    });
    

    Instead of calling the service via JSON. You should, of course have this included in your scripts to use Google Maps API:

    <script src="http://maps.google.com/maps/api/js?sensor=false"></script>
    
    0 讨论(0)
提交回复
热议问题