Native Map object does not work on Android

@Rob: could you please try one more time with the zip file I sent (with my map key)? I have removed all restrictions from it in the Google dashboard, just curious if that changes anything for you.

UPDATE: I just found this in the Android logfile:

01-05 20:46:38.290 31943 31943 I chromium: [INFO:CONSOLE(50)] "Google Maps JavaScript API error: RefererNotAllowedMapError

01-05 20:46:38.290 31943 31943 I chromium: https://developers.google.com/maps/documentation/javascript/error-messages#referer-not-allowed-map-error

12-30 20:46:38.290 31943 31943 I chromium: Your site URL to be authorized: __file_url__//data/user/0/[my package name]/cache/.system/resources/corona_map_view2.html", source: https://maps.googleapis.com/maps/api/js?v=3.9&sensor=false&key=[my map key] (50)

On the credentials page of the Google Cloud Platform, you can apply restrictions. I had my restrictions set to “Android apps”, but I now understand that a Corona app is not an “Android app” in this sense since it uses a web view for displaying the map. Therefore, I must instead apply restrictions for “HTTP referrers (website)”.

Since your key worked in my app you either have no restrictions on your key, or you have entered a “HTTP referrers (website)” restriction. Can you please confirm that? If so, is the URL that you entered really " __file_url__//data/user/0/[my package name]/cache/.system/resources/corona_map_view2.html"?

It now works with your Maps API key

Rob

Ok, great, then it was the applied restrictions…

One last question: what did you enter under “HTTP referrers (website)”? Was it " __file_url__//data/user/0/[my package name]/cache/.system/resources/corona_map_view2.html" like it said in the logfile I quoted or was on some other format?

I don’t remember entering anything.

If so, your key is “unrestricted” and could potentially be used by someone else. At least according to the instructions at the google cloud platform website where the keys are handled. Since Corona apps do not have a url request per se even though the request comes from a web view, I will have to let google support help me on what url to enter “HTTP referrers (website)”.

@Rob & agramonte: thank you so much for your help, I really appreciate it!  :slight_smile:

@Rob:

Just got this from google support regarding the logfile I sent them:

The “RetiredVersion” means that the application is making a request to a version of Google Maps JavaScript API that is already retired. A way to fix this is to replace the version in the request URL. The request URL can also be found in the logs that you have sent:

https://maps.googleapis.com/maps/api/js?v=3.9&sensor=false&key=[your_map_key]

The v=3.9 is not an updated version. But, this has to be fixed by the Corona team, since they are the ones who set that up.

Another error says “SensorNotRequired”. This means that the request URL is also using a deprecated parameter which is “sensor”. This parameter is no longer working and should no longer be used. This can also be fixed only by the the Corona Team.

In other words: the request that Corona is making to Google Maps uses partly deprecated or non-supported parameters. This has got nothing to do with my error, this is the same for everyone using Corona.

Could you please forward this to your engineers?

UPDATE:

In case anyone wonders, this is the url that should be filled out with the “HTTP referrers (web sites)” choice:

__file_url__//data/user/0/[your package name]/cache/.system/resources/corona_map_view2.html

This could be a bit tricky if Corona ever decides to change the name of the html file. In that case, the request will not be valid and no map will be displayed…

I would suggest trying https://marketplace.coronalabs.com/corona-plugins/map-plugin , it’s easy to develop using Corona Simulator.

Thanks or the tip! Just curious: is the map displayed in a web view? Who is the content provider, Google, Apple or someone else?

@Divergent Monkey, I don’t believe either of those URL parameters are causing an error. I agree that they are old and not doing anything, but they shouldn’t be causing any harm either.

I’ve raised it with engineering, but I’m not sure what the priority will be on fixing it. Since we’ve gone to an open source model, we also are now using GitHub issues to track these types of bugs. Can I get you to visit:  https://github.com/coronalabs/corona/issues

And file an issue for this. Perhaps if we can’t get to it in a timely fashion, a community developer who wants to contribute to Corona can look into it.

Rob

@Rob:

True, they don’t cause any problems (confirmed by Google support) but if possible, they should be fixed just for the sake of keeping Corona up-to-date. I have creted an issue at the GitHub page. Thanks!

FYI: https://github.com/coronalabs/corona/issues/8