#1 Tue 15 February 2011 15:08
- WWS
- Participant occasionnel
- Date d'inscription: 11 Oct 2010
- Messages: 16
OpenLayers - Mapserver - WFS
Bonjour,
Besoin d'aide ...
Le problème : je n'arrive pas à afficher, par openlayers, des données issues de MapServer en WFS. En WMS, ça fonctionne.
J'ai cherché (longtemps) une solution en parcourant les forums et autres tutoriaux, sans succès. Je pense que le problème vient du .map plutôt que du .php, mais je mets les deux ci-dessous.
Le mapfile :
Code:
MAP
NAME "Admin_Indonesie_WFS"
SIZE 550 350
EXTENT 95 -10 132 5
UNITS METERS
IMAGECOLOR 255 255 255
SHAPEPATH "/var/www/mapserver/test"
TRANSPARENT ON
PROJECTION
"init=epsg:4326"
END
WEB
IMAGEPATH "/var/www/mapserver/test/tmp/"
IMAGEURL "/mapserver/test/tmp/"
METADATA
"original_projection" "init=epsg:4326"
"wfs_title" "TestWFS"
"wfs_onlineresource" "http://127.0.0.1/cgi-bin/mapserv?"
"wfs_srs" "epsg:4326"
END
END
LAYER
CONNECTIONTYPE WFS
CONNECTION "/var/www/mapserver/test/indonesie_surface.tab"
NAME Admin_Indonesie_WFS
METADATA
"wfs_onlineresource" "/var/www/mapserver/test/indonesie_surface.tab"
"wfs_version" "1.0.0"
"wfs_title" "TestWFS"
"wfs_srs" "ESPG:4326"
"gml_featureid" "SE_ASIA_"
"gml_include_items" "all"
END
CLASS
STYLE
COLOR 0 0 0
OUTLINECOLOR 255 255 255
END
END
TYPE LINE
DUMP TRUE
END
ENDEt le PHP :
Code:
<html>
<head>
<script type="text/javascript" src="http://127.0.0.1/openlayers/OpenLayers.js"></script>
<script type="text/javascript">
var map;
function init() {
map = new OpenLayers.Map('map', {
controls:[
new OpenLayers.Control.Navigation(),
new OpenLayers.Control.PanZoomBar(),
new OpenLayers.Control.LayerSwitcher(),
new OpenLayers.Control.Attribution()],
maxExtent: new OpenLayers.Bounds(95,-15,125,10),
units: 'dd',
projection: new OpenLayers.Projection("epsg:4326"),
displayProjection: new OpenLayers.Projection("epsg:4326")
} );
var wfs = new OpenLayers.Layer.WFS(
"Admin_Indonesie_WFS",
"http://127.0.0.1/cgi-bin/mapserv?map=/var/www/mapserver/test/testWFS.map&",
{TYPENAME: 'Admin_Indonesie_WFS',layers: 'Admin_Indonesie_WFS', format: 'image/jpeg' }, {buffer: 1, isBaseLayer: true} );
map.addLayers([wfs]);
map.addControl(new OpenLayers.Control.Scale('scale'));
map.addControl(new OpenLayers.Control.MousePosition());
}
</script>
</head>
<body onload="init()">
Test d'affichage de la carte d'Indonesie avec Openlayers en WFS sur MapServer.
<div id="map" style="width: 600px; height: 300px"></div>
</body>Pour info, les codes pour le test en WMS, qui eux fonctionnent bien :
Le mapfile :
Code:
MAP
NAME "Test"
SIZE 550 350
EXTENT 95 -10 132 5
UNITS METERS
IMAGECOLOR 255 255 255
SHAPEPATH "/var/www/mapserver/test"
TRANSPARENT ON
PROJECTION
"init=epsg:4326"
END
WEB
IMAGEPATH "/var/www/mapserver/test/tmp/"
IMAGEURL "/mapserver/test/tmp/"
END
OUTPUTFORMAT
NAME png
DRIVER "GD/PNG"
MIMETYPE "image/png"
IMAGEMODE PC256
EXTENSION "png"
END
LAYER
NAME Admin_Indonesie
STATUS ON
CONNECTIONTYPE OGR
CONNECTION "/var/www/mapserver/test/indonesie_surface.tab"
TYPE LINE
CLASS
STYLE
COLOR 0 0 0
OUTLINECOLOR 255 255 255
END
END
END
ENDet le PHP :
Code:
<html>
<head>
<script type="text/javascript" src="http://127.0.0.1/openlayers/OpenLayers.js"></script>
<script type="text/javascript">
var map;
function init() {
map = new OpenLayers.Map('map', {
controls:[
new OpenLayers.Control.Navigation(),
new OpenLayers.Control.PanZoomBar(),
new OpenLayers.Control.LayerSwitcher(),
new OpenLayers.Control.Attribution()],
maxExtent: new OpenLayers.Bounds(95,-15,125,10),
units: 'dd',
projection: new OpenLayers.Projection("epsg:4326"),
displayProjection: new OpenLayers.Projection("epsg:4326")
} );
var wms = new OpenLayers.Layer.WMS(
"Admin_Indonesie",
"http://127.0.0.1/cgi-bin/mapserv?map=/var/www/mapserver/test/test.map&",
{layers: 'Admin_Indonesie'}
);
map.addLayers([wms]);
map.zoomToMaxExtent();
}
</script>
</head>
<body onload="init()">
Test d'affichage de la carte d'Indonesie avec Openlayers en WMS sur MapServer.
<div id="map" style="width: 600px; height: 300px"></div>
</body>Merci d'avance pour votre aide !
Hors ligne
#2 Tue 15 February 2011 16:39
Re: OpenLayers - Mapserver - WFS
Tu peux jeter un coup d'oeil au tuto de geotribu : http://www.geotribu.net/node/42
"wfs_onlineresource" "/var/www/mapserver/test/indonesie_surface.tab"
me semble très incertain, car je ne suis pas sur que le niveau layer prend cet attribut et surtout car ca ne ressemble pas à une ressource en ligne.
Hors ligne
#3 Wed 16 February 2011 09:24
- WWS
- Participant occasionnel
- Date d'inscription: 11 Oct 2010
- Messages: 16
Re: OpenLayers - Mapserver - WFS
Merci pour ta réponse.
J'ai suivi de près les différents tutoriaux de Geotribu, ça a fonctionné en partie, mais pas pour le WFS.
Je vais continuer à chercher !
Je posterai la solution, si je trouve. D'ici là, autres avis bienvenus !!!!
Hors ligne
#4 Fri 29 March 2013 13:58
- icadedt
- Participant assidu
- Lieu: ici et là
- Date d'inscription: 21 Jul 2006
- Messages: 478
Re: OpenLayers - Mapserver - WFS
moi de mon côté j'arive à afficher du wfs mapserver dans openlayers.
Le probleme c'est que je souhaite que la couche wfs ne s'affiche plus à partir d'un certain niveau de zoom,
j'ai essayé maxscale et minscale mais cela ne marche pas.
Auriez-vous une solution pour ne plus afficher une couche wfs au dela d'une certaine echelle?
Hors ligne


