[OpenLayers-Users] some questions about popup extent & hyperlink
beppe
beppenapo at gmail.com
Mon Dec 21 10:22:42 EST 2009
Hi,
I'm an italian OL's newbie, I come from a mapserver world and I'm very
happy to discover every day something about OpenLayers!
I've this code [1] and this mapfile [2], the geographic elements are
stored in a postgis table.
The code works but in the popup window, info are displayed like this:
"GetFeatureInfo results: Layer 'ut' Feature 78: paese = 'Coredo'
localita = 'S. Barbara'"
Obviously I don't want info about "GetFeatureInfo", "Layer" and
"Feature", but only about "paese" and "localita".
The info, then, are print like a "text string". I'd want print the info
in table style...but I don't know how !!!
Question 2.
I'd like to have in popup an hyperlink to a page in wich print a map
with the extent of the selected feature, but:
1. my feature are point
2. I don't know how write the code!!!
Any ideas, example or tutorial?
thanks
-beppe-
[1]
OpenLayers.ProxyHost = "http://localhost/cgi-bin/proxy.cgi?url=";
var map;
var info;
// pink tile avoidance
OpenLayers.IMAGE_RELOAD_ATTEMPTS = 5;
// make OL compute scale according to WMS spec
OpenLayers.DOTS_PER_INCH = 25.4 / 0.28;
function init(){
var format = 'image/png';
var bounds = new OpenLayers.Bounds(
653890.824038, 5121367.412500, 673982.300962, 5139410.087500
);
var options = {
controls: [],
maxExtent: bounds,
maxResolution: 40.83535156249854,
projection: "EPSG:3003",
units: 'm'
};
map = new OpenLayers.Map('map', options);
// setup comuni
var comuni = new OpenLayers.Layer.WMS(
"comuni",
"http://localhost/cgi-bin/mapserv?map=/var/www/vervo/config/default/pmapper_demo.map&",
{layers: 'confini_com',
tiled: 'true',
tilesOrigin : "657732.15,5120937.825",
},{buffer: 0}
);
map.addLayer(comuni);
var ctr = new OpenLayers.Layer.WMS("ctr",
"http://localhost/cgi-bin/mapserv?map=/var/www/vervo/config/default/pmapper_demo.map&",
{layers: 'ctr',
srs: 'EPSG:3003',
tiled: 'true',
transparent: 'true',
format: format});
map.addLayer(ctr);
// setup ut
var ut = new OpenLayers.Layer.WMS(
"ut",
"http://localhost/cgi-bin/mapserv?map=/var/www/vervo/config/default/pmapper_demo.map&",
{srs: 'EPSG:3003',
layers: 'ut',
styles: '',
format: format,
tiled: 'true',
tilesOrigin : "658390.746875,5121279.4",
transparent: 'true'
},
{buffer: 0}
);
map.addLayer(ut);
// build up all controls
map.addControl(new OpenLayers.Control.PanZoomBar({
position: new OpenLayers.Pixel(2, 15)
}));
map.addControl(new OpenLayers.Control.Navigation());
map.addControl(new OpenLayers.Control.Scale($('scale')));
map.addControl(new OpenLayers.Control.MousePosition({element:
$('location')}));
map.zoomToExtent(bounds);
//Crea pop-up info
var createPopup = function(response) {
var lonlat = map.getLonLatFromViewPortPx(this.xy);
var popup = new OpenLayers.Popup.FramedCloud(
"chicken",lonlat, null,response.responseText,null,true);
popup.setBackgroundColor("#c1cdc1");
popup.setOpacity(0.7);
map.addPopup(popup, true /* exclusive */);
function onFeatureUnselect(event) {
var feature = event.feature;
if(feature.popup) {
map.removePopup(feature.popup);
feature.popup.destroy();
delete feature.popup;
}
}
};
// support GetFeatureInfo
map.events.register('click', map, function (e) {
var params = ut.getFullRequestString ({
REQUEST: "GetFeatureInfo",
EXCEPTIONS: "application/vnd.ogc.se_xml",
BBOX: map.getExtent().toBBOX(),
X: e.xy.x,
Y: e.xy.y,
INFO_FORMAT: 'text/plain',
//QUERY_LAYERS: ut.params.LAYERS,
QUERY_LAYERS: ut,
FEATURE_COUNT: 50,
RADIUS: 5,
Srs: 'EPSG:3003',
Layers: 'ut',
//Layers: 'topp:unita\'_territoriali',
//Styles: '',
WIDTH: map.size.w,
HEIGHT: map.size.h,
format: format},
"http://localhost/cgi-bin/mapserv?map=/var/www/vervo/config/default/pmapper_demo.map&SERVICE=WMS&VERSION=1.1.1&QUERY_LAYERS=ut"
);
// updateFeatureInfoFilters(params);
OpenLayers.loadURL(params, '', e, createPopup);
OpenLayers.Event.stop(e);
});
}
-------------------------------------------------
[2]
LAYER
NAME 'ut'
TYPE POINT
CONNECTIONTYPE postgis
CONNECTION "dbname='mydb' host=localhost port=5432 user='myuser'
password='mypwd'"
DATA 'ut_geo FROM public.ut using unique "id_ut" using SRID=3003'
PROJECTION
"init=epsg:3003"
END
TOLERANCEUNITS pixels
TOLERANCE 10
DUMP TRUE
TEMPLATE void
METADATA
"RESULT_FIELDS" "paese,localita"
"RESULT_HEADERS" "Paese, Localita'"
"wfs_title" "ut"
"wfs_featureid" "ut"
"wms_include_items" "paese,localita"
"ows_include_items" "paese, localita"
END
CLASS
NAME "Unita' territoriali"
STYLE
SYMBOL 'circle'
SIZE 8
OUTLINECOLOR 0 0 0
COLOR 222 255 22
END
END
END
More information about the Users
mailing list