Effectively adding baseLayer to  OverView Map

4401
3
06-01-2011 05:51 AM
AlexanderAnkrah
New Contributor III
Hi Folks,
I have successfully implemented the overview widget, all works great. The only snag is my main map (used in map:map) is a tiled service starting at a particular scale to the lowest zoom level.

And I have a dynamic map which shows on the start of the app and hides at the scale where the tiled map kicks in.

Now by default the overview widget uses the first map "layer" (in my case the tiled map) if no baseLayer parameters are provide - that works fine. Now I want to define a baseLayer such that there're quite literally two maps (the tiles and the  dynamic) for the overview widget.

From the documentations that I have seen, you could do this by simply going

var layer = new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer")

then setting baseLayer:layer

This sometimes works, sometime I get the following error
'wkid' is null or not an object

This I think have something to do with the layer definition for the baseLayer. Can anyone shed more light on this?

Thanks. below is a section of what I have.

dojo.connect(this.GISmap, 'onLayerAdd', jQuery.proxy(function() {        
                   this.afterLoad();
            dojo.connect(dijit.byId("Map_Div"), 'resize', jQuery.proxy(this.resizeMap, this));
        }, this));


afterLoad: function() {

var overviewMapDijit = new esri.dijit.OverviewMap({
    map: this.GISmap,
    baseLayer: layer,
        visible: false,
        attachTo: "top-right",
        expandFactor: 2.5
    });
    overviewMapDijit.startup();

}
0 Kudos
3 Replies
AlexanderAnkrah
New Contributor III
Think I answered my own question there...

I had to wait for the Layer to load.

This I have done by putting the overView widget code in an if (layer.loaded){} function.

thanks
0 Kudos
AlexanderAnkrah
New Contributor III
Right I thought I had this cracked but apparently not!

I sometimes get one of these two errors or both

1. 'esri.bundle.widgets' is null or not an object
2. 'wkid' is null or not an object


Below is my current implementation of the OverView widget. Anything I'm doing wrong?

dojo.connect(this.GISmap, 'onLayerAdd', jQuery.proxy(function() {
            this.afterLoad();
        }, this));



afterLoad: function() {

var overviewMapDijit = new esri.dijit.OverviewMap({
map: this.GISmap,
baseLayer: layer,
visible: false,
attachTo: "top-right",
expandFactor: 2.5
});
overviewMapDijit.startup();

}


I have tried other approaches including the two below but the above errors keep coming up. Any pointers please?

afterLoad: function() {

if (this.GISmap.loaded) {
var overviewMapDijit = new esri.dijit.OverviewMap({
map: this.GISmap,
baseLayer: layer,
visible: false,
attachTo: "top-right",
expandFactor: 2.5
});
overviewMapDijit.startup();
}
else{
//nothing. 
}
}


This other approach just gives errors usual errors (but works in a simple map app!!)

if (this.GISmap.loaded) {
                   var createOverviewMap = function() {
                   overviewMapDijit = new esri.dijit.OverviewMap({
                       map: this.GISmap,
                       baseLayer: layer,
                       visible: false,
                       attachTo: "top-right",
                       color: "#D84E13",
                       width: 300,
                       height: 250,
                       expandFactor: 2
                       });
                       overviewMapDijit.startup();
                       dojo.style(dojo.byId("status"), "display", "none");
                   };

                   if (layer.loaded) {
                       createOverviewMap();
                   }
                   else {
                       dojo.connect(layer, "onLoad", createOverviewMap);
                   }
               }
0 Kudos
AlexanderAnkrah
New Contributor III
0 Kudos