Two Bugs with Basemap Gallery

981
6
08-29-2011 06:10 AM
by Anonymous User
Not applicable
Original User: Steaks

The first bug occurs sometimes while switching between Bing base maps.  If you cycle through them fairly fast the map will stop updating.  Sometimes it happens right away, other times it can take up to a minute of switching the maps until it stops working.  I wish I could narrow it down more and find out how its actually happening. You can test it here http://help.arcgis.com/en/webapi/javascript/arcgis/demos/widget/widget_basemap.html.  Firebug returns this message when it happens.

uncaught exception: [Exception... "Component returned failure code: 0x80004003 (NS_ERROR_INVALID_POINTER) [nsIDOMHTMLDivElement.removeChild]" nsresult: "0x80004003 (NS_ERROR_INVALID_POINTER)" location: "JS frame :: http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.4 :: <TOP_LEVEL> :: line 48" data: no]


The second bug is minor.  While switching the maps programmatically using the select method the orange border around the thumbnails inside the widget does not update.
0 Kudos
6 Replies
by Anonymous User
Not applicable
Original User: jeff.pace

I cant comment on the first, i can not see a cause for "rapidly" switching basemaps.

However, on the second, we have noticed this as well.  We have to do a

                 dojo.removeClass(dojo.byId(  this.layerIds[this.baseMapGallery.getSelected().title]), "esriBasemapGallerySelectedNode");
                 this.baseMapGallery.select(this.layerIds[this.prevMap].replace("galleryNode_",""));
                 dojo.addClass(dojo.byId(  this.layerIds[this.prevMap]), "esriBasemapGallerySelectedNode");

to remove the selection css, select, then add the css to the new one.  Not ideal, but hey.
0 Kudos
DavideLimosani
Occasional Contributor II
Sorry if I resume this thread, but I think that the first problem is not as irrelevant as someone may think. If you are pointing on services hosted on arcgisonline.com the problem is a minor problem because you have to switch very rapidly to cause the error (see for example http://help.arcgis.com/en/webapi/javascript/arcgis/demos/widget/widget_basemapManual.html on firebug appears the error "this._map is null" switching between the two basemaps).

However if your services are hosted on a slower server the problem occours more frequently. For example I am experimenting the use of a loading icon with the base map gallery, connected through   

dojo.connect(map, "onUpdateStart", showLoading);
dojo.connect(map, "onUpdateEnd", hideLoading);

If the "this._map is null" error appears the events are not triggered anymore and the icon stays on the screen.

Do you have any way to fix this?

thankyou in advance

Davide
0 Kudos
by Anonymous User
Not applicable
Original User: bdaigle

I've been battling the first bug listed in this thread for a while now.  I have a single map app that I use to meet the mapping needs of a variety of other applications.  I use the basemap gallery to get the map loaded.  The map always opens up with the same basemap layer.  On the map's "onLoad" event, I dynamically switch the basemap to something more appropriate for the particular application; sometime imagery is best, other times topo makes more sense.  This usually works fine, but occasionally I get an error ("this._map is null") when I try to switch the basemap. The basemap still changes, but I seem to loose access to some of the map events ("onUpdate").  It helps if I add a 1000ms timeout before the changing the basemap, but it doesn't completely solve the problem. 

Any thoughts???
0 Kudos
JeffPace
MVP Alum
Well not at all an accurate solution, you might be able to do some TRIAGE/damage mitigation.

In your showLoading function, you could set a 1000ms timer or so and have it publish an onUpdateEnd event, which would at least trick your app into thinking it was done drawing and hide the icon, even if its not done.

I know this does not fix the error of never properly receiving the onUpdateEnd event, but if you application relies on receiving it to continue at least this way you are stuck refreshing the browser.

Better to have a busted basemap and be able to proceed than eject.
0 Kudos
by Anonymous User
Not applicable
Original User: bdaigle

Thanks for the suggestion Jeff. I may try something along that line.  The root of the problem seems to be that the basemap needs to completely update before the user updates the map in any way.  The same problem occurs if the user picks one basemap, then quickly changes to another.  Give it a try on the samples if your curious.  I contacted ESRI support and they filed it as a bug (NIM080755).  It doesn't seem to be showing up in their system yet, but I assume it will soon. 

I tried the following workaround:
dojo.connect(this.basemapGallery,"onSelectionChange",function(){
  
  //disable the map until it done updating the basemap 
  var mapStandby = new dojox.widget.Standby({target: _this.map.container});
  document.body.appendChild(mapStandby.domNode);
  mapStandby.startup();
  mapStandby.show();
  
  var mapUpdateEndConnect = dojo.connect(_this.map,"onUpdateEnd",function(){
      //disconnect the listener
      dojo.disconnect(mapUpdateEndConnect);
      
      //destroy the map standby
      mapStandby.destroy();
    });  
});


It helps, but unfortunately the "onSelectionChange" event is somewhat slow to react, soit's still possible for the user to update that map before the standby widget pops up.  I may try using it in combination with your suggestion and see how that works for me.
0 Kudos
BillDaigle
Occasional Contributor III
Here is my latest installment. 

I linked to the onClick event of the basemapGallery Nodes:
    //Listen for a change of basemap (NIM080755)
    dojo.forEach(dojo.query(".esriBasemapGalleryNode"),function(galleryNode){
      dojo.connect(galleryNode,"onclick",function(){
        _this._basemapButton.closeDropDown();
        _this._disableAllMapFunctionUntilBasemapUpdates();
      });
    }); 


The following function disables the map until it is done updating:
//this is a a stopgap measure until ESRI fixes NIM080755  
  _disableAllMapFunctionUntilBasemapUpdates: function(){
    var _this = this;
    //disable the map  it id done updating the basemap 
    var mapStandby = new dojox.widget.Standby({target: _this.map.container});
    document.body.appendChild(mapStandby.domNode);
    mapStandby.startup();
    mapStandby.show();
    
    var mapUpdateEndConnect = dojo.connect(_this.map,"onUpdateEnd",function(){
        mapStandby.destroy();
        dojo.disconnect(mapUpdateEndConnect);
      });    
  }


Finally, if all else fails I give the user an alert so they know something might have gone wrong. 
//added to account for errors caused by NIM080755
    window.onerror = function(){
      alert("An error has occured.\nYou're map will likely continue to function, but you may see inconsistent results.\nRefresh your browser to start over.");
    };
0 Kudos