[fusion-commits] r1932 - in trunk/layers/MapServer: . php
svn_fusion at osgeo.org
svn_fusion at osgeo.org
Tue Oct 6 17:50:24 EDT 2009
Author: pdeschamps
Date: 2009-10-06 17:50:23 -0400 (Tue, 06 Oct 2009)
New Revision: 1932
Modified:
trunk/layers/MapServer/MapServer.js
trunk/layers/MapServer/php/Maptip.php
Log:
bug#62 Added scalerange check in js and pushed visible layers to the
Maptip.php
Modified: trunk/layers/MapServer/MapServer.js
===================================================================
--- trunk/layers/MapServer/MapServer.js 2009-10-05 18:23:10 UTC (rev 1931)
+++ trunk/layers/MapServer/MapServer.js 2009-10-06 21:50:23 UTC (rev 1932)
@@ -817,6 +817,20 @@
var geometry = 'POLYGON(('+ minx + ' ' + miny + ', ' + minx + ' ' + maxy + ', ' + maxx + ' ' + maxy + ', ' + maxx + ' ' + miny + ', ' + minx + ' ' + miny + '))';
var selectionType = "INTERSECTS";
+ var aVisLayers = [];
+
+ for(var i = 0; i<this.aLayers.length;i++ ){
+ var iLayerMinScale = this.aLayers[i].scaleRanges[0].minScale;
+ var iLayerMaxScale = this.aLayers[i].scaleRanges[0].maxScale;
+ var iCurrentScale = this.mapWidget.getScale();
+
+ if(iCurrentScale < iLayerMaxScale && iCurrentScale > iLayerMinScale){
+ if(this.aLayers[i].isVisible() === true){
+ aVisLayers.push(this.aLayers[i].layerName);
+ }
+ }
+ }
+
var loadmapScript = '/layers/'+ this.arch + '/php/Maptip.php';
var params = {
'mapname': this._sMapname,
@@ -827,7 +841,9 @@
'layer': oMapTips.aLayers || '',
'textfield': oMapTips.aTextFields || '',
'label': oMapTips.aLabels || '',
- 'customURL': oMapTips.aCustomURL || ''
+ 'customURL': oMapTips.aCustomURL || '',
+ 'visLayers' : aVisLayers
+
}
var parseMapTip = this.parseMapTip.bind(this);
this.bMapTipFired = true;
Modified: trunk/layers/MapServer/php/Maptip.php
===================================================================
--- trunk/layers/MapServer/php/Maptip.php 2009-10-05 18:23:10 UTC (rev 1931)
+++ trunk/layers/MapServer/php/Maptip.php 2009-10-06 21:50:23 UTC (rev 1932)
@@ -63,6 +63,7 @@
/* a spatial filter in the form on a WKT geometry */
$spatialFilter = (isset($_REQUEST['spatialfilter']) && $_REQUEST['spatialfilter'] != '') ? urldecode($_REQUEST['spatialfilter']) : false;
+
header('Content-type: application/json');
header('X-JSON: true');
@@ -82,52 +83,63 @@
$aURL = array();
$aTipLabel = array();
foreach($aLayer as $key=>$layer){
- $oLayer = @$oMap->GetLayerByName($layer);
+ if(isLayerVisible($layer) === TRUE){
+ $oLayer = @$oMap->GetLayerByName($layer);
- // make sure the layer exists in the map.
- if(is_object($oLayer)){
- $oLayer->set('tolerance', 0);
+ // make sure the layer exists in the map.
+ if(is_object($oLayer)){
+ $oLayer->set('tolerance', 0);
- if ($oLayer->type == MS_LAYER_RASTER || $oLayer->type == MS_LAYER_QUERY ||
- $oLayer->type == MS_LAYER_CIRCLE || $oLayer->type == MS_LAYER_CHART) {
- die("{'error':'maptips are only valid for vector layers'}");
- }
+ if ($oLayer->type == MS_LAYER_RASTER || $oLayer->type == MS_LAYER_QUERY ||
+ $oLayer->type == MS_LAYER_CIRCLE || $oLayer->type == MS_LAYER_CHART) {
+ die("{'error':'maptips are only valid for vector layers'}");
+ }
- if (@$oLayer->queryByShape($oSpatialFilter) == MS_SUCCESS) {
+ if (@$oLayer->queryByShape($oSpatialFilter) == MS_SUCCESS) {
- $oRes = $oLayer->getResult(0);
- $oLayer->open();
+ $oRes = $oLayer->getResult(0);
+ $oLayer->open();
- $oShape = $oLayer->getShape($oRes->tileindex,$oRes->shapeindex);
+ $oShape = $oLayer->getShape($oRes->tileindex,$oRes->shapeindex);
- $szMapTipText .= $oLayer->name." : ".$oShape->values[$aMapTipTextField[$key]].$szBreak;
+ $szMapTipText .= $oLayer->name." : ".$oShape->values[$aMapTipTextField[$key]].$szBreak;
- $szLabels = $aLabel[$key];
+ $szLabels = $aLabel[$key];
- $szMapTip = $oShape->values[$aMapTipTextField[$key]];
- $szURL = buildCustonUrl($oShape->values,$aMapTipURL[$key]);
+ $szMapTip = $oShape->values[$aMapTipTextField[$key]];
+ $szURL = buildCustonUrl($oShape->values,$aMapTipURL[$key]);
- $szMapTip = $szMapTip != "undefined" ? $szMapTip : "";
- $szURL = $szURL != "undefined" ? $szURL : "";
- $szLabels = $szLabels != "undefined" ? $szLabels : "";
+ $szMapTip = $szMapTip != "undefined" ? $szMapTip : "";
+ $szURL = $szURL != "undefined" ? $szURL : "";
+ $szLabels = $szLabels != "undefined" ? $szLabels : "";
+ array_push($aMapTips, $szMapTip);
+ array_push($aURL, $szURL);
+ array_push($aTipLabel,$szLabels);
- array_push($aMapTips, $szMapTip);
- array_push($aURL, $szURL);
- array_push($aTipLabel,$szLabels);
-
- $oLayer->close();
+ $oLayer->close();
+ }
}
}
}
- echo "{'maptips':".var2json($aMapTips).",'url':".var2json($aURL).",'label':".var2json($aTipLabel)."}";
+ echo "{'maptips':".var2json($aMapTips).",'url':".var2json($aURL).",'label':".var2json($aTipLabel).",'test':'casper'}";
}
else
{
echo "{'maptips':'','url':'','label':''}";
}
+function isLayerVisible($szLayerName){
+ $aVisLayers = split(",",$_POST["visLayers"]);
+ foreach($aVisLayers as $item){
+ if(trim($szLayerName) == trim($item)){
+ return true;
+ }
+ }
+ return false;
+}
+
function buildCustonUrl($aValues,$url){
if($url != ""){
More information about the fusion-commits
mailing list