title: Google Maps from Firefox addon (without SDK)
body: <p>I need to add a map in my adddon and I know how to do what I need in a "common webpage", like I did here: <a href="http://jsfiddle.net/hCymP/6/" rel="nofollow">http://jsfiddle.net/hCymP/6/</a></p>
  
  <p>The problem is I really don't know how to to the same in a Firefox Addon. I tryed importing the scripts with <a href="https://developer.mozilla.org/en-US/docs/XPCOM_Interface_Reference/mozIJSSubScriptLoader#loadSubScript%28%29" rel="nofollow">LoadSubScript</a> and also tryed adding a chrome html with the next line:</p>
  
  <pre><code>&lt;script src="https://maps.googleapis.com/maps/api/js?v=3.exp&amp;sensor=false"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>But nothing works. The best solution I found was to add part of the code in <a href="https://maps.googleapis.com/maps/api/js?v=3.exp&amp;sensor=false" rel="nofollow">this file</a> (the code of the script src) in my function, to import <a href="https://maps.gstatic.com/intl/en_us/mapfiles/api-3/13/11/main.js" rel="nofollow">this file</a> with <a href="https://developer.mozilla.org/en-US/docs/XPCOM_Interface_Reference/mozIJSSubScriptLoader#loadSubScript%28%29" rel="nofollow">loadSubScript</a>, and all my function is executed but an empty div is returned.</p>
  
  <pre><code>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 but 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;
  </code></pre>
  
  <p>Can you help me? I'm developing a "Firefox for Android" addon and that's why I need to do things like *window.content.*document.createElement because document is not declared, only window and I think thats may be the problem... But I can't declare everything if I don't know what Google Maps uses.</p>
  
  <p>Added: I also read that Google Maps API Team has specific code that disallows you from copying the main script locally. In particular, that code "expires" every so many hours. I'm  combined part of this script: <a href="https://maps.googleapis.com/maps/api/js?v=3.exp&amp;sensor=false" rel="nofollow">https://maps.googleapis.com/maps/api/js?v=3.exp&amp;sensor=false</a>   because I can't execute this directly (Error: write called on an object that does not implement interface HTMLDocument). So I don't have any alternative!</p>