Chrome APP: google maps, Download script denied because it violates the following content security policy directive

I am trying to include a google map in my chrome application (not extension, APP ).

When I launch the application, I see the following exception: Refused to download the script ' https://maps.googleapis.com/maps/api/js?libraries=places ' because it violates the following content security policy directive: "default-src" self "blob: file system: chrome-extension-resource:". Note that 'script -src' is not explicitly set, so 'default-src' is used as a backup.

I know this is a content security policy issue, but the following line in my manifest file does not work: "content_security_policy": "script -src 'self' 'insecure-eval' https://maps.googleapis.com ; object-src ' self '' unsafe -eval '"

It works to expand but not for the application. If I try to add this line to my application manifest, I get the following: "content_security_policy" is only allowed for extensions and deprecated packaged applications, but it is a bundled application.

Has anyone been able to turn on google map display in chrome app?

+6
source share
1 answer

You cannot load external scripts in a Chrome batch application. Instead, you should have an iframe in the main html document pointing to an isolated HTML document that can have a link to the Google Maps script that you need (as well as the #map div and the logic to initialize it).

See this sample isolated HTML file inside iframe: https://github.com/GoogleChrome/chrome-app-samples/tree/master/samples/sandbox

Also, be sure to check out this document: https://developer.chrome.com/apps/app_external#external to customize the manifest

+1
source

All Articles