CEF and Google Maps API

Built a cool app using CEF that you'd like to share with the community? Talk about it here.

CEF and Google Maps API

Postby mrtnlowr » Mon Aug 09, 2021 7:13 am

Hi

Some years ago I built an app with Lazarus/FPC for mapping my field observations. I included a form hosting the fpCEF3 (ver. 3.3029) browser and loaded a small webapp into the browser using a CefBrowserProcessHandler. That webapp loaded the Google Maps API into a <script> element. It has worked with no problems until last week. Now, with no changes to any of the code, it no longer successfully loads the API and all attempts to plot a coordinate result in an 'Uncaught ReferenceError: google is not defined' error. All my attempts to fix the webapp - defer, async and callback - have failed. Strangely when I load the webapp directly into Chrome (92.0.4515.131) it works fine and loads the Maps API.

Not sure what to do next. Any suggestions appreciated.

Martin
mrtnlowr
Newbie
 
Posts: 2
Joined: Mon Aug 09, 2021 4:01 am

Re: CEF and Google Maps API

Postby magreenblatt » Mon Aug 09, 2021 10:34 am

I'm not sure if it will cause your specific error, but usage of Google Maps requires API keys from Google (config for CEF/Chromium described here).
magreenblatt
Site Admin
 
Posts: 12379
Joined: Fri May 29, 2009 6:57 pm

Re: CEF and Google Maps API

Postby salvadordf » Mon Aug 09, 2021 12:40 pm

You need the API keys as Marshall suggested but this issue might also be caused by the old CEF libraries used by fpCEF3 (CEF 3.3029)

Try installing the latest CEF4Delphi component into Lazarus and run the SimpleBrowser2 demo with your webapp to see if using the latest CEF libraries fixes your issue.
Maintainer of the CEF4Delphi, WebView4Delphi, WebUI4Delphi and WebUI4CSharp projects.
User avatar
salvadordf
Expert
 
Posts: 129
Joined: Sun Dec 18, 2016 8:39 am
Location: Spain

Re: CEF and Google Maps API

Postby mrtnlowr » Mon Aug 09, 2021 4:50 pm

Hi Salvador and Marshall,

Thanks for your responses. I already have an API key and use it in the script tag src so that's not the issue.
I downloaded and installed CEF4Delphi and the CEF binaries and compiled the SimpleBrowser2 demo but it doesn't appear on screen although it does appear in Task manager. So I tried the Minibrowser demo instead and that runs fine and it also runs my webapp without issue. Great! I guess I should now read all the CEF4Delphi docs and try updating my browser host form to the new version. I assume all the components and classes have new names and operate differently so it might take a little while to achieve.

Thanks for your help.
mrtnlowr
Newbie
 
Posts: 2
Joined: Mon Aug 09, 2021 4:01 am

Re: CEF and Google Maps API

Postby salvadordf » Tue Aug 10, 2021 3:12 am

Thanks for the bug report! :) Now it's fixed.

This is the official CEF forum but most of the CEF wrappers like CEF4Delphi have a different forum with tons of information about each wrapper.

In CEF4Delphi's case the forum is this one :
https://www.briskbard.com/forum/

Please, read this document too :
https://www.briskbard.com/index.php?lang=en&pageid=cef
Maintainer of the CEF4Delphi, WebView4Delphi, WebUI4Delphi and WebUI4CSharp projects.
User avatar
salvadordf
Expert
 
Posts: 129
Joined: Sun Dec 18, 2016 8:39 am
Location: Spain


Return to Apps Discussion

Who is online

Users browsing this forum: No registered users and 4 guests