dpdearing/android-gps-emulator

Google Maps API error: MissingKeyMapError

Closed this issue · 9 comments

Hello,

I'm unable to display map and the console output give me:

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

Is there a way to specify a google maps api key ?

I can't reproduce the error with a fresh download of the war file. Are you running from the war or the source code?

No API key should be needed if running on localhost. Otherwise you will need to create an API key and update the code yourself. See https://developers.google.com/maps/documentation/javascript/get-api-key

An API key can be added when loading the Maps API script at

<script src="https://maps.googleapis.com/maps/api/js" async defer></script>

Same here...

@thiagotalma Can you give more details? Are you running on localhost?

@dpdearing
I was able to understand that the problem only occurs when the default port is changed.

When access is through localhost:8080 I have no problem with the key.

It is worth highlighting this in the documentation.

Taking advantage of the contact, could you clarify a question, please?
Does this only work in emulators? Can not run using adb via USB on a device?

I`m have also this problem.

Google map reqiured API key.

Hi I seem to be having the same problem as the others, I personally am using localhost with the default port. There is no issue with the program authenticating to the emu and establishing a telnet connection. However when I load the web ui this (1) message appears from google, when clicking the "do you own this website" link it takes me to this page: https://developers.google.com/maps/documentation/javascript/error-messages?utm_source=maps_js&utm_medium=degraded&utm_campaign=keyless#api-key-and-billing-errors

Please advise.

(1) https://imgur.com/a/yLb6XG4

@panaceya and @Neomeister2077, do you see the same behavior as @thiagotalma about only having a problem when using a non-default port? (#18 (comment))

In that case you may need to set your own API Key as I noted in #18 (comment), or maybe Google changed something in the API that requires an API Key for everyone.

It's open source and I don't have a convenient configuration for testing this out, but feel free to submit a solution if you find one!

or maybe Google changed something in the API that requires an API Key for everyone.

Yup, Google Map with no API key is not permitted anymore, -1 to Google.

So, how to fix?

I am not submitting a PR cause I am lazy to fix it, however you can fix it by:

  1. Editing the file in src/main/webapp/gpsemulator/index.html
  2. Change the map js from <script src="https://maps.googleapis.com/maps/api/js" async defer></script> to <script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&callback=initMap" async defer></script>
  3. Do the usual stuff (command line do mvn ... and java ...)

But I don't want to create a google map key D:

Here my google map key :P
AIzaSyBqPKkQya1l2z
combine above below
sb0vFGysIOxcz6udDOoCg

I have restricted the above to only work on the following websites:

http://localhost:8888/*
http://127.0.0.1:8888/*

Still, be gentle when using my key D: Cheers for the great software!

Thanks @NgSekLong! I've been playing around with a way to store the API key in a local text file so that it's easier to create drop in each user's own key, but that's still kind of a hassle. Just dropping in a key with limitations as you suggest is probably the easiest solution in the short term.