How Google Maps Api Key can work in my html? - javascript

I created a site with google maps online (in javascript) .I took an api key from Google Maps, but it doesnt work, because every time i open the browser i receive an image with a message that it cann't load correctly the Google Mps. Do you know, should i have done something with HTTP referrer or with API libraries in Google Map Api's Settings??

Google's new billing and pricing model requires you to add a credit card to use even the free API's. The documentation/tutorial page which shows code examples, will provide a key, however it will not work until you add your billing info.
If you are using the Javascript API for Static Maps, it is no longer free but you can use the $200 monthly credit being offered. It should allow you over 1+ million maps loads per month.
https://cloud.google.com/maps-platform/pricing/sheet/ https://developers.google.com/maps/documentation/javascript/tutorial

Related

How to get the Google Maps directions (route) sharing feature in web application via its Java Script API

I am sorry if this question is not fit for this forum.
I want to get the Google Maps directions (route) sharing feature into my web application via Google Maps Java Script API same like Send directions to your phone on Gogle Maps Directions. Is it possible?
I have searched out but not found any information related to google maps route sharing through Java Script API.If it is possible then please suggest some relevant links or data to impalement it.
Thanks-Hashim
At present time this functionality is not available via Google Maps JavaScript API.
I can see a feature request for this in the Google issue tracker:
https://issuetracker.google.com/issues/35826888
It looks like Google didn't set high priority on this task. Anyway, I suggest adding a star in the feature request to add your vote and subscribe to notifications.

Google Maps Javascript API Usage not showing

I recently (like 4 hours ago) added an api key and enabled billing for Google Cloud Platform so my Google Maps Javascript API wouldn't get blocked at 25,000 places autocomplete requests. I expected to see usage statistics in Google Cloud Platform immediately but still it shows zero usage activity. Am I doing something wrong?
I think you are checking the wrong API.
Try going to Google Places API Web Service : Key features include autocomplete, search, place picker, photos and add place
OR
Google Maps JavaScript API: build and style a map onto your website.
Check the usage statistic of these two API to see the request related to place autocomplete. Hope this helps

Google Places JavaScript API v3, how can I add my API key to requests?

I've got a web application using the Google Maps JavaScript API(v3) and I'm hitting the Places API using the JavaScript version as well.
The Places API documentation, when using HTTPS requests, says that you need to add your Places API key (acquired through the Google API Console). The documentation also says that you must verify your identity with a credit card otherwise you are limited to 1000 request a day. Once verified you are allowed 100 000 requests per day.
There is no documentation, however, that says how to add your API key to the JavaScript object you pass into the google.maps.places.PlacesService.search() method...
My client is very concerned with this daily limit, as the app is a kiosk that will be part of a huge trade show where it's likely that the Places API will be pinged more than 1000 times throughout the day...
Can anyone advise on this? Should I rework the code to use the HTTP request method so I can add the key there? Or is it possible, perhaps, to add the key to my initial load of the Google Maps JavaScript API?
Thanks in Advance,
Grammar.
You can add your API console key when loading the JS API as follows:
<script type="text/javascript"
src="http://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&sensor=SET_TO_TRUE_OR_FALSE">
However, I don't believe the JS Places service is subject to the same limit; it falls under the 25,000 map loads allowed in the v3 API. In addition, to soothe your client's mind, you can note that for the JS API, "In order to accommodate sites that experience short term spikes in usage (eg. a news gathering organisation or a site that briefly goes viral), the usage limits will only be enforced once a site has exceeded the limits for 90 consecutive days." (From the Usage Limits section of the Maps API FAQ)

How to detect that the 25000 request per day limit has been reached in Google Maps?

I'm working on a website using the Google Maps Javascript API v3.
The free version of the API is limited by 25000 requests a day. But what happens if this limit is reached?
Is there a way to detect that the request limit has been reached so a fallback Google Maps Image API map can be displayed instead?
The usage limit is based on site or application, not the client IP address.
You can use the Google API console to monitor your usage if you add an API key to each of your map requests. I have not seen a way to query the usage programmatically.
https://code.google.com/apis/console
Per the comment below by #alds, it does appear that JS Maps API v3 and Static Maps API are separate services, therefore having separate request limits. Falling back to a static Google map image could help.
This also explains the usage limits in better detail:
http://googlegeodevelopers.blogspot.com/2011/11/understanding-how-maps-api-usage-limits.html
You cannot detect via the API that the request limit has been reached. There are no events that are fired and the API does not expose a function or property to determine that the API quota has been reached.
Google has decided that this is not a feature they will implement.
https://issuetracker.google.com/issues/35830575#comment12
#kilogauss I would disagree that falling back to static Google Map is not an option.
According to https://developers.google.com/maps/faq#usagelimits
"Web sites and applications using the Google Maps API may at no cost generate up to 25,000 map loads per day FOR EACH service" (capitalization and boldface mine).
And on https://developers.google.com/maps/faq#usage_pricing, you can see that JS Maps API v3 and Static Maps API are separate services.

When is a Google Maps API key required?

Recently Google changed it's policy on the use API keys. You're now supposed to no longer need an API key to place Google Maps on your website.
And this worked perfectly. But now I have this map (without API key) running on my localhost, which works fine. But as soon as I place it online, I get a popup saying that I need another API key. And on another page on that website, Google Maps does work. Could it maybe have something to do with that the map that doesn't work have a lot (30+) of markers on it?
Actually using an API key wouldn't be a very nice solution to me, as this is part of a Wordpress plugin used on many websites.
Sounds like you're running v2~ time to upgrade, or get a key for the domain you want to run it on:
Google Maps V2 API Key Request
You do not need an API Key to use Goolge Maps API V3. However, we just experienced an issue where Google reported that we had exceeded our limit, even though we didn't (Development Server). I went ahead and set up an API Key, and its actually beneficial, because you then get usage reporting. Also, we haven't seen the false Quota usage problem since then. I thought I would go ahead a share the process:
Goto https://console.developers.google.com/
Click the red 'Create Project' button
Give your project a name and Google will automatically give it an ID
Wait until the Spinny on the bottom says your project is complete.
In the left hand nav, select APIs Under APIs & Auth, and select 'Google Maps JavaScript API v3'
Click the link and then Turn on the API
Go to Credentials under the APIs & Auth section, and click the red 'Create New Key' under the Public API access section. Then click Browser Key.
Make sure you include the star in your Website's name. For example, use mywebsite.com/*. This will ensure all pages are authorized to use the API.
Copy the key into your Javascript reference to the Google Maps API, like so:
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=YOUR_KEY"></script>
Long story short, the key is not required, but best practices would indicate that you should use the key.

Categories