1. You cannot close the window without getting errors.
2. You cannot add the map to a widget created from the CDN.
This snippet address #1 by wrapping the esriDijit.findWidgets to only return defined widgets:
(function () {
var findWidgets = esriDijit.findWidgets;
esriDijit.findWidgets = function (x) {
var r1 = findWidgets(x), r2 = [];
for (var i = 0; i < r1.length; i++) {
if (r1[i]) r2.push(r1[i]);
}
return r2;
};
})();
Widgets created outside of the esriWidget scope are null in the original result. Without this patch the calling code will fail when attempting to operate on the null values.
I don't have a clean solution to the second problem but it is possible as long as you clean-up the ESRI widgets before the CDN widgets. In my case I added the map to layout control:
var mapNode = esriDojo.doc.createElement("div");
mapNode.id = "map";
var containerNode = new esriDijit.layout.ContentPane({ title: "ESRI Map" });
containerNode.setContent(mapNode);
dijit.byId("tabs").addChild(containerNode);
var esriMap = new esri.Map("map", { extent: extent });
To avoid errors on closing the window clean up the widgets:
esriMap.destroy();
dijit.byId("tabs").removeChild(containerNode);
containerNode.destroy();
Related links:
No comments:
Post a Comment