Pages: 1
- Sujet précédent - probélme de GetFeature lors de plusieurs Layer ou un gourpe layer - Sujet suivant
#1 Sun 18 September 2011 15:08
- aminealaoui
- Juste Inscrit !
- Date d'inscription: 29 Aug 2011
- Messages: 3
probélme de GetFeature lors de plusieurs Layer ou un gourpe layer
bonjour ,
cher amies j'ai besoin de votre aide j’arrive pas a récupérer des informations sur ma couche grâce a la fonction OpenLayers.Control.GetFeature quand j'ai 2 couche mais pour une seul couche ça marche bien voici le code utilisé
Code:
<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script src="http://api.maps.yahoo.com/ajaxymap?v=3.0&appid=euzuro-openlayers"></script>
<link rel="stylesheet" href="/geoserver/style.css" type="text/css" />
<link rel="stylesheet" href="openlayers/theme/default/style.css" type="text/css" />
<style type="text/css">
body {
margin: 1em;
}
#map {
width: 95%;
height: 512px;
border: 1px solid gray;
}
div.olControlMousePosition {
color: white;
}
#bounds {
font-size: 0.9em;
}
</style>
<script src="http://openlayers.org/api/OpenLayers.js"></script>
<script type="text/javascript">
// make map available for easy debugging
var map;
// avoid pink tiles
OpenLayers.IMAGE_RELOAD_ATTEMPTS = 3;
OpenLayers.Util.onImageLoadErrorColor = "transparent";
function init(){
var options = {
// the "community" epsg code for spherical mercator
projection: "EPSG:900913",
// map horizontal units are meters
units: "m",
// this resolution displays the globe in one 256x256 pixel tile
maxResolution: 78271.51695,
// these are the bounds of the globe in sperical mercator
maxExtent: new OpenLayers.Bounds(-20037508, -20037508,
20037508, 20037508)
};
// construct a map with the above options
map = new OpenLayers.Map('map', options);
// create Yahoo layer (only the default layer works, the hibrid and the
// satellite ones do throw exceptions and rendering goes totally bye bye)
var yahoosat = new OpenLayers.Layer.Yahoo("Yahoo", {
sphericalMercator: true
});
// create WMS layer
var wms = new OpenLayers.Layer.WMS(
"ville",
"http://localhost:8080/geoserver/wms?",
{
layers: 'maroc:Villes_principales',
styles: '',
srs: 'EPSG:4326',
format: 'image/png',
tiled: 'true',
tilesOrigin : "143.60260815000004,-43.851764249999995",
transparent: true
},
{
'opacity': 0.75, 'isBaseLayer': false, 'wrapDateLine': true
}
);
var usBounds = new OpenLayers.Bounds(
-3123522.723286, 2000815.652034, 2996331.508242, 4505504.194434
);
select = new OpenLayers.Layer.Vector("Selection", {styleMap:
new OpenLayers.Style(OpenLayers.Feature.Vector.style["select"])
});
hover = new OpenLayers.Layer.Vector("Hover");
map.addLayers([yahoosat, wms]);
control = new OpenLayers.Control.GetFeature({
protocol: OpenLayers.Protocol.WFS.fromWMSLayer(wms),
box: true,
hover: true,
multipleKey: "shiftKey",
toggleKey: "ctrlKey"
});
control.events.register("featureselected", this, function(e) {
document.getElementById('repclique').innerHTML = 'amine';
select.addFeatures([e.feature]);
alert(e.feature.fid);
//document.getElementById('repclique').innerHTML = e.feature.attributes['nom'];
});
control.events.register("featureunselected", this, function(e) {
select.removeFeatures([e.feature]);
});
control.events.register("hoverfeature", this, function(e) {
hover.addFeatures([e.feature]);
});
control.events.register("outfeature", this, function(e) {
hover.removeFeatures([e.feature]);
});
map.addControl(control);
control.activate();
map.addControl(new OpenLayers.Control.LayerSwitcher());
map.zoomToExtent(usBounds);
}
</script>
</head>
<body onLoad="init()">
<h3>eoserver OpenLayers </h3>
<div id="map"> </div>
<div id="repclique">
<em>Click on the map to get feature info</em>
</div>
<p> </p>
</body>
</html>et Merci d'avance
Hors ligne
Pages: 1
- Sujet précédent - probélme de GetFeature lors de plusieurs Layer ou un gourpe layer - Sujet suivant


