Google Map not showing properly in emulator

62 views
Skip to first unread message

jason...@gmail.com

unread,
Jun 14, 2019, 7:57:26 AM6/14/19
to CodenameOne Discussions
Hi,

I was trying out your map library. I registered for the required API key and applied them to the build hints mentioned in your blogs.

When I run them in the simulator it displays the map properly for the first time. When running again it displays it incorrectly and never did again (see attached image).

It seems to be working on actual device, but its quite annoying with the simulator. Perhaps its something I did wrong, not sure. Can you please advise?

Thanks.

IDE: NetBeans
Simulator
GoogleMap Problem.png

Shai Almog

unread,
Jun 15, 2019, 12:04:43 AM6/15/19
to CodenameOne Discussions
Hi,
the image is unreadable so I can't really see what's going on. Why didn't you use the screenshot mechanism in the simulator?
Did you register a JavaScript map key and pass it in the constructor?
Message has been deleted
Message has been deleted

jason...@gmail.com

unread,
Jun 15, 2019, 7:21:10 AM6/15/19
to CodenameOne Discussions

The screen error is really small because it zooms out despite zooming in.


Basically the top dialog says "This Page cannot load Google Maps correctly:

This is joined by an overlay with an error message "For development purpose only".

I did use a Google Map JavaScript API key in the constructor.

Shai Almog

unread,
Jun 16, 2019, 12:25:59 AM6/16/19
to CodenameOne Discussions
This generally means the id is incorrect, invalid or beyond its quota. Is the google account beyond its billing quota limits?
Do you see something printed in the console?

jason...@gmail.com

unread,
Jun 16, 2019, 5:53:25 AM6/16/19
to CodenameOne Discussions
It is definitely correct. I haven't exceed the quota. Its working on an actual Android device (tested on Marshmallow), just not on CN1 simulator.

When it does work, it is only after 24 hours, but only once and then it gives the problem like I described if you run again.

Shai Almog

unread,
Jun 17, 2019, 12:19:14 AM6/17/19
to CodenameOne Discussions
These are separate keys. You need to have 3 keys each of which is generated separately and has its own quota (thanks google...). In native you're using the native Android key defined in the build hints. On the simulator you use the JavaScript key which you pass in the constructor. It's a key for a web application not for a native application since Google doesn't support native desktop applications the simulator uses a browser component.

jason...@gmail.com

unread,
Jun 17, 2019, 5:44:45 AM6/17/19
to CodenameOne Discussions
What I understand from key generation is that you can restrict one key to the API usage on Google. So, one key could be used on Google Map JavaScript API, Native Android, some other cloud or Map related API and so on. You  can also be crazy and set the key to unlimited API usage. Therefore, isn't it correct that if I restrict key to use on multiple APIs, including JavaScript Map API the key could still work on the simulator browser? Anyway, I tried to restrict they key to just JavaScript and it didn't work.  

Shai Almog

unread,
Jun 17, 2019, 11:40:43 PM6/17/19
to CodenameOne Discussions
That isn't the case. You need 3 separate keys. Just follow the instructions here for the JavaScript key: https://developers.google.com/maps/documentation/javascript/get-api-key
Message has been deleted
Message has been deleted
Message has been deleted

Shai Almog

unread,
Jun 21, 2019, 12:00:17 AM6/21/19
to codenameone...@googlegroups.com
You need 3 keys. You indicated that it "works" on the device. But that's effectively saying "the Android key works". It has no bearing on the JavaScript keys.


On Fri, Jun 21, 2019 at 6:54 AM <jason...@gmail.com> wrote:
So, just to confirm, in order to run a simple example in simulator just to display a Google Map, I need Android, JavaScript and iOS keys, despite me already passing a JavaScript key in the MapContainer constructor, is this what you are saying by those 3 keys?



On Tuesday, June 18, 2019 at 5:40:43 AM UTC+2, Shai Almog wrote:
That isn't the case. You need 3 separate keys. Just follow the instructions here for the JavaScript key: https://developers.google.com/maps/documentation/javascript/get-api-key

--
You received this message because you are subscribed to the Google Groups "CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to codenameone-discu...@googlegroups.com.
Visit this group at https://groups.google.com/group/codenameone-discussions.
To view this discussion on the web visit https://groups.google.com/d/msgid/codenameone-discussions/7f86821f-7c9f-489e-8da4-7087bc2aca72%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages