Copyright (c) 2002, DM Solutions Group Inc. * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ include_once(dirname(__FILE__)."/../NavTool.php"); include_once(dirname(__FILE__)."/../geomath.php"); /** * KeyMapDHTMLWidget provides a DHTML enabled mapping interface and the javascript * functions for doing javascript-based navigation. */ class KeyMapDHTML extends NavTool { var $msAnchorName = "keymapanchor"; var $msMapImageName = "keymapimage"; var $mszMarqueeColor = "RED"; var $mnMarqueeWidth = 1; var $mszMarqueeImageHorizontal = "images/a_pixel.gif"; var $mszMarqueeImageVertical = "images/a_pixel.gif"; var $mszURL = ""; var $mbAllowResize = true; var $mfMinScale = 1; var $mfMaxScale = -1; var $mnWidth = 100; var $mnHeight = 100; var $mszImage = ""; var $mdMinx = 0; var $mdMiny = 0; var $mdMaxx = 0; var $mdMaxy = 0; var $mszSRS = ''; var $mszAnchorName = "keyMapAnchor"; var $mszKeyMapImageName = "KeyMapImage"; var $mszKeyMapName = ""; var $mdfZoomMin = 4; var $mszMode = "ZOOM"; function KeyMapDHTML() { // invoke constructor of parent parent::NavTool(); $this->SetNavCommand("KEY_MAP_DHTML"); $this->SetUniqueId(md5(uniqid(rand()))); $this->moButton->mszAnchorName = $this->mszAnchorName; $this->maAttributes["WIDTH"] = new IntegerAttribute( "WIDTH", false, 0 ); $this->maAttributes["HEIGHT"] = new IntegerAttribute( "HEIGHT", false, 0 ); $this->maAttributes["IMAGE"] = new StringAttribute( "IMAGE", false ); $this->maAttributes["COLOR"] = new RGBColorAttribute( "COLOR", false ); $this->maAttributes["OUTLINECOLOR"] = new RGBColorAttribute( "OUTLINECOLOR", false ); $this->maAttributes["MINX"] = new FloatAttribute( "MINX", false ); $this->maAttributes["MINY"] = new FloatAttribute( "MINY", false ); $this->maAttributes["MAXX"] = new FloatAttribute( "MAXX", false ); $this->maAttributes["MAXY"] = new FloatAttribute( "MAXY", false ); $this->maAttributes["SRS"] = new StringAttribute( "SRS", false ); $this->mszMarqueeImageHorizontal = $_SESSION['gszCoreWebPath']."/skins/default/images/a_pixel.gif"; $this->mszMarqueeImageVertical = $_SESSION['gszCoreWebPath']."/skins/default/images/a_pixel.gif"; $this->mnMaturityLevel = MATURITY_BETA; } function InitDefaults() { parent::InitDefaults(); if (!isset($_SESSION['KEYMAPDHTML_INIT']) || $_SESSION['KEYMAPDHTML_INIT'] != "1") { $oApp = GetChameleonApplication(); // set width if (isset($this->maParams['WIDTH'])) { $this->moMapObject->oMap->reference->set( "width", $this->maParams['WIDTH'] ); } // set height if (isset($this->maParams['HEIGHT'])) { $this->moMapObject->oMap->reference->set( "height", $this->maParams['HEIGHT'] ); } // set image if (isset($this->maParams['IMAGE'])) { $szImage = $oApp->getRemoteFile( $this->maParams['IMAGE'] ); $szImage = $oApp->findFile( $szImage ); $this->moMapObject->oMap->reference->set( "image", $szImage ); } else { $szMapPath = realpath( $_SESSION['gszMapPath'] )."/"; $szImage = $this->moMapObject->oMap->reference->image; $szImage = realpath($oApp->resolvePath2( $szImage, $szMapPath )); $this->moMapObject->oMap->reference->set( "image", $szImage ); } // set extent if (isset($this->maParams['MINX']) && isset($this->maParams['MINY']) && isset($this->maParams['MAXX']) && isset($this->maParams['MAXY'])) { $this->moMapObject->oMap->reference->extent->setextent( $this->maParams['MINX'], $this->maParams['MINY'], $this->maParams['MAXX'], $this->maParams['MAXY'] ); } } // intialize member variables $this->mnWidth = $this->moMapObject->oMap->reference->width; $this->mnHeight = $this->moMapObject->oMap->reference->height; $this->mszImage = $this->moMapObject->oMap->reference->image; $this->mdMinx = $this->moMapObject->oMap->reference->extent->minx; $this->mdMiny = $this->moMapObject->oMap->reference->extent->miny; $this->mdMaxx = $this->moMapObject->oMap->reference->extent->maxx; $this->mdMaxy = $this->moMapObject->oMap->reference->extent->maxy; if ($this->isVarSet( "MAP_ORIGINAL_PROJ" )) $this->mszSRS = $this->getVar( "MAP_ORIGINAL_PROJ" ); elseif ($this->moMapObject->oMap->getmetadata( "original_projection" ) != "") $this->mszSRS = $this->moMapObject->oMap->getmetadata( "original_projection" ); else $this->mszSRS = $this->moMapObject->oMap->getprojection(); //echo "keymapdhtml srs is ".$this->mszSRS."
\n"; // Accept different format for SRS. // only a number, we will add init=epsg: // EPSG:XXXX will result in init=epsg:XXXX // Or else a valid projection string. if(isset($this->maParams['SRS']) && $this->maParams['SRS'] != "") { $szSRS = ""; $szSRS .= intval($this->maParams['SRS']); if($szSRS == $this->maParams['SRS']) { $this->mszSRS = "init=epsg:".$this->maParams['SRS']; } else if(strtoupper(substr($this->maParams['SRS'], 0, 5)) == "EPSG:") { $this->maParams['SRS'] = "init=epsg:". substr($this->maParams['SRS'], 5); } else { $this->mszSRS = $this->maParams['SRS']; } } $_SESSION['KEYMAPDHTML_INIT'] = "1"; } /** * handle changes coming from the URL. In this case, we only want * to verify that the map size is valid */ function ParseURL() { parent::ParseURL(); $oMap = $this->moMapObject->oMap; $szCmd = ""; if ($this->isVarSet("NAV_CMD")) $szCmd = trim($this->getVar("NAV_CMD")); if ($this->isVarSet('KEYMAP_DHTML_MODE')) $this->mszMode = $this->getVar('KEYMAP_DHTML_MODE'); if ($szCmd != "" && $this->isVarSet("NAV_INPUT_COORDINATES") && $this->isVarSet("NAV_INPUT_TYPE") && $szCmd == "KEYMAP_DHTML") { $szMapProj = $oMap->getProjection(); //adjust extents/projection first ... $szInputCoords = $this->getVar("NAV_INPUT_COORDINATES"); $szInputType = $this->getVar("NAV_INPUT_TYPE"); $aPixMin = false; $aPixMax = false; if ($szInputType == "RECTANGLE") { $aPixPos = explode(";", $szInputCoords); $aPixMin = explode(",", $aPixPos[0]); $aPixMax = explode(",", $aPixPos[1]); // adjust ratio of height & width to match main map if ($this->mszMode == "ZOOM") { $this->adjustBBox( $aPixMin[0], $aPixMin[1], $aPixMax[0], $aPixMax[1], $oMap->width, $oMap->height ); //check if the rectangle is bigger than the minmum size allowed. */ if (abs($aPixMax[0] - $aPixMin[0]) < $this->mdfZoomMin && abs($aPixMax[1] - $aPixMin[1]) < $this->mdfZoomMin) { $aPixMax = false; $szInputType = 'POINT'; } } } else { $aPixMin = explode(",", $szInputCoords); } //calc geo positions and reproject points if ($aPixMin != false) { $nGeoMinx = Pix2Geo($aPixMin[0], 0, $this->mnWidth, $this->mdMinx, $this->mdMaxx); $nGeoMiny = Pix2Geo($aPixMin[1], 0, $this->mnHeight, $this->mdMiny, $this->mdMaxy, 1); reprojectPoint( $nGeoMinx, $nGeoMiny, $this->mszSRS, $this->moMapObject->oMap->getProjection() ); } if ($aPixMax != false) { $nGeoMaxx = Pix2Geo($aPixMax[0], 0, $this->mnWidth, $this->mdMinx, $this->mdMaxx); $nGeoMaxy = Pix2Geo($aPixMax[1], 0, $this->mnHeight, $this->mdMiny, $this->mdMaxy, 1); reprojectPoint( $nGeoMaxx, $nGeoMaxy, $this->mszSRS, $this->moMapObject->oMap->getProjection() ); } if ($this->mszMode == "ZOOM") { if ($szInputType == "RECTANGLE") { if ($nGeoMinx > $nGeoMaxx) { $tmp = $nGeoMinx; $nGeoMinx = $nGeoMaxx; $nGeoMaxx = $tmp; } if ($nGeoMiny > $nGeoMaxy) { $tmp = $nGeoMiny; $nGeoMiny = $nGeoMaxy; $nGeoMaxy = $tmp; } // set the map extent $oMap->setExtent($nGeoMinx, $nGeoMiny, $nGeoMaxx, $nGeoMaxy); } elseif ($szInputType == "POINT") { // convert to map pixels $aPix[0] = Geo2Pix($nGeoMinx, 0, $oMap->width, $oMap->extent->minx, $oMap->extent->maxx); $aPix[1] = Geo2Pix($nGeoMiny, 0, $oMap->height, $oMap->extent->miny, $oMap->extent->maxy, true); // perform zoom $this->moMapNavigator->zoomPoint(1, $aPix[0], $aPix[1]); } else { $_SESSION['gErrorManager']->setError(ERR_WARNING, trim($this->moMLT->get("1", "ERROR: Invalid input type specified in "))." (".$szInputType.") KeyMapDHTML.widget.php."); return; } //cause extents to be recalculated based on size .... if ($oMap->getprojection() != "") { $oMap->setProjection($oMap->getProjection(), true); } /* -------------------------------------------------------------------- */ /* Call the reporjectauto function in case the map projection */ /* is set to AUTO:XXX. If it is not, the function will do */ /* nothing. */ /* -------------------------------------------------------------------- */ $this->ReprojectAuto(); } elseif ($this->mszMode == "RECENTER") { if ($szInputType == "POINT") { // convert to map pixels $aPix[0] = Geo2Pix($nGeoMinx, 0, $oMap->width, $oMap->extent->minx, $oMap->extent->maxx); $aPix[1] = Geo2Pix($nGeoMiny, 0, $oMap->height, $oMap->extent->miny, $oMap->extent->maxy, true); // perform zoom of factor 1 to recenter $this->moMapNavigator->zoomPoint(1, $aPix[0], $aPix[1]); } elseif ($szInputType == "RECTANGLE") { // calculate offset $nDeltaXGeo = $nGeoMaxx - $nGeoMinx; $nDeltaYGeo = $nGeoMaxy - $nGeoMiny; // offset current extent $oMap->setExtent( $oMap->extent->minx + $nDeltaXGeo, $oMap->extent->miny + $nDeltaYGeo, $oMap->extent->maxx + $nDeltaXGeo, $oMap->extent->maxy + $nDeltaYGeo ); } else { $_SESSION['gErrorManager']->setError(ERR_WARNING, trim($this->moMLT->get("1", "ERROR: Invalid input type specified in"))." Recenter.php."); return true; } /* -------------------------------------------------------------------- */ /* Call the reporjectauto function in case the map projection */ /* is set to AUTO:XXX. If it is not, the function will do */ /* nothing. */ /* -------------------------------------------------------------------- */ $this->ReprojectAuto(); } } // return success return true; } /** * draw the map DHTML widget interface */ function DrawPublish() { if (!$this->mbVisible) return ""; $url = $_SESSION['gszCoreWebPath']."/skins/default/images/a_pixel.gif"; $nWidth = $this->mnWidth; $nHeight = $this->mnHeight; $szReturn = << EOT; return $szReturn; } /** * return an array of javascript functions needed by KeyMapDHTML widget * @return array of name = function values */ function GetJavascriptFunctions() { /* -------------------------------------------------------------------- */ /* test if we use the JS API. */ /* -------------------------------------------------------------------- */ if (isset($this->maSharedResourceWidgets["CWCJSAPI"])) $bCWCJSAPI = 1; else $bCWCJSAPI = 0; $aReturn = parent::GetJavascriptFunctions(); /* -------------------------------------------------------------------- */ /* KeyMapWsetZoomBoxSettings */ /* -------------------------------------------------------------------- */ $szJsFunctionName = "KeyMapWsetZoomBoxSettings"; $szFunction = "function $szJsFunctionName()\n"; $szFunction .= <<mszHTMLForm}.NAV_INPUT_COORDINATES.value = szCoord; {$this->mszHTMLForm}.NAV_INPUT_TYPE.value = "POINT"; goCWCJSAPI.UpdateNavTools(); } else { {$this->mszHTMLForm}.NAV_INPUT_COORDINATES.value = szCoord; {$this->mszHTMLForm}.NAV_INPUT_TYPE.value = "POINT"; document.onmousemove = null; document.onmouseup = null; document.onmousedown = null; {$this->mszHTMLForm}.submit(); } } EOT; $aReturn[$szJsFunctionName] = $szFunction; /* -------------------------------------------------------------------- */ /* KeyMapWmapTool */ /* -------------------------------------------------------------------- */ $szJsFunctionName = "KeyMapWmapTool"; $szFunction = "function $szJsFunctionName(e)\n"; $szFunction .= <<mszHTMLForm}.NAV_ALLOW_RECTANGLE.value == 0) { //alert({$this->mszHTMLForm}.NAV_ALLOW_RECTANGLE.value); // KeyMapWPointNavigation(); // return true; } } if (!gKeyMapWdragging && KeyMapWinsideKeyMap()) { KeyMapWstartZoomBox(e); return false; } else if (gKeyMapWdragging) { KeyMapWgetMouse(e); KeyMapWstopZoomBox(e); } return true; } EOT; $aReturn[$szJsFunctionName] = $szFunction; /* -------------------------------------------------------------------- */ /* KeyMapgetImageXY */ /* -------------------------------------------------------------------- */ $szJsFunctionName = "KeyMapWgetImageXY"; $szFunction = "function $szJsFunctionName(e)\n"; $szFunction .= <<mszHTMLForm} == null || {$this->mszHTMLForm}.KEYMAP_CURSOR_POS_X == null) { return true; } if (KeyMapWinsideKeyMap()) { {$this->mszHTMLForm}.KEYMAP_CURSOR_POS_X.value = gKeyMapWmouseX; {$this->mszHTMLForm}.KEYMAP_CURSOR_POS_Y.value = gKeyMapWmouseY; if ({$bCWCJSAPI}) { goCWCJSAPI.oMap.cursorpos[0] = gKeyMapWmouseX; goCWCJSAPI.oMap.cursorpos[1] = gKeyMapWmouseY; } } else { {$this->mszHTMLForm}.KEYMAP_CURSOR_POS_X.value = -1; {$this->mszHTMLForm}.KEYMAP_CURSOR_POS_Y.value = -1; if ({$bCWCJSAPI}) { goCWCJSAPI.oMap.cursorpos[0] = -1; goCWCJSAPI.oMap.cursorpos[1] = -1; } if (document.onmousedown == KeyMapWmapTool) document.onmousedown = null; if (document.onmouseup == KeyMapWchkMouseUp) document.onmouseup = null; return true; } document.onmousedown = KeyMapWmapTool; document.onmouseup = KeyMapWchkMouseUp; if (gKeyMapWdragging) { gKeyMapWx2 = gKeyMapWmouseX = Math.min(Math.max(gKeyMapWmouseX, 0), gKeyMapWiWidth); gKeyMapWy2 = gKeyMapWmouseY = Math.min(Math.max(gKeyMapWmouseY, 0), gKeyMapWiHeight); KeyMapWsetClip(); return false; } else { return true; } return true; } EOT; $aReturn[$szJsFunctionName] = $szFunction; /* -------------------------------------------------------------------- */ /* KeyMapWinsideKeyMap */ /* -------------------------------------------------------------------- */ $szJsFunctionName = "KeyMapWinsideKeyMap"; $szFunction = "function $szJsFunctionName()\n"; $szFunction .= <<= 0) && (gKeyMapWmouseX < gKeyMapWiWidth) && (gKeyMapWmouseY >= 0) && (gKeyMapWmouseY < gKeyMapWiHeight)); } EOT; $aReturn[$szJsFunctionName] = $szFunction; /* -------------------------------------------------------------------- */ /* KeyMapWstartZoomBox */ /* -------------------------------------------------------------------- */ $szJsFunctionName = "KeyMapWstartZoomBox"; $szFunction = "function $szJsFunctionName(e)\n"; $szFunction .= <<mszHTMLForm}.NAV_INPUT_COORDINATES.value = szCoord; {$this->mszHTMLForm}.NAV_INPUT_TYPE.value = "POINT"; goCWCJSAPI.UpdateNavTools(); } else { {$this->mszHTMLForm}.NAV_INPUT_COORDINATES.value = szCoord; {$this->mszHTMLForm}.NAV_INPUT_TYPE.value = "POINT"; {$this->mszHTMLForm}.NAV_CMD.value = "KEYMAP_DHTML"; document.onmousemove = null; document.onmouseup = null; document.onmousedown = null; {$this->mszHTMLForm}.submit(); } return true; } else { // Zoom to box if ({$this->mszHTMLForm}.KEYMAP_DHTML_MODE.value == "ZOOM") { var tx1 = Math.min(gKeyMapWfirstx, gKeyMapWsecondx); var tx2 = Math.max(gKeyMapWfirstx, gKeyMapWsecondx); var ty1 = Math.min(gKeyMapWfirsty, gKeyMapWsecondy); var ty2 = Math.max(gKeyMapWfirsty, gKeyMapWsecondy); } else { var tx1 = gKeyMapWfirstx; var tx2 = gKeyMapWsecondx; var ty1 = gKeyMapWfirsty; var ty2 = gKeyMapWsecondy; } var szCoord = ""+ tx1 + "," + ty1 + ";" + tx2 + "," + ty2; if ({$bCWCJSAPI}) { goCWCJSAPI.NAV_CMD = "KEYMAP_DHTML"; goCWCJSAPI.NAV_INPUT_COORDINATES = szCoord; goCWCJSAPI.NAV_INPUT_TYPE = "RECTANGLE"; //the forms variables settings should not be necessary. But It //keeps consistancy since some js functions test the values //of the form parameters. {$this->mszHTMLForm}.NAV_INPUT_COORDINATES.value = szCoord; {$this->mszHTMLForm}.NAV_INPUT_TYPE.value = "RECTANGLE"; CWCDHTML_HideLayer("zKeyMapBoxTop"); CWCDHTML_HideLayer("zKeyMapBoxLeft"); CWCDHTML_HideLayer("zKeyMapBoxRight"); CWCDHTML_HideLayer("zKeyMapBoxBottom"); goCWCJSAPI.UpdateNavTools(); } else { {$this->mszHTMLForm}.NAV_INPUT_COORDINATES.value = szCoord; {$this->mszHTMLForm}.NAV_INPUT_TYPE.value = "RECTANGLE"; {$this->mszHTMLForm}.NAV_CMD.value = "KEYMAP_DHTML"; document.onmousemove = null; document.onmouseup = null; document.onmousedown = null; {$this->mszHTMLForm}.submit(); } return true; } return false; } EOT; $aReturn[$szJsFunctionName] = $szFunction; /* -------------------------------------------------------------------- */ /* KeyMapWsetClip */ /* -------------------------------------------------------------------- */ $oMap = $this->moMapObject->oMap; $nMinx = $oMap->extent->minx; $nMiny = $oMap->extent->miny; $nMaxx = $oMap->extent->maxx; $nMaxy = $oMap->extent->maxy; //echo "bbox 1: $nMinx,$nMiny:$nMaxx,$nMaxy
\n"; reprojectPoint( $nMinx, $nMiny, $this->moMapObject->oMap->getProjection(), $this->mszSRS ); reprojectPoint( $nMaxx, $nMaxy, $this->moMapObject->oMap->getProjection(), $this->mszSRS ); //echo "bbox 2: $nMinx,$nMiny:$nMaxx,$nMaxy
\n"; $nRefMinx = $oMap->reference->extent->minx; $nRefMiny = $oMap->reference->extent->miny; $nRefMaxx = $oMap->reference->extent->maxx; $nRefMaxy = $oMap->reference->extent->maxy; //echo "ref: $nRefMinx,$nRefMiny:$nRefMaxx,$nRefMaxy
\n"; // calculate the bounding pixels of the box to draw $nLeft = Geo2Pix($nMinx, 0, $oMap->reference->width, $nRefMinx, $nRefMaxx); $nTop = Geo2Pix($nMaxy, 0, $oMap->reference->height, $nRefMiny, $nRefMaxy, true); $nRight = Geo2Pix($nMaxx, 0, $oMap->reference->width, $nRefMinx, $nRefMaxx); $nBottom = Geo2Pix($nMiny, 0, $oMap->reference->height, $nRefMiny, $nRefMaxy, true); //echo "$nLeft,$nBottom:$nRight,$nTop
\n"; $nSRSRefMinx = $nRefMinx; $nSRSRefMaxx = $nRefMaxx; $nSRSRefMiny = $nRefMiny; $nSRSRefMaxy = $nRefMaxy; reprojectPoint( $nSRSRefMinx, $nSRSRefMiny, $this->mszSRS, $this->moMapObject->oMap->getProjection() ); reprojectPoint( $nSRSRefMaxx, $nSRSRefMaxy, $this->mszSRS, $this->moMapObject->oMap->getProjection() ); $szJsFunctionName = "KeyMapWsetClip"; $szFunction = "function $szJsFunctionName()\n"; $szFunction .= <<mnMarqueeWidth}; if ({$this->mszHTMLForm}.KEYMAP_DHTML_MODE.value == "ZOOM") { CWCDHTML_ClipLayer(gKeyMapWtoplayer, gKeyMapWzleft, gKeyMapWztop, gKeyMapWzright, gKeyMapWztop + ovBoxSize); CWCDHTML_ClipLayer(gKeyMapWleftlayer, gKeyMapWzleft, gKeyMapWztop, gKeyMapWzleft + ovBoxSize, gKeyMapWzbottom); CWCDHTML_ClipLayer(gKeyMapWrightlayer, gKeyMapWzright - ovBoxSize, gKeyMapWztop, gKeyMapWzright, gKeyMapWzbottom); CWCDHTML_ClipLayer(gKeyMapWbottomlayer, gKeyMapWzleft, gKeyMapWzbottom - ovBoxSize, gKeyMapWzright, gKeyMapWzbottom); } else {// recenter var nXDiff = gKeyMapWx2 - gKeyMapWx1; var nYDiff = gKeyMapWy2 - gKeyMapWy1; var nLeft = {$nLeft}; var nTop = {$nTop}; var nRight = {$nRight}; var nBottom = {$nBottom}; CWCDHTML_ClipLayer(gKeyMap2Wtoplayer, nLeft+nXDiff,nTop+nYDiff,nRight+nXDiff,nTop+nYDiff+1); CWCDHTML_ClipLayer(gKeyMap2Wleftlayer, nLeft+nXDiff,nTop+nYDiff,nLeft+nXDiff+1,nBottom+nYDiff); CWCDHTML_ClipLayer(gKeyMap2Wrightlayer, nRight+nXDiff-1,nTop+nYDiff,nRight+nXDiff,nBottom+nYDiff); CWCDHTML_ClipLayer(gKeyMap2Wbottomlayer, nLeft+nXDiff,nBottom+nYDiff-1,nRight+nXDiff,nBottom+nYDiff); } } } EOT; $aReturn[$szJsFunctionName] = $szFunction; $szJsFunctionName = "KeyMapWCaptureMouse"; $szFunction = "function $szJsFunctionName()\n"; $szFunction .= <<fileSystemToURL( $this->mszImage, true ); $szJsFunctionName = "KeyMapWCreateDHTMLLayers"; $szFunction = "function $szJsFunctionName()\n"; $szAPixel = $_SESSION['gszCoreWebPath']."/skins/default/images/a_pixel.gif"; $szFunction .= <<mnWidth}+"\" height=\""+{$this->mnHeight}+"\" border=\"0\" onload=\"\" onmouseover=\"KeyMapWCaptureMouse();\" onmouseout=\"KeyMapWReleaseMouse();\">"; CWCDHTML_CreateLayer("KeyMapLayerDiv", gKeyMapWhspc, gKeyMapWvspc, gKeyMapWiWidth, gKeyMapWiHeight, true, content); CWCDHTML_SetLayerZOrder( "KeyMapLayerDiv", 11 ); content = ''; CWCDHTML_CreateLayer("zKeyMapBoxTop", gKeyMapWhspc, gKeyMapWvspc, gKeyMapWiWidth, gKeyMapWiHeight, false, content); CWCDHTML_SetLayerZOrder( "zKeyMapBoxTop", 12 ); content = ''; CWCDHTML_CreateLayer("zKeyMapBoxLeft", gKeyMapWhspc, gKeyMapWvspc, gKeyMapWiWidth, gKeyMapWiHeight, false, content); CWCDHTML_SetLayerZOrder( "zKeyMapBoxLeft", 12 ); content = ''; CWCDHTML_CreateLayer("zKeyMapBoxBottom", gKeyMapWhspc, gKeyMapWvspc, gKeyMapWiWidth, gKeyMapWiHeight, false, content); CWCDHTML_SetLayerZOrder( "zKeyMapBoxBottom", 12 ); content = ''; CWCDHTML_CreateLayer("zKeyMapBoxRight", gKeyMapWhspc, gKeyMapWvspc, gKeyMapWiWidth, gKeyMapWiHeight, false, content); CWCDHTML_SetLayerZOrder( "zKeyMapBoxRight", 12 ); content = ''; CWCDHTML_CreateLayer("zKeyMap2BoxTop", gKeyMapWhspc, gKeyMapWvspc, gKeyMapWiWidth, gKeyMapWiHeight, true, content); CWCDHTML_SetLayerZOrder( "zKeyMap2BoxTop", 12 ); content = ''; CWCDHTML_CreateLayer("zKeyMap2BoxLeft", gKeyMapWhspc, gKeyMapWvspc, gKeyMapWiWidth, gKeyMapWiHeight, true, content); CWCDHTML_SetLayerZOrder( "zKeyMap2BoxLeft", 12 ); content = ''; CWCDHTML_CreateLayer("zKeyMap2BoxBottom", gKeyMapWhspc, gKeyMapWvspc, gKeyMapWiWidth, gKeyMapWiHeight, true, content); CWCDHTML_SetLayerZOrder( "zKeyMap2BoxBottom", 12 ); content = ''; CWCDHTML_CreateLayer("zKeyMap2BoxRight", gKeyMapWhspc, gKeyMapWvspc, gKeyMapWiWidth, gKeyMapWiHeight, true, content); CWCDHTML_SetLayerZOrder( "zKeyMap2BoxRight", 12 ); boundingColor = '{$this->mszMarqueeColor}'; CWCDHTML_SetLayerBackgroundColor("zKeyMapBoxTop", boundingColor); CWCDHTML_SetLayerBackgroundColor("zKeyMapBoxLeft", boundingColor); CWCDHTML_SetLayerBackgroundColor("zKeyMapBoxRight", boundingColor); CWCDHTML_SetLayerBackgroundColor("zKeyMapBoxBottom", boundingColor); CWCDHTML_SetLayerBackgroundColor("zKeyMap2BoxTop", boundingColor); CWCDHTML_SetLayerBackgroundColor("zKeyMap2BoxLeft", boundingColor); CWCDHTML_SetLayerBackgroundColor("zKeyMap2BoxRight", boundingColor); CWCDHTML_SetLayerBackgroundColor("zKeyMap2BoxBottom", boundingColor); var nLeft = {$nLeft}; var nTop = {$nTop}; var nRight = {$nRight}; var nBottom = {$nBottom}; // Create the red rectangle that will show wich part of the map is shown. CWCDHTML_ClipLayer(gKeyMap2Wtoplayer, nLeft,nTop,nRight,nTop+1); CWCDHTML_ClipLayer(gKeyMap2Wleftlayer, nLeft,nTop,nLeft+1,nBottom); CWCDHTML_ClipLayer(gKeyMap2Wrightlayer, nRight-1,nTop,nRight,nBottom); CWCDHTML_ClipLayer(gKeyMap2Wbottomlayer, nLeft,nBottom-1,nRight,nBottom); } EOT; $aReturn[$szJsFunctionName] = $szFunction; /* -------------------------------------------------------------------- */ /* Initilalization function called from on load. */ /* -------------------------------------------------------------------- */ $nWidth = $this->mnWidth; $nHeight = $this->mnHeight; $szJsFunctionName = "KeyMapWidgetInitVariables"; $szFunction = "function $szJsFunctionName()\n"; $szFunction .= <<mszSRS, $this->moMapObject->oMap->getProjection() ); reprojectPoint( $nSRSRefMaxx, $nSRSRefMaxy, $this->mszSRS, $this->moMapObject->oMap->getProjection() ); $szJsFunctionName = "KeyMapWGeo2Pix"; $szFunction = <<mbAllowResize) $bAllowResize = 1; $szJsFunctionName = "KeyMapWRegisterForEvent"; $szFunction = <<maSharedResourceWidgets["CWCJSAPI"])) { $szJsFunctionName = "KeyMapWRegisterForEvent"; $szFunction = "$szJsFunctionName();\n"; $aReturn[$szJsFunctionName] = $szFunction; } return $aReturn; } /** * GetJavascriptInitFunctions * * Functions to be called at the end of the load. */ function GetJavascriptInitFunctions() { $aReturn = array(); $szJsFunctionName = "KeyMapWidgetInitVariables"; //$szFunction = "setTimeout('$szJsFunctionName()',5000);"; $szFunction = "$szJsFunctionName();\n"; $aReturn[$szJsFunctionName] = $szFunction; return $aReturn; } /** * GetJavascriptIncludeFunctions */ function GetJavascriptIncludeFunctions() { $aReturn = parent::GetJavascriptIncludeFunctions(); $szJsIncludeName = "cwc_dhtml.js"; $szInclude = ''; $aReturn[$szJsIncludeName] = $szInclude; return $aReturn; } /** * GetJavascriptVariables * * Return JS global variables and global code. */ function GetJavascriptVariables() { $aReturn = array(); $szVariable = "gKeyMapWvspcIEadjust"; $szValue = " var $szVariable = 7;\n"; $aReturn[$szVariable] = $szValue; $szVariable = "gKeyMapWhspcIEadjust"; $szValue = " var $szVariable = -2;\n"; $aReturn[$szVariable] = $szValue; $szVariable = "gKeyMapWiWidth"; $szValue = " var $szVariable = 0;\n"; $aReturn[$szVariable] = $szValue; $szVariable = "gKeyMapWiHeight"; $szValue = " var $szVariable = 0;\n"; $aReturn[$szVariable] = $szValue; $szVariable = "gKeyMapWhspc"; $szValue = " var $szVariable = 0;\n"; $aReturn[$szVariable] = $szValue; $szVariable = "gKeyMapWvspc"; $szValue = " var $szVariable = 0;\n"; $aReturn[$szVariable] = $szValue; $szVariable = "gKeyMapWmouseX"; $szValue = " var $szVariable = 0;\n"; $aReturn[$szVariable] = $szValue; $szVariable = "gKeyMapWmouseY"; $szValue = " var $szVariable = 0;\n"; $aReturn[$szVariable] = $szValue; $szVariable = "gKeyMapWx1"; $szValue = " var $szVariable = 0;\n"; $aReturn[$szVariable] = $szValue; $szVariable = "gKeyMapWy1"; $szValue = " var $szVariable = 0;\n"; $aReturn[$szVariable] = $szValue; $szVariable = "gKeyMapWx2"; $szValue = " var $szVariable = 0;\n"; $aReturn[$szVariable] = $szValue; $szVariable = "gKeyMapWy2"; $szValue = " var $szVariable = 0;\n"; $aReturn[$szVariable] = $szValue; $szVariable = "gKeyMapWfirstx"; $szValue = " var $szVariable = 0;\n"; $aReturn[$szVariable] = $szValue; $szVariable = "gKeyMapWfirsty"; $szValue = " var $szVariable = 0;\n"; $aReturn[$szVariable] = $szValue; $szVariable = "gKeyMapWsecondx"; $szValue = " var $szVariable = 0;\n"; $aReturn[$szVariable] = $szValue; $szVariable = "gKeyMapWsecondy"; $szValue = " var $szVariable = 0;\n"; $aReturn[$szVariable] = $szValue; $szVariable = "gKeyMapWzleft"; $szValue = " var $szVariable = 0;\n"; $aReturn[$szVariable] = $szValue; $szVariable = "gKeyMapWzright"; $szValue = " var $szVariable = 0;\n"; $aReturn[$szVariable] = $szValue; $szVariable = "gKeyMapWztop"; $szValue = " var $szVariable = 0;\n"; $aReturn[$szVariable] = $szValue; $szVariable = "gKeyMapWzbottom"; $szValue = " var $szVariable = 0;\n"; $aReturn[$szVariable] = $szValue; $szVariable = "gKeyMapWmapX"; $szValue = " var $szVariable = 0;\n"; $aReturn[$szVariable] = $szValue; $szVariable = "gKeyMapWmapY"; $szValue = " var $szVariable = 0;\n"; $aReturn[$szVariable] = $szValue; $szVariable = "gKeyMapWdragging"; $szValue = " var $szVariable = false;\n"; $aReturn[$szVariable] = $szValue; $szVariable = "gKeyMapWtoplayer"; $szValue = " var $szVariable = \"zKeyMapBoxTop\";\n"; $aReturn[$szVariable] = $szValue; $szVariable = "gKeyMapWleftlayer"; $szValue = " var $szVariable = \"zKeyMapBoxLeft\";\n"; $aReturn[$szVariable] = $szValue; $szVariable = "gKeyMapWbottomlayer"; $szValue = " var $szVariable = \"zKeyMapBoxBottom\";\n"; $aReturn[$szVariable] = $szValue; $szVariable = "gKeyMapWrightlayer"; $szValue = " var $szVariable = \"zKeyMapBoxRight\";\n"; $aReturn[$szVariable] = $szValue; $szVariable = "gKeyMap2Wtoplayer"; $szValue = " var $szVariable = \"zKeyMap2BoxTop\";\n"; $aReturn[$szVariable] = $szValue; $szVariable = "gKeyMap2Wleftlayer"; $szValue = " var $szVariable = \"zKeyMap2BoxLeft\";\n"; $aReturn[$szVariable] = $szValue; $szVariable = "gKeyMap2Wbottomlayer"; $szValue = " var $szVariable = \"zKeyMap2BoxBottom\";\n"; $aReturn[$szVariable] = $szValue; $szVariable = "gKeyMap2Wrightlayer"; $szValue = " var $szVariable = \"zKeyMap2BoxRight\";\n"; $aReturn[$szVariable] = $szValue; return $aReturn; } /** * GetHTMLHiddenVariables * * Return HTML hidden variables. */ function GetHTMLHiddenVariables() { $szVariable = "NAV_INPUT_TYPE"; $szValue = " "; $aReturn[$szVariable] = $szValue; $szVariable = "NAV_INPUT_COORDINATES"; $szValue = " \n"; $aReturn[$szVariable] = $szValue; $szVariable = "KEYMAP_CURSOR_POS_X"; $szValue = " \n"; $aReturn[$szVariable] = $szValue; $szVariable = "KEYMAP_CURSOR_POS_Y"; $szValue = " \n"; $aReturn[$szVariable] = $szValue; $szCmd = ''; if ($this->isVarSet('NAV_CMD')) $szCmd = $this->getVar('NAV_CMD'); $szVariable = "NAV_CMD"; $szValue = " \n"; $aReturn[$szVariable] = $szValue; $szVariable = "KEYMAP_NAV_ALLOW_RECTANGLE"; $szValue = " \n"; $aReturn[$szVariable] = $szValue; $szVariable = "KEYMAP_DHTML_MODE"; $szValue = " \n"; $aReturn[$szVariable] = $szValue; return $aReturn; } /** * adjustBBox() * * Postcondition: This function adjusts a user supplied pixel bbox to the correct ratio * of the mainmap * */ function adjustBBox( &$nMinx, &$nMiny, &$nMaxx, &$nMaxy, $nMapWidth, $nMapHeight ) { // calculate center pixel values $nMidX = (($nMaxx - $nMinx)/2) + $nMinx; $nMidY = (($nMaxy - $nMiny)/2) + $nMiny; // adjust according to which dimension is furthest out if ( ($nMaxx-$nMinx)/$nMapWidth > ($nMaxy-$nMiny)/$nMapHeight ) { // calculate the pixel width of zoom box $nPixDist = $nMaxx - $nMinx; // determine main map width and height ratio $dMainMapRatio = $nMapHeight/$nMapWidth; // convert the pixel values to be in the same ratio as the main map $nConvertedPixWidth = $nPixDist; $nConvertedPixHeight = $dMainMapRatio * $nPixDist; } else { // calculate the pixel height of zoom box $nPixDist = $nMaxy - $nMiny; // determine main map width and height ratio $dMainMapRatio = $nMapWidth/$nMapHeight; // convert the pixel values to be in the same ratio as the main map $nConvertedPixWidth = $dMainMapRatio * $nPixDist; $nConvertedPixHeight = $nPixDist; } // update the coordinates $nMinx = $nMidX - ($nConvertedPixWidth/2); $nMaxx = $nMidX + ($nConvertedPixWidth/2); $nMiny = $nMidY - ($nConvertedPixHeight/2); $nMaxy = $nMidY + ($nConvertedPixHeight/2); } } ?>