Google Maps from Firefox addon (without SDK) -


i need add map in adddon , know how need in "common webpage", did here: http://jsfiddle.net/hcymp/6/

the problem don't know how to same in firefox addon. tryed importing scripts loadsubscript , tryed adding chrome html next line:

<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script> 

but nothing works. best solution found add part of code in this file (the code of script src) in function, import this file loadsubscript, , function executed empty div returned.

components.utils.import("resource://gre/modules/services.jsm");  window.google = {}; window.google.maps = {}; window.google.maps.modules = {}; var modules = window.google.maps.modules; var loadscripttime = (new window.date).gettime();  window.google.maps.__gjsload__ = function(name, text) { modules[name] = text;}; window.google.maps.load = function(apiload) {     delete window.google.maps.load;     apiload([0.009999999776482582,[[["https://mts0.googleapis.com/vt?lyrs=m@227000000\u0026src=api\u0026hl=en-us\u0026","https://mts1.googleapis.com/vt?lyrs=m@227000000\u0026src=api\u0026hl=en-us\u0026"],null,null,null,null,"m@227000000"],[["https://khms0.googleapis.com/kh?v=134\u0026hl=en-us\u0026","https://khms1.googleapis.com/kh?v=134\u0026hl=en-us\u0026"],null,null,null,1,"134"],[["https://mts0.googleapis.com/vt?lyrs=h@227000000\u0026src=api\u0026hl=en-us\u0026","https://mts1.googleapis.com/vt?lyrs=h@227000000\u0026src=api\u0026hl=en-us\u0026"],null,null,null,null,"h@227000000"],[["https://mts0.googleapis.com/vt?lyrs=t@131,r@227000000\u0026src=api\u0026hl=en-us\u0026","https://mts1.googleapis.com/vt?lyrs=t@131,r@227000000\u0026src=api\u0026hl=en-us\u0026"],null,null,null,null,"t@131,r@227000000"],null,null,[["https://cbks0.googleapis.com/cbk?","https://cbks1.googleapis.com/cbk?"]],[["https://khms0.googleapis.com/kh?v=80\u0026hl=en-us\u0026","https://khms1.googleapis.com/kh?v=80\u0026hl=en-us\u0026"],null,null,null,null,"80"],[["https://mts0.googleapis.com/mapslt?hl=en-us\u0026","https://mts1.googleapis.com/mapslt?hl=en-us\u0026"]],[["https://mts0.googleapis.com/mapslt/ft?hl=en-us\u0026","https://mts1.googleapis.com/mapslt/ft?hl=en-us\u0026"]],[["https://mts0.googleapis.com/vt?hl=en-us\u0026","https://mts1.googleapis.com/vt?hl=en-us\u0026"]],[["https://mts0.googleapis.com/mapslt/loom?hl=en-us\u0026","https://mts1.googleapis.com/mapslt/loom?hl=en-us\u0026"]],[["https://mts0.googleapis.com/mapslt?hl=en-us\u0026","https://mts1.googleapis.com/mapslt?hl=en-us\u0026"]],[["https://mts0.googleapis.com/mapslt/ft?hl=en-us\u0026","https://mts1.googleapis.com/mapslt/ft?hl=en-us\u0026"]]],["en-us","us",null,0,null,null,"https://maps.gstatic.com/mapfiles/","https://csi.gstatic.com","https://maps.googleapis.com","https://maps.googleapis.com"],["https://maps.gstatic.com/intl/en_us/mapfiles/api-3/13/11","3.13.11"],[3047554353],1.0,null,null,null,null,1,"",null,null,1,"https://khms.googleapis.com/mz?v=134\u0026",null,"https://earthbuilder.googleapis.com","https://earthbuilder.googleapis.com",null,"https://mts.googleapis.com/vt/icon"], loadscripttime); };   //i can't use document.write use loadsubscript insthead services.scriptloader.loadsubscript("chrome://googlemaps/content/google-maps-v3.js", window, "utf8"); //chrome://mowa/content/google-maps-v3.js", window, "utf8");  var mapcontainer = window.content.document.createelement('canvas');     mapcontainer.setattribute('id', "map");     mapcontainer.setattribute('style',"width: 500px; height: 300px");     mapcontainer.style.backgroundcolor = "red";  var mapoptions = {     center: new window.google.maps.latlng(latitude, longitude),     zoom: 5,     maptypeid: window.google.maps.maptypeid.roadmap }  var map = new window.google.maps.map(mapcontainer,mapoptions); return mapcontainer; 

can me? i'm developing "firefox android" addon , that's why need things *window.content.*document.createelement because document not declared, window , think thats may problem... can't declare if don't know google maps uses.

added: read google maps api team has specific code disallows copying main script locally. in particular, code "expires" every many hours. i'm combined part of script: https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false because can't execute directly (error: write called on object not implement interface htmldocument). don't have alternative!

use iframe (type=content if in xul) display web content. there can include whatever scripts like. content in iframe not have special privileges, or @ least should not. if need communicate privileged add-on part of code, can use e.g. regular html events (createevent, addeventlistener , friends) or postmessage web api pass messages.

do not try load remote code directly other pages, or worse, browser, compatibility , security nightmare. because loading remote code and/or code not reviewed running in privileged context, platform refuse load such scripts remote sources (http, etc.) via loadsubscript, etc.

should noted, if you'd later host add-on on addons.mozilla.org , still include remote scripts in privileged code, add-on rejected until fix it. also, mozilla might blocklist add-on if host elsewhere if discovered there known security vulnerabilities in add-on, per add-on guidelines.


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

.htaccess - Matching full URL in RewriteCond -