Skip to content

Instantly share code, notes, and snippets.

@dbouwman
Created March 22, 2013 04:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dbouwman/5218940 to your computer and use it in GitHub Desktop.
Save dbouwman/5218940 to your computer and use it in GitHub Desktop.
onMapLoaded handler in Router. I do this so that we wait until the map is ready, and THEN dispatch events telling is how to re-hydrate it's state
onMapLoaded:function(){
//ok, now that we have a map we can link up some events
Viewer.vent.on('FireLayer:ConfigChanged',this.setYear);
//and if we have values passed in on the url, raise events
if(this.urlValues){
Viewer.vent.trigger('FireLayer:ConfigChanged', this.urlValues.yearData);
Viewer.vent.trigger('Map:ShowPerimeters',this.urlValues.yearData);
Viewer.vent.trigger('Navbar:ChangeItemName',this.urlValues.yearData.model.name);
Viewer.vent.trigger('Map:CenterAtLatLongAndZoom', {
x:this.urlValues.x,
y:this.urlValues.y,
l:this.urlValues.l
});
}else{
//do the defaults - this is essentially what starts the app
//with the active fires
Viewer.vent.trigger('FireLayer:ConfigChanged', this.active);
Viewer.vent.trigger('Map:ShowPerimeters',this.active);
Viewer.vent.trigger('Navbar:ChangeItemName',this.active.model.name);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment