Project

General

Profile

1
/*
2
Author:       Patrice G Cappelaere patATcappelaere.com
3
License:      LGPL as per: http://www.gnu.org/copyleft/lesser.html
4

    
5
$Id$
6
*/
7
// Ensure this object's dependancies are loaded.
8
mapbuilder.loadScript(baseDir+"/widget/WidgetBaseXSL.js");
9

    
10
/**
11
 * Widget to switch maps while preserving the current user view 
12
 *
13
 * @constructor
14
 * @base WidgetBaseXSL
15
 * @param widgetNode  This widget's object node from the configuration document.
16
 * @param model       The model that this widget is a view of.
17
 */
18
function ModelSwitcher(widgetNode, model) {
19
  WidgetBase.apply(this,new Array(widgetNode, model));
20
  
21
  
22
  // Switch maps.
23
  // Called from html buttons
24
  this.switchMap = function(targetModel, modelUrl) {
25
    // get the context and bbox
26
    this.bbox = config.objects.mainMap.getBoundingBox();
27
   
28
    this.targetModel.addListener( "contextLoaded", this.setExtent, this );
29
    window.cgiArgs["bbox"]  = ""+this.bbox[0]+","+ this.bbox[1]+"," +this.bbox[2]+"," +this.bbox[3];
30
    config.loadModel( targetModel, modelUrl );
31
  }
32
  
33
  // called when the map is reloaded
34
  this.setExtent = function (objRef) {
35
    //var extent = config.objects.mainMap.extent;
36
    //alert( "Setting extent:"+objRef.bbox[0]+" "+objRef.bbox[1]+" "+objRef.bbox[2]+" "+objRef.bbox[3]);
37
    //extent.zoomToBox( new Array(objRef.bbox[0], objRef.bbox[1]), new Array(objRef.bbox[2], objRef.bbox[3]) );
38
    //objRef.targetModel.removeListener( "loadModel", objRef.setExtent, objRef );
39
  }
40
}
41

    
42

    
(87-87/145)