[ka-Map-users] Re: Ka-Map Spatial Bookmark / Link to View
Paul Spencer
pspencer at dmsolutions.ca
Thu Sep 22 22:16:38 EDT 2005
Peter,
did you figure this out? I haven't had a chance to look at it (and
probably won't until at least next week)
Cheers
Paul
On 21-Sep-05, at 5:16 PM, 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];
>
>
+-----------------------------------------------------------------+
|Paul Spencer pspencer at dmsolutions.ca |
+-----------------------------------------------------------------+
|Applications & Software Development |
|DM Solutions Group Inc http://www.dmsolutions.ca/|
+-----------------------------------------------------------------+
More information about the ka-Map-users
mailing list