[Gfoss] Openlayers e popup

Luca Delucchi lucadeluge a gmail.com
Mer 20 Maggio 2009 11:54:44 CEST


Ciao a tutti, sto facendo un po' di prove con Openlayers ora ho due
problemi con i layer wfs.
Primo è possibile assegnare un simbolo diverso dal rombo rosso? io ho
provato utilizzando del codice che con i GML funziona correttamente ma
con il wfs non va; secondo non riesco a visualizzare i popup, ho
seguito un po' gli esempi ma non riesco a farlo andare.
Di seguito vi metto il codice che utilizzo.

Ciao e grazie
Luca

function initMap(){

    	//Creo la mappa e definisco alcuni controlli di base
    	var map = new OpenLayers.Map('map',{controls:[
        	new OpenLayers.Control.Navigation(),
        	new OpenLayers.Control.PanZoomBar(),
        	new OpenLayers.Control.MousePosition()
    		],  projection: new OpenLayers.Projection("EPSG:32632"),
        	displayProjection: new OpenLayers.Projection("EPSG:32632"),
		units: "meters",
		maxResolution: 1565.0399,
		maxExtent: new OpenLayers.Bounds(609421,5056000,731000,5159000)}
	);

     	var base = new OpenLayers.Layer.WMS("IASMA_WMS_base",
"http://localhost/cgi-bin/mapserv?map=/home/gis/mapserver/cartocomune_wms.map&",{layers:
'comuni,idrografia,nome_comuni', transparent:true}, {isBaseLayer:
true});

    	var usosuolo = new OpenLayers.Layer.WMS("IASMA_WMS_usosuolo",
"http://localhost/cgi-bin/mapserv?map=/home/gis/mapserver/cartocomune_wms.map&",{layers:
"uso_suolo"}, {isBaseLayer: false});

     	var comuni = new OpenLayers.Layer.WMS("IASMA_WMS_comuni",
"http://localhost/cgi-bin/mapserv?map=/home/gis/mapserver/cartocomune_wms.map&",{layers:
"comuni", transparent:true}, {isBaseLayer: false});

	var symbolizer = OpenLayers.Util.applyDefaults(
	{fillColor:'#68228B', fillOpacity: 0.9, strokeColor: '#B23AEE',
strokeWidth: "5", strokeOpacity: 0.6},
	OpenLayers.Feature.Vector.style["default"]);
 	styleMap = new OpenLayers.StyleMap({"default": symbolizer});

	var vigneti_centroidi = new OpenLayers.Layer.WFS("centroidi_cavit",
"http://localhost/cgi-bin/mapserv?map=/home/gis/mapserver/wfs_previsione.map",
{typename: "Indici_vendemmia", maxfeatures: 1000}, {styleMap:
styleMap, featureClass: OpenLayers.Feature.WFS, format:
OpenLayers.Format.WFS, formatOptions: {extractAttributes:true}})

	//Aggiungo i layer alla mappa
	map.addLayer(base);
	map.addLayer(usosuolo);
	map.addLayer(comuni);
	map.addLayer(vigneti);
	map.addLayer(vigneti_centroidi);

	var selectControl = new OpenLayers.Control.SelectFeature(vigneti_centroidi,
	{onSelect: onFeatureSelectWeb, onUnselect: onFeatureUnselect});
 	map.addControl(selectControl);
 	selectControl.activate();

	function onPopupClose(evt) {
            	selectControl.unselect(selectedFeature);
        }
	function onFeatureSelectWeb(feature) {

 		selectedFeature = feature;

     		for(var key in feature.attributes)
	               	popup = new OpenLayers.Popup.FramedCloud("chicken",
feature.geometry.getBounds().getCenterLonLat(),
                		null,"<html><iframe
src='http://10.0.101.11/MapFish-1.1/client/mio_primo/clima/show_clima.php?id="+feature.attributes.id_vigneto+"'
height='100%' width='100%'></iframe></html>", null, true,
onPopupClose,{'autoSize': true});
	              	feature.popup = popup;
        	       	map.addPopup(popup);
	}


        function onFeatureUnselect(feature) {
		map.removePopup(feature.popup);
            	feature.popup.destroy();
            	feature.popup = null;
        }
}


Maggiori informazioni sulla lista Gfoss