ReferenceError: google is not defined

后端 未结 4 1287
孤城傲影
孤城傲影 2020-12-16 16:11

I use google map\'s api in my website to show couple of locations. Google Maps is working just fine in my local solution but not in my website. I changed this source

相关标签:
4条回答
  • 2020-12-16 16:15

    Owing to the fact that my website uses https for the connection, I can not use http://maps.google.com/maps/api/js?sensor=false. When I debug the whole page, this link says: Warning : The page index.html ran insecure content. so I made another search on google and came across to this question. so what basically causes a problem is not using https link in the source part so the correct link will be (for me)

    https://maps.google.com/maps/api/js?sensor=false
    

    now everythnig works just fine!

    0 讨论(0)
  • To me, with the new Google Maps API, simply this solution worked: Just omit "async defer" from the script provided by goolge:

    <script async defer src="https://maps.googleapis.com/maps/api/js?key={your_key}"></script>
    

    TO

    <script src="https://maps.googleapis.com/maps/api/js?key={your_key}"></script>
    
    0 讨论(0)
  • 2020-12-16 16:29

    i met this problem in the rails application.

    request to googlemap was from http and https pages

    and it solved:

    = javascript_include_tag "//maps.google.com/maps/api/js?sensor=false"
    

    if protocol not defined rails inserts automatic

    0 讨论(0)
  • 2020-12-16 16:32

    That's an old URL. If you look at the examples from the documentation, almost all of them use:

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