1

In my application was failing several connections to my webservice, I found the way to solve it through a plugin, Cordova-plugin-whitelist. However, adding this plugin I had some problems with google maps and not loaded.

my index.html

<meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'">

Error :

Error: undefined is not an object (evaluating 'google.maps.event.addDomListener')

Removing the meta parameter, all the maps loaded correctly.

LeftyX
  • 35,328
  • 21
  • 132
  • 193
NHTorres
  • 1,528
  • 2
  • 21
  • 39

1 Answers1

0

You're only allowing to load resources from the same origin: self.

script-src 'self'

You might want to read what the cordova plugin white list has defined.
Another source of information can be found here where every single chunk of value is explained in a very clear way.

I would change your meta allowing a few urls to be loaded. Try to change it like this. It should work:

<meta http-equiv="Content-Security-Policy" content="script-src 'self' https://maps.googleapis.com/ https://maps.gstatic.com/ https://mts0.googleapis.com/ https://mts1.googleapis.com/ 'unsafe-inline' 'unsafe-eval'">

Other interesting articles on the topic can be found here and here.

LeftyX
  • 35,328
  • 21
  • 132
  • 193
  • This does not work for me, I get these errors: Error: undefined is not a constructor (evaluating 'new google.maps.Map(el, {})') and ionic.bundle.js:20299 Error: undefined is not a valid argument for 'instanceof' (evaluating 'markerOptions.position instanceof google.maps.LatLng') – NHTorres Jun 09 '15 at 16:08