[ka-Map-users] Ka-Map Spatial Bookmark / Link to View
Stephen Woodbridge
woodbri at swoodbridge.com
Wed Sep 21 17:29:32 EDT 2005
Peter,
Look at your url, you are missing the '=' in miny, but that by itself
does not seem to fix it.
-Steve W.
Peter Giencke wrote:
> All,
>
> 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
> properties."
>
> 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.....
>
> -pete
>
> //Pseudo
>
> 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
>
> //Real
>
> function spatialBookmark() //activated through a link on the main ka-map
> page
> {
> 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)
> {
> getDataString=getDataString.substr(questionMarkLocation+1);
> var getDataArray=getDataString.split(/&/g);
> for (var i=0;i<getDataArray.length;i++)
> {
> var nameValuePair=getDataArray[i].split(/=/);
> GET_DATA[unescape(nameValuePair[0])]=unescape(nameValuePair[1]);
> }
> }
> }
>
>
> 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 *
> inchesPerUnit[oMap.units];
>
> _______________________________________________
> ka-Map-users mailing list
> ka-Map-users at lists.maptools.org
> http://lists.maptools.org/mailman/listinfo/ka-map-users
>
More information about the ka-Map-users
mailing list