Bing maps on Cordova -


i have been trying implement bing maps in cordova app have been unsuccessful in it.

the bing mas doesn’t load , throws exception : “0x800a1391 - javascript runtime error: 'microsoft' undefined"

same goes google maps too. says “0x800a1391 - javascript runtime error: 'google' undefined"

any pointers?

<!doctype html> <html> <head>     <meta charset="utf-8" />     <link rel="stylesheet" type="text/css" href="css/index.css" />     <script type="text/javascript"             src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0">     </script>     <script type="text/javascript" src="js/index.js"></script>     <title>bing maps</title> </head> <body>       <div id="divmap" style="width:100%; height:92%;    position:absolute; left:0px; top:55px;" onload="getmap();"></div> </body> </html>   <script>      function getmap() {            microsoft.maps.loadmodule('microsoft.maps.themes.bingtheme', {             callback: function () {                 map = new microsoft.maps.map(document.getelementbyid('divmap'),                 {                     credentials: "<bing map key>",                     maptypeid: microsoft.maps.maptypeid.road,                     enableclickablelogo: false,                     enablesearchlogo: false,                     center: new microsoft.maps.location(47.603561, -122.329437),                     zoom: 10,                     theme: new microsoft.maps.themes.bingtheme()                 });             }         });     }  </script> 

check out: http://www.html5rocks.com/en/tutorials/security/content-security-policy/

the new cordova 5 security model prevents loading , execution of script non-local source, need add header tag allow cordova load scripts particular source

 <meta http-equiv="content-security-policy" content="default-src 'self'; script-src 'self' http://ecn.dev.virtualearth.net; data: gap: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *"> 

most importantly

script-src 'self' http://ecn.dev.virtualearth.net;  

that allows u load script locally(self) , virutalearth.net site


Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -