Re: [Portugal] Não consigo visualizar as layers WFS...
Pedro Venâncio
pedrongvenancio at yahoo.com
Fri Jun 11 05:55:33 EDT 2010
Olá bom dia,
Também estou a iniciar-me no Geoserver (há cerca de uma semana) e tenho este mesmo problema do Oscar.
Fazendo a edição com o uDig via WFS-T, tudo corre bem, consigo ver o resultado da edição, tanto na base de dados, como no QGIS, mal faço "Commit changes" no uDig.
No entanto, utilizando o exemplo wfs-t.html, mesmo com as alterações da bbox que resolveram o problema ao Oscar, não consigo visualizar o WFS. Aliás, com os as alterações do Oscar, nem aparecem os WMS, nem sequer os controlos do OpenLayers.
Deixo aqui o código que estou a testar:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="stylesheet" href="http://localhost:8080/geoserver/style.css" type="text/css" />
<style type="text/css">
body {
margin: 1em;
}
#map {
width: 800px;
height: 475px;
border: 1px solid black;
}
</style>
<script src="http://openlayers.org/api/OpenLayers.js"></script>
<script type="text/javascript">
OpenLayers.IMAGE_RELOAD_ATTEMPTS = 3;
var map;
function init(){
var bounds = new OpenLayers.Bounds(
71085.954, 100001.161,
102603.730, 145416.122
);
var options = {
controls: [],
maxExtent: bounds,
maxResolution: 87.17609375,
projection: "EPSG:3763",
units: 'm'
};
map = new OpenLayers.Map('map', options);
var vias = new OpenLayers.Layer.WMS(
"Rede Viaria",
"http://localhost:8080/geoserver/wms",
{layers: 'pinhel:rede_viaria',
projection: new OpenLayers.Projection("EPSG:3763"),
displayProjection: new OpenLayers.Projection("EPSG:3763"),
format: 'image/png'}
);
pedreiras.style = OpenLayers.Util.applyDefaults({strokeColor: "#ff0000"},
OpenLayers.Feature.Vector.style["default"]);
var ocorrencias = new OpenLayers.Layer.WFS(
"Ocorrências",
"http://localhost:8080/geoserver/wfs",
{typename: 'pinhel:ocorrencias'},
{
typename: 'ocorrencias',
featureNS: 'http://localhost:8080/pinhel',
extractAttributes: false,
srsName: 'EPSG:3763',
geometryName: 'the_geom'
}
);
ocorrencias.style = OpenLayers.Util.applyDefaults({strokeColor: "#0000ff"},
OpenLayers.Feature.Vector.style["default"]);
map.addLayers([vias, ocorrencias]);
var panel = new OpenLayers.Control.Panel(
{displayClass: 'olControlEditingToolbar'}
);
var drawLine = new OpenLayers.Control.DrawFeature(
eixos_via, OpenLayers.Handler.Path,
{displayClass: 'olControlDrawFeaturePath'}
);
drawLine.featureAdded = function(feature) {
feature.layer.eraseFeatures([feature]);
// cast to multilinestring
feature.geometry = new OpenLayers.Geometry.MultiLineString(
feature.geometry
);
feature.style.strokeColor = "#ff0000";
feature.state = OpenLayers.State.INSERT;
feature.layer.drawFeature(feature);
}
var drawPoint = new OpenLayers.Control.DrawFeature(
pontos_interesse, OpenLayers.Handler.Point,
{displayClass: 'olControlDrawFeaturePoint'}
);
drawPoint.featureAdded = function(feature) {
feature.layer.eraseFeatures([feature]);
feature.style.strokeColor = "#0000ff";
feature.state = OpenLayers.State.INSERT;
feature.layer.drawFeature(feature);
}
panel.addControls(
[new OpenLayers.Control.Navigation(), drawLine, drawPoint]
);
map.addControl(panel);
map.addControl(new OpenLayers.Control.LayerSwitcher());
map.addControl(new OpenLayers.Control.ScaleLine());
map.addControl(new OpenLayers.Control.PanZoomBar());
map.addControl(new OpenLayers.Control.MousePosition());
map.zoomToExtent(bounds);
}
</script>
</head>
<body onload="init()">
<h3>OpenLayers WFS-T demo: Tasmania cities and roads</h3>
<a href="#" onclick="map.layers[2].commit();return false">Save Roads</a><br />
<a href="#" onclick="map.layers[3].commit();return false">Save Cities</a>
<div id="map"></div>
</body>
</html>
Abraço!
Pedro Venâncio
-------------- próxima parte ----------
Um anexo em HTML foi limpo...
URL: http://lists.osgeo.org/pipermail/portugal/attachments/20100611/90a2c9a5/attachment-0001.html
More information about the Portugal
mailing list