Hi,
I am new to Geoserver so please be gentle!
I have created a thin client to view some layers from Geoserver. I attach
the html below which shows my coding for this. You may not be able to view
the layers as the servers are internal.
I want to be able to click on features within all layers and for the
attribution to be displayed for each feature when I click on it. Ideally, I
would like to be able to click on a point in a layer and a baloon pops up
with all (or some) attribition associated with that feature.
Would be grateful if someone could have a look at the attached code and add
a section of code to reflect what I require above. This would greatly help
me!
Thanks.
Nick
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Nick's Experiment with Geoserver</title>
<link rel="stylesheet"
href="http://openlayers.org/dev/theme/default/style.css" type="text/css" />
<link rel="stylesheet" href="style.css" type="text/css" />
<!--set up size of map on screen-100% of width, 400 pixels in
height-->
<style type="text/css">
#controls
{
width: 100%;
height: 700px;
}
</style>
<!--Get Open Layers JavaScript library-->
<script src="http://openlayers.org/dev/OpenLayers.js"
type='text/javascript'></script>
<script type="text/javascript">
<!--When loading tiles from 3rd party, good to have re-tries for
tiles not delivered on first request-->
OpenLayers.IMAGE_RELOAD_ATTEMPTS = 3;
OpenLayers.Util.onImageLoadErrorColor = "transparent";
<!--Creates variable that will be the map object-->
var map;
<!--Creates variables to designate initial view of map-->
var lon = -180;
var lat = -180;
var zoom = 2;
<!--Initial function that fires when page is loaded-->
function init(){
<!--create OpenLayers map object-->
map = new OpenLayers.Map( 'map' );
<!--SET UP BASEMAP LAYERS-->
<!--State Outlines from the BLM-->
var blm_states = new OpenLayers.Layer.WMS("ARCS",
" http://211.55.30.20/System.wms",
{layers: "ARCS", reaspect: "false",transparent:
"true"}, {isBaseLayer: true, singleTile: true, ratio: 1, visibility:true});
<!--***NOTE the 'singleTile' parameter: layers with
labels will often have distracting-->
<!-- duplicate labeling when streamed normally as
tiles-->
<!--USGS Topos-->
var worldmap = new OpenLayers.Layer.WMS( "Global Image",
"http://211.55.30.20/System.wms",
{layers: "Bathymetry", reaspect:
"false"},{singleTile: false, ratio: 1, isBaseLayer: true});
var Vector = new OpenLayers.Layer.WMS( "Vector Base",
"http://211.55.30.20/System.wms",
{layers: "Vector", reaspect: "false"},{singleTile:
false, ratio: 1, isBaseLayer: true});
<!--SET UP OVERLAY LAYERS-->
var blm_lease = new OpenLayers.Layer.WMS("British
point",
"http://62.172.108.29/geoserver/wms",
{layers: "geoserver_layer", reaspect: "false",
transparent: "true"},{isBaseLayer: false,visibility:false});
<!--***NOTE the 'reaspect' parameter set to false for
BLM layers. For WMS services emanating from ArcIMS,-->
<!-- this parameter often needs to be included for
layers to overlay correctly in non-ESRI viewers-->
var sale_lease = new OpenLayers.Layer.WMS("British point
2",
"http://20.180.555.29/geoserver/wms",
{layers: "geoserver2_layer", reaspect: "false",
transparent: "true"}, {isBaseLayer: false, visibility:false});
var blm_land = new OpenLayers.Layer.WMS("British point
3",
"http://20.180.555.29/geoserver/wms",
{layers: "geoserver3_layer", reaspect:
"false",transparent: "true"}, {isBaseLayer: false, visibility:false});
<!--***NOTE we are requesting multiple layers from the
same WMS service. For large datasets, there will often be-->
<!-- an 'overview' layer at zoomed-out scales with a
more detailed layer closer in so as to improve performance-->
var nf_land = new OpenLayers.Layer.WMS("National
Forests",
"http://www.geocommunicator.gov:80/wmsconnector/com.esri.wms.Esrimap/BLM_MAP_SURFACE_MGT_AGY",
{layers: "National Forest Labels,National Forests
Dissolved,National Forests", reaspect: "false",transparent: "true"},
{isBaseLayer: false, singleTile: true, ratio: 1, visibility:false});
<!--***NOTE the 'singleTile' parameter: layers with
labels will often have distracting-->
<!-- duplicate labeling when streamed normally as
tiles-->
<!--Pulling a Census Block Group layer from the new
DRCOG WMS Service-->
var drcog_blk = new OpenLayers.Layer.WMS("DRCOG Census
Blk Grps",
"http://gis.drcog.org/geoserver/wms?",
{layers: "bg2000", transparent: "true"},
{visibility:false, isBaseLayer: false});
<!--Add layers to the map object-->
map.addLayers([blm_states,worldmap,Vector,sale_lease,blm_lease,blm_land]);
<!--***NOTE: the order in which they are added determines
their order in the layer switcher menu-->
<!--Add layer switcher menu (with custom color)-->
var ls = new
OpenLayers.Control.LayerSwitcher({'div':OpenLayers.Util.getElement('layerswitcher'),activeColor:'#660066'})
map.addControl(ls);
<!--Add lat/long read-out to the menu-->
map.addControl( new OpenLayers.Control.MousePosition() );
<!--Add zoom and pan controls to map-->
var panel = new OpenLayers.Control.NavToolbar();
map.addControl(panel);
<!--Add lat/long read-out to the menu-->
map.addControl(new OpenLayers.Control.Scale($('scale')));
<!--Have the layer menu already expanded when page is
loaded-->
ls.maximizeControl();
<!--Set the initial view of map using variables defined
above-->
map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
map.addControl(new OpenLayers.Control.OverviewMap());
map.addControl(new OpenLayers.Control.Attribution());
map.addControl(new OpenLayers.Control.SelectFeature('blm_lease'));
}
<!--END OF OPEN LAYERS JavaScript-->
</script>
</head>
<!--HTML-->
<body onload="init()">
<p style="font-family:verdana;font-size:10pt">
LAND Object Service
</p>
<hr>
<br>
<!--LOAD MAP INTO A DIV-->
<div id="controls">
<div id="map" class="smallmap"></div>
</div>
</body>
</html>
--
View this message in context: http://n2.nabble.com/Feature-Info-tp3231951p3231951.html
Sent from the GeoServer developers mailing list archive at Nabble.com.