[ka-Map-users] Ka-Map Spatial Bookmark / Link to View

Peter Giencke pgiencke at glc.org
Wed Sep 21 17:16:47 EDT 2005


I'm working on a spatial bookmark/'link to view' function (similar to what
google is doing) so that a user can follow a link to get to a 'saved' extent
with certain layers enabled/disabled.

I'm having a problem accessing the current map through oMap in zoomToExtent
function while loading the linkified ka-map instance: "oMap has no

Below is the pseudocode, followed by the real code for this. My ka-map
testcase for this is here: http://mds.glc.org/kamap_final/htdocs/

Any help/insight/etc into this would be appreciated.....



User clicks a button to linkify location (as seen on maps.google.com)
 Get extents
  Get selected Layers
   Create query string of extents + layers
    [re]load ka-map with query string (QS)

Ka-Map loads
 'Notice' QS pairs
  Parses out QS params
   Zooms to extent given through QS
    *Todo turn on selected layers


 function spatialBookmark()  //activated through a link on the main ka-map
  var a = myKaMap.getGeoExtents();
  var vLayers = getVisibleLayer();
  var oMap = myKaMap.getCurrentMap();
  var aLayers = oMap.getLayers();  
  stringToPass = String(document.location.href) + "?minx=" + a[0] + "&miny"
+ a[1] + "&maxx=" + a[2] + "&maxy=" + a[3] + "&layers=" + aLayers;
  window.location = stringToPass;  

function initialiseGetData() //safalra - set GET variables
    GET_DATA=new Array();
    var getDataString=new String(window.location);
    var questionMarkLocation=getDataString.search(/\?/);
    if (questionMarkLocation!=-1)
      var getDataArray=getDataString.split(/&/g);
      for (var i=0;i<getDataArray.length;i++)
        var nameValuePair=getDataArray[i].split(/=/);

if(GET_DATA['maxx'] && GET_DATA['minx']) //if extent is set, zoom! Part of
body onload
     myKaMap.zoomToExtents(getMinx, getMiny, getMaxx, getMaxy);
     //todo set selected layers from layer variable

//the offending function
  var oMap = this.getCurrentMap();

    //the geographic center - where we want to end up
    var cgX = (maxx+minx)/2;
    var cgY = (maxy+miny)/2;

    var tmpCellSizeX = (maxx - minx)/this.viewportWidth;
    var tmpCellSizeY = (maxy - miny)/this.viewportHeight;
    var tmpCellSize = Math.max( tmpCellSizeX, tmpCellSizeY );

    var tmpScale = tmpCellSize * oMap.resolution *

More information about the ka-Map-users mailing list