Google App Engine: API is not being called in deployed version - javascript

I am building a web app with Google AppEngine. I am using the Google Maps, Google Places, and Geocoding API's.
In the local version, everything works as it should. When the page is loaded, the user's current location is indicated and all the nearby stores are marked with markers on the map that appears on the webpage.
In the deployed version, only the map loads. I checked the console developer's log on Google and I noticed that a request to the Google Maps API is made, but not to the Google Places or Geocoding API's. I'm really confused/not sure what's going on. I tried browsing through some old questions, but I can't figure out how to fix this. If anyone could offer a solution, I would greatly appreciate it.
** I have made sure that the deployed version is the most recent version. It 100% works on localhost, but doesn't on the deployed webpage.
Edit: the API's aren't being called because they don't work on "insecure origins". I've configured the app.yaml under handlers to be
- url: /.*
script: IGNORED
secure: always
but it doesn't seem to make a difference.

You don't have to separately call Google Places and Geocoding APIs. All those are included in the Google Map API. If you want to choose on what you should include in your map click here to refer the API on customizing your map.

By default, Google App Engine doesn't support secure connections, which both the Geolocation & Google Places API's need, in order to be called. However, Google App Engine can support secure connections. The local host does support secure connections, which is why the local version of my app was working.
To properly support secure connections after deploying the app, just add in the parameter "secure: always" in the app.yaml file under Handlers!

Related

Rails using Google Places web API (key not working)

I am trying to use Google Places address autocomplete in a rails app.
I am using this example from google and trying it out on JSFiddle works fine. I change to my API Key and then doesnt work.
I tried in my rails app in development and in production getting the same result.
As soon as i write something the text box freezes and a little 'i' appears. (not clickable)
I created and tried 'browser api key' and 'server api key' with no luck.
I set my domain as requested * .mydomain.com/* and it didnt work
I enabled
- Google Maps JavaScript API
- Google Static Maps API
- Google Maps Embed API
- Google Places API Web Service
- Google Maps Geocoding API
- Google Maps Geolocation API
I added to my layout/application.html.erb file
I am searching through all questions but cant find my case, please help me find a solution or point me in the right direction. Thanks!
Update: In browser console i see
Google Maps API error: RefererNotAllowedMapError https://developers.google.com/maps/documentation/javascript/error-messages#referer-not-allowed-map-error
Your site URL to be authorized: 'mysite'
I have authorized the link exactly as shown in console but its not accepting it.
Solved.
I somehow managed to mix up my API keys in loading 1.&libraries=places and in
2.=initAutocomplete" while I was authorizing my url.
thanks to all specially to #power for reminding me to check the console logs. I know its dumb, but I keep forgetting...

Check Connectivity to Google Maps API (China Great Firewall)

I'm currently working on a platform that will be launched all over the world and I am working in Shanghai China and as you might know there is a very big Firewall policy here.
The site contains a custom map view created with the Google Maps API this is because Google allows a lot of nice features to change the look and feel of the map.
But now I'm running into a problem where if a user wants to access the site without VPN the whole page where the map is located slows down,crashes and breaks my login procedure.
Here are the errors showing in the Console View:
GET https://maps.googleapis.com/maps/api/js?key=1010101010101&sensor=true net::ERR_CONNECTION_TIMED_OUT
Uncaught ReferenceError: google is not defined
I want to know if there is a way to check if I have a connection to the Google Maps API before executing the code?
Cheers,
Koen
Checking if the API is loaded, as Keith links above, is a good way to see if the loading has had any trouble.
To minimize problems loading the API in China the Maps API FAQ recommends loading the API from http://maps.google.cn/maps/api/js and not using https.

Use of Google Maps JavaScript API v3 in PhoneGap iOS App

I'm experiencing a problem in using the Google Maps JavaScript API v3 for a Cordova PhoneGap based iOS App which, up until a few days ago, was working fine.
As I'm not an Objective-C developer I've purposely picked the Google Maps JavaScript API v3 over the iOS Maps SDK and have, in the Google Developers console, created a project and associated a browser key (set to enable all referrers) with that project.
In the head of the HTML page in my PhoneGap App I have called the Google Map API like so:
https://maps.googleapis.com/maps/api/js?key=MY_APPLICATION_KEY_IS_PASTED_HERE&sensor=false
But when I run the App, despite this having worked without a key in previous versions and now having created a browser key and associating that as part of the call to the Google Maps API, I get the following error message:
Google has disabled use of the MAPS API for this application. The key provided is not a valid Google API key or it is not authorised for the Google Maps JavaScript API v3 on this site.
Can anyone provide any suggestions on what I might be missing/doing wrong and what I could possibly do to resolve this as I need to get the App running again. I've looked through the Google Maps and Developer documentation but can't see anything that would alert me to what I might be doing wrong.
Thanks in advance for any help that anyone out there might be able to provide with this query.
I had the same problem. Solved it by setting up a key as per instruction here:
https://developers.google.com/maps/documentation/javascript/tutorial#api_key
BUT setting the "Referrers" to [NOTHING].
KEY NOTE: I had set it explicitly to "*" and this did NOT work and then edited it beck to be empty. I can't believe the edit back to nothing is necessary but...the default was already blank so and did not initially work so ... maybe try the explicit "edit" to blank if all else fails.

Getting Google Analytics to see a test server

I have a conceptually simple problem involving Google Analytics and Tomcat, but I cannot solve it.
We have Google Analytics set up for our production machine and it is working fine. I want to set up a Google Analytics account to monitor our test system so I can test various features without affecting/polluting our production data. I have a test system set up, and a test Google Analytics account. However, the test Google Analytics account never receives data from the test system.
From my investigation, it appears that the problem is that my test system is being referred to as "localhost" instead of "test.mycompany.com" and the document.domain property used by Javascript is therefore "localhost" instead of the "test.mycompany.com" URL that it should be. This is causing the Google Analytics cookies to be written incorrectly (I think) and therefore the Google Analytics Javascript code is never sending data to my Google Analytics account.
Is there any way to set this "document.domain" property in Tomcat 6 so that this system will think it is "test.mycompany.com" instead of "localhost"?
I have examined both the Tomcat docs and the Google Analytics docs, but neither of them address this point directly.
Any help would be appreciated.
Open your firewall on the test server so google can access it and use add this in the snipet
_gaq.push(['_setDomainName', 'none']); //has to be place before _trackPageview
also open your firewall for ga
https://ssl.google-analytics.com/__utm.gif
http://www.google-analytics.com/__utm.gif
and
http://www.google-analytics.com/ga.js
So, port 80 for HTTP, port 443 for HTTPS and the site(s):
ssl.google-analytics.com
www.google-analytics.com
See stackoverflow.com/questions/9738815/google-analytics-gif-request-not-sent/9741228
Google Analytics doesn't send the tracking GIF for localhost, unless
_gaq.push(['_setDomainName', 'none']);
is added before the _trackPageview

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.
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.
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:
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
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.

Categories

Resources