[mapserver-users] Variable-substitution cause WMS GetFeatureInfo error

AlessioDL alessio.dilorenzo at gmail.com
Thu Aug 27 04:41:33 EDT 2009


I post the my code... hope this "helps to help" :-)

Mapfile layer:

          LAYER
                NAME 			"QueryAreas"
		TYPE 			POLYGON
		CONNECTIONTYPE 	postgis
		CONNECTION		"host=localhost user=***password=*** dbname=***"
		DATA			"the_geom FROM (SELECT * FROM areas)AS foo USING UNIQUE gid USING
SRID=4326"
		FILTER 			"YEAR = %YEAR%"
		METADATA
			"wms_title" 					"Query Areas"
			"wms_include_items" 			"all"
			"wms_exclude_items"			"the_geom"
		END
		DUMP TRUE
		STATUS ON
		TRANSPARENCY ALPHA
		CLASS
			TEMPLATE 		"../TemplateMS/areas.html"
			NAME "Areas"
			STYLE
				SYMBOL 		 "simpleline"
				SIZE		 2
				OUTLINECOLOR 0 0 0
				COLOR		 255 127 36
			END #Style end
		END #Class end
	END #Layer end

OpenLayers code:

[code]
var map, qAreas, year;
var wmsURL =
"http://correggiov3/cgi-bin/mapserv.exe?map=/ms4w/apps/caps_manager/Mapfiles/wms.map";
var cgiURL = "http://correggiov3/cgi-bin/mapserv.exe?";
var proj4326 = new OpenLayers.Projection("EPSG:4326");
var proj900913 = new OpenLayers.Projection("EPSG:900913");


function initMap(){
    
	OpenLayers.IMAGE_RELOAD_ATTEMPTS = 3;
	OpenLayers.Util.onImageLoadErrorColor = "transparent";
	
	startBounds = new
OpenLayers.Bounds(1297594.634132,5197717.568058,2178149.1998195,5818997.7338486);
	
    options = {
	    controls:[],
	    projection: new OpenLayers.Projection("EPSG:900913"),
	    displayProjection: new OpenLayers.Projection("EPSG:4326"),
	    units: "m",
	    numZoomLevels: 18,
	    maxResolution: 156543.0339,
	    maxExtent: new
OpenLayers.Bounds(-20037508,-20037508,20037508,20037508.34)
    };
    
    map = new OpenLayers.Map('map', options);
    
    // create Google Mercator Layers
    var gphy = new OpenLayers.Layer.Google("Google Terrain",{type:
G_PHYSICAL_MAP, 'sphericalMercator': true});
    var gmap = new OpenLayers.Layer.Google("Google
Streets",{'sphericalMercator': true});
    var gsat = new OpenLayers.Layer.Google("Google Satellite",{type:
G_SATELLITE_MAP, 'sphericalMercator': true});
    var ghyb = new OpenLayers.Layer.Google("Google Hybrid",{type:
G_HYBRID_MAP, 'sphericalMercator': true};
    
    
    // add Layers array
    map.addLayers([gphy,gmap,gsat,ghyb]);
    
    // add simple Controls
    map.addControl(new OpenLayers.Control.LayerSwitcher());
    map.addControl(new OpenLayers.Control.MousePosition(/*{div:
$('coord')}*/));
    map.zoomToExtent(startBounds);
    
   /*
    * GetFeatureInfo - Pupup
    * **********************
    */
    
    var info = new OpenLayers.Control.WMSGetFeatureInfo({
        url:
"http://correggiov3/cgi-bin/mapserv.exe?map=/ms4w/apps/caps_manager/Mapfiles/wms.map", 
        title: 'Identify features by clicking',
        queryVisible: true,
        eventListeners: {
            getfeatureinfo: function(event) {
                map.addPopup(new OpenLayers.Popup.FramedCloud(
                    "chicken", 
                    map.getLonLatFromPixel(event.xy),
                    null,
                    event.text,
                    null,
                    true
                ));
            }
        }
    });
    map.addControl(info);
    info.activate();

} //end initMap

/*
 * Add the filtered layer
 * **********************
 */
function addQueryLayers(){
	
	year = document.forms['queryForm'].elements["year"].value;
	areaType = document.forms['queryForm'].elements["areaType"].value;

	qAreas = new OpenLayers.Layer.WMS("Selected areas", wmsURL, {
		map:"/ms4w/apps/caps_manager/Mapfiles/wms.map",year:year,
		layers: 'QueryAreas',
		format:'image/png',
		transparent:'true'
	}, {'isBaseLayer':false});
    
	map.addLayer(qAreas);

}
[/code]

-- 
View this message in context: http://n2.nabble.com/Variable-substitution-cause-WMS-GetFeatureInfo-error-tp3515191p3522732.html
Sent from the Mapserver - User mailing list archive at Nabble.com.


More information about the mapserver-users mailing list