Google Maps v3 api for localhost not working

后端 未结 3 2094
庸人自扰
庸人自扰 2020-12-05 01:47

I wanted to try out a sample demo of implementing Gmaps v3 and tried out this example from Google\'s documentation, but there is no output , the page just loads for a few se

相关标签:
3条回答
  • 2020-12-05 02:24

    First of all: Google Maps 3 does not need an api key anymore, so you are fine with

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

    as an URL.

    (As Jeff Hoye pointed out, as of June 22, 2016, an API Key is required again.)

    And then you forgot the "new" in this line:

    var map = new google.maps.Map(document.getElementById("map-canvas"), mapOptions);

    With those changes your map will be displayed.

    0 讨论(0)
  • 2020-12-05 02:25

    it's very easy! in the new API code, you should enter your referrers. So for your localhost test:

    LEAVE IT EMPTY

    here is also the google api explanation:

     Accept requests from these HTTP referrers (web sites) (Optional)
     Use asterisks for wildcards. 
    

    If you leave this blank, requests will be accepted from any referrer.
    Be sure to add referrers before using this key in production.

    0 讨论(0)
  • 2020-12-05 02:27

    Without an API Key now Google Maps does not work... reference: https://console.cloud.google.com/apis

    0 讨论(0)
提交回复
热议问题