Why does my custom Google Map no longer function? - google-maps

I have built a custom google map using their Maps JavaScript API and Places API. It's worked fine for several months but now when I try to access the map, I get the "Oops something went wrong" error and receive the following message in Chrome's Console.
https://developers.google.com/maps/documentation/javascript/error-messages#invalid-key-map-error
When I click on that link it tells me that "The API key included in the script element that loads the API is not found." I log into my Google Maps Dashboard and the API key is still there.
Do these expire? Do I need to periodically create new keys?

I found the problem. It had nothing to do with either my API key or my billing account. The problem was due to where I had the &libraries=places parameter in my <script... statement.
This fails:
<script async defer src="https://maps.googleapis.com/maps/api/js?libraries=places&key=MY KEY IS HERE&callback=initMap"> </script>
This works:
<script async defer src="https://maps.googleapis.com/maps/api/js?key=MY KEY IS HERE&libraries=places&callback=initMap" async></script>
If I place the libraries=places parameter after the API key parameter, it works fine. But if it's placed before the API key parameter, it fails with the "The API key included in the script element that loads the API is not found." error.
I can see that I had originally malformed the <script... statement, but it used to work that way, with the libraries=places parameter before the API key parameter - ran for months, no problems - but a few days ago it started throwing this error.
I thank both of you for taking the time to answer me.

Related

404 error when deploying a Google Apps script via the REST API

I'm trying to deploy a Google Apps script via the Google REST API, and I'm using the API Explorer to perform that.
This is the method I am testing:
https://developers.google.com/apps-script/api/reference/rest/v1/projects.deployments/create
Executing the method via the API Explorer returns a 404 error. I have verified that the scriptId in question does exist, and have tried several other scriptIds, to no avail. I have also made sure the permission scopes are properly set.
This is what the API Explorer gives me.
Worth mentioning that the same scriptId works when calling another method such as projects.get.
Is there anything I am missing, or is this an issue on Google's end?
In case of the latter, what are the steps to contact Google Apps Script's team and inform them of this issue?
Your versionNumber is incorrect. The Requested entity here refers to the version of your script. You need to go to File>Manage Versions>Save New version to create a new version(or create one with the api1) and use that version number in the request body.
Check your authorization scopes. You need to have the following scope enabled:
https://www.googleapis.com/auth/script.deployments
If its not in the list of available scopes in API Explorer then you'll need to add it manually (there is an area at the bottom of the authorization dialog where you can add scopes).
Google's API Explorer uses API keys to authorize requests. In some cases an API key is not sufficient and an OAuth2 (bearer) access token is required. As an alternative you can create an Apps Script project and add the appropriate scopes via the manifest file(appsscript.json). Then you can use UrlFetchApp.fetch() to test the API directly.

Google Map API key expires

I have generated a Google Map API Key using Google console and currently that has 'None' restriction. It works fine and I am able to consume Google Places API without any problem. I am using Ionic framework and my application is purely based on HTML and AngularJS (JavaScript).
Now as my key works as expected for some duration, it stops working all of a sudden after sometime. Google service returns 'UNKNOWN ERROR' as response for all calls. To resolve this I need to generate another key and without code changes everything works fine. I have used URL https://maps.googleapis.com/maps/api/js?key=AIzaSyDgM6rXXXXXXXXXXXXXXXXXXXXTA68vY5g&callback=&libraries=places and pasted it in browser and copied the content of the generated JavaScript in a file and referring it locally. Also FYI, I don't have any server side code with me.
Now I have precisely 2 questions.
Do I need to change my Google API key every week to keep it active? Or once the restriction is set to 'Android' or 'HTTPS' then the key will work as long as I want?
If I publish my app in Android store is it safe to place the Google API Key in app files (JavaScript or HTML)? Is there a better way of doing it? Google best practices says we should keep it outside root, but then how should I do it?
You might not have billing enabled on your project.
Without billing enabled you only get 1,000 free requests per 24 hour period (calculated as the sum of client-side and server-side requests).
After you enable billing you get up to 150,000 requests per 24 hour period free of charge.
It might be slightly confusing that JS API Places library usage counts against the Places API limit, but that is the case: the daily usage is calculated as the sum of client-side and server-side requests combined.

Reverse geocoding

I have a worker (servlet) called by a queue in google app engine.
I can call an external URI for reverse geocoding like: http://nominatim.openstreetmap.org/reverse?format=xml&lat=51.0475&lon=3.5323&zoom=18&addressdetails=1
But when I try to call the "The Google Geocoding API" with/without the key parameter: http://maps.google.com/maps/api/geocode/json?latlng=51.0475,3.5323&sensor=false, I always get the following message: Attempt to access a blocked recipient without permission. (mapped-IPv4)
The billing is active, the key is also defined in the dev console, and the URL with the key work in my browser but not from app engine.
Any ideas? Thanks
to avoid the issue, i don't use anymore the org.apache.http.client package but now i use the com.google.appengine.api.urlfetch package.
Now the URI to google also work
thanks

Bogus "This web site needs a different Google Maps API key" with STATIC image map api

Starting from recently, any request I try to get a static image from the Google Static Map API gets this text response:
This web site needs a different Google Maps API key
According to documentation https://developers.google.com/maps/documentation/staticmaps/#Limits
Note that the use of a key is not required, though it is recommended. Examples in this document do not include the key parameter so that they will work for all users who cut-and-paste the code.
Has this changed and did they forget to document it? There's a warning at the doc page that says the usage limits have changed (though then the usage limit that are claimed are the same as before!!) but it doesn't say that the use of an API key has become required.
If I had hit the usage limit, which I certainly haven't, then I would (or should) get a different response, as I experienced in the past.
The exact same requests used to work until recently.
Can anybody clarify?
Example request:
http://maps.google.com/staticmap?center=45.54309129999999,-73.62077841957398&zoom=16&size=480x360&maptype=mobile&markers=45.54309129999999,-73.62077841957398&sensor=false
I appears you are using an old URL for V1 (whose deprecation period has ended), for V2 it has to be:
https://maps.googleapis.com/maps/api/staticmap?center=45.54309129999999,-73.62077841957398&zoom=16&size=480x360&maptype=hybrid&markers=45.54309129999999,-73.62077841957398&sensor=false&mobile=true

Google Maps API Key alert

I have a problem with my Google Maps API key. I get an alert saying "This web site needs a different Google Maps API key." When I prees OK to the alert the map are loading and working fine.
The same problem is already posted:
Google Maps API key not working
I have tried to request the API key for both "http://www.domain.com" and "http://domain.com" but I still get the alert.
When I follow the instructions from their FQA and use alert(window.location.host) I get www.domain.com but the api key generator will only accept the domain if the prefix is http://
Does anyone have a solution to this?
I found out that is was a generel encoding error in my google maps api script tag. I got the alert error when I had a script tag like this:
<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=MyGoogleMapsApiKey" type="text/javascript"></script>
The problem here is the duplicated amp;wich was generated from a scriptmanager in asp.net. So the & was replaced with &.
The script tag should look like this:
<script src="http://maps.google.com/maps?file=api&v=2&key=MyGoogleMapsApiKey" type="text/javascript"></script>
So if you are using a scriptmanager to add script tags or in any other way dynamically adding script tags to your pages, wach out for duplicated amp;.
You have to sign up for the new google API key for your new domain, I used to get the same error message, because I use the old API with the new domain, please click the following link to register your new API key for the new domain.
http://code.google.com/apis/maps/signup.html
Hope this can help.
Vutha
I had the same problem. I remembered that Google calls my Appspot app by a different name found in the Versions area of the App Engine Dashboard. I changed the name of the URL to the long version and the key started to work... e.g. LIVE URI... http://5.latest.myappname.appspot.com.
You'd think they could resolve their keys to their own app hosting service urls.
Regards,
John