English 中文(简体)
What s the API Key for in Google Maps API V3?
原标题:

In the older version of the API, I d have to insert the javascript into the page using something like this for just basic functionality to work:

http://maps.google.com/maps?file=api&v=2&key=GoogleMapsAPIKey

Where I had to configure the API key for each individual site. Looking at the documentation, it says to get a basic map working I just need this:

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

Where does the API key fit in? Do I need to worry about it if I just plan on using a basic map and marker and none of the more advanced functions?

I m also testing on localhost, but the FAQ says I still need to register a key for it, which I haven t done and it still works.

最佳回答

As of June 22, 2016 Google Maps V3 no longer supports keyless access so you need to get a key for every (referrer-)domain which has never had a Google Map on it before.

Get your key here: https://developers.google.com/maps/documentation/javascript/get-api-key

and append it to the URL of the script like so:

<script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY" type="text/javascript"></script>

If you do not provide an API key you will see this warning instead of your rendered map:

Oops! Something went wrong. This page didn t load Google Maps correctly. See the JavaScript console for technical details.

and your browser s console will tell you the reason:

Google Maps API error: MissingKeyMapError https://developers.google.com/maps/documentation/javascript/error-messages#missing-key-map-error

Google Maps API error: MissingKeyMapError https://developers.google.com/maps/documentation/javascript/error-messages#missing-key-map-error

问题回答

Whilst it is true that V3 of the Google Maps API does not require an API key, it is there for a reason. Google recently introduced the following usage limits:

Web sites and applications using each of the Maps API may at no cost generate:

  • up to 25,000 map loads per day for each API
  • up to 2,500 map loads per day that have been modified using the Styled Maps feature

In order to monitor usage an API key is necessary, as the developer notes make clear:

All Maps API applications should load the Maps API using an API key. Using an API key enables you to monitor your application s Maps API usage, and ensures that Google can contact you about your application if necessary. If your application s Maps API usage by exceeds the Usage Limits, you must load the Maps API using an API key in order to purchase additional quota.

So whilst you don t need to have an API key it is useful if you want to monitor your usage and also required if you buy additional usage quota.

V3 of the Google Maps API does not require an API key. So you re good to go.

Edit: In the time since I answered this question Google released support for API keys in v3, letting you see usage of your API site in Google s developer console. The original answer is still accurate: API keys are not required, but they are now recommended.

Under Google Map s Api s choose Google Maps JavaScript API Enable the Api. Go to credentials section.Choose create Credentials. choose API Key from the popup,and then choose browser key from the proceeding popup. .

6.Replace the YOUR_API_KEY with your own api key obtained

You can t use google maps in Android app unless you create a google map key. You need to use keytool to generate MD5 and use that to generate google map key on google map website. keytool should be located on your computer where you have sdk installed. I have generated developer google map key, and I have noticed that key is only good for developing Android app on that particular computer. If you are going to develop Android app on an another computer then you need to generate another google map key for that computer. If you don t see a google map on your Android app but rather you see a grid, this could mean that your google map key is invalid.





相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签