<script type="text/javascript" src="js/libs/dojo/dojo/dojo.js"></script> <!--version 1.7.1 of the dojo framework is loaded first --> <script type="text/javascript"> <!--then I remap the dojo namespace so that when the arcgis library is loaded it's functions can be called using esridojo instead of dojo --> djConfig = { scopeMap: [ [ "dojo", "esridojo" ], [ "dijit", "esridijit" ], [ "dojox", "esridojox" ] ] }; </script> <script type="text/javascript" src="http://tiney-pie/cma/staging/prototype/js/libs/arcgis_js_api/2.6/"></script>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <meta http-equiv="X-UA-Compatible" content="IE=7,IE=9" /> <!--The viewport meta tag is used to improve the presentation and behavior of the samples on iOS devices--> <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no"/> <title>Custom Dojo Namespace</title> <!-- Load Dojo 1.7.1 from Google CDN --> <script src="http://ajax.googleapis.com/ajax/libs/dojo/1.7.1/dojo/dojo.js"></script> <!-- local version also works... --> <!-- <script type="text/javascript" src="/~dswingley/dojosrc/1.7.1/dojo/dojo.js" ></script> --> <link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/2.7/js/dojo/dijit/themes/claro/claro.css"> <script type="text/javascript"> djConfig = { scopeMap: [ [ "dojo", "esriDojo" ], [ "dijit", "esriDijit" ], [ "dojox", "esriDojox" ] ] }; </script> <script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.7"></script> <script type="text/javascript"> // Dojo library from Google CDN is built in such a way that // it depends on the djConfig global object when loading modules. // But we override it later when loading the JSAPI. // Reset it here so that modules from Google CDN are loaded // properly. // For example: after the page loads, try loading the following // module: // dojo.require("dijit.layout.ContentPane"); // and observe firebug net tab. You should see bunch of modules // loaded from Google CDN. Without the reset below, the first module // loaded will be from Google CDN and its dependencies loaded from // the dojo instance embedded within JSAPI. djConfig = dojo.config; esriDojo.require("esri.map"); dojo.require("dijit.layout.ContentPane"); function init() { var extent = new esri.geometry.Extent(-122.93,47.02,-122.86,47.07, new esri.SpatialReference({wkid:4326})); var map = new esri.Map("map", {extent:esri.geometry.geographicToWebMercator(extent)}); var tiledMapServiceLayer = new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer"); map.addLayer(tiledMapServiceLayer); esriDojo.connect(map,"onLoad",function(map){ var esriVersion = "<b>ArcGIS API for JavaScript version:</b>" + esri.version; var esriDojoVersion = "<b>ArcGIS API for JavaScript Dojo version:</b>" + esriDojo.version; esriDojo.byId('esriInfo').innerHTML= esriVersion + "<br />" + esriDojoVersion; }); } function initDojo(){ dojo.byId('dojoInfo').innerHTML="<b>Google CDN Dojo Version:</b>" + dojo.version; } dojo.addOnLoad(initDojo); esriDojo.addOnLoad(init); </script> </head> <body class="claro"> The following libraries are loaded in this application:<br /> <div id="map" style="margin:2px 2px 2px 2px; border:solid thin #999967;width:500px;height:500px;"> </div> <span id="esriInfo"></span><br /> <span id="dojoInfo"></span> </div> </body> </html>
This is unfortunate as dojo 1.7 has a lot of functionality and bug fixes that I would like to use. It's good to know that it's not just me that's having problems though.
This is supported, and we publish a sample to show how to do it: http://help.arcgis.com/en/webapi/javascript/arcgis/help/jssamples/mapconfig_customdojo.htmlThat being said, I haven't tried this with 1.7. Since 1.7 introduces a new loaded, there might be issues. I'll try to take a look and see if I can get it to work.
Even if you can manage to hack it together and get it to work I don't think it's a good idea. You'll be loading many libraries twice. Esri Dojo 1.6.1 stuff to support their widgets and then whatever 1.7 stuff you load yourself. So you might be loading 2 dijit.form.Textbox or whatever else. If it's a smaller app then it's prob not a problem. If you are doing a larger app the double loading will kill your browser twice as fast, and you will see the dreaded 'script is too large' in your Firebug console.
Can you post more of your code? Do you see the error you mentioned even when you don't load dojo 1.7.1 but still rename the dojo namespace?
You might end up loading modules from dojo's base twice, but unless you dojo.require("dijit.something") and esridojo.require("dijit.something"), you shouldn't be loading additional modules twice. Taking it one step further, and this might be more trouble than it's worth, if you use dojo 1.7's AMD loader, you have to explicitly load everything so you could avoid duplicating modules in dojo base. You would only explicitly require() what you need and duplication would be minimal.
I don't know about that. Sounds like a good way for a programmer to go bald. And I think it would be a nightmare to maintain.
I agree about it being a maintenance nightmare. Using multiple versions of dojo should never be a long term solution. It's feasible for quick, short term prototyping but for anything beyond a proof of concept, I wouldn't recommend it. The old "just because you can, doesn't mean you should" cliche applies.
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.