Message posté par : remi_c (remi-c(a)live.fr)
----------------------------------------
Bonjour,
Suite à pas mal de recherche sur internet, je n'arrive pas à afficher ma couche en WFS
avec OpenLayers. En WMS, celle-ci s'affichait bien mais étant donné que je veux
pouvoir afficher les informations d'un point en cliquant dessus, il était plus simple
de le faire en WFS (et aussi parce que j'aimerais pouvoir afficher en WFS et WMS,
histoire d'acquérir un peu d’expérience).
Voici mon code java :
-----------------
Code :
var osm = new ol.layer.Tile({
source: new ol.source.OSM({
crossOrigin: ''
})
});
var vectorSource = new ol.source.Vector({
format: new ol.format.GML3({srsName: 'EPSG:3857'}),
url:
'https://ggat.alwaysdata.net/cgi-bin/mapserv?service=wfs&version=1.1.0&request=GetFeature&map=/home/ggat/www/html/stages.map&typename=stages&',
projection:'EPSG:3857'
});
var vecteur = new ol.layer.Vector({
source : vectorSource,
name: 'stages'
});
var view = new ol.View({
center: [310640.0830, 5801876.1950],
zoom: 5
});
//Création de la carte
var map = new ol.Map({ //Ajout de la couche OSM
layers: [osm,vecteur],
target: 'map',
controls : ol.control.defaults().extend([ //Ajouter des fonctionnalités
new ol.control.ScaleLine(), //Ajouter une échelle
new ol.control.FullScreen() //Ajouter l'option plein écran
]), //fin de controle
view : view
});
-----------------
Et mon MapFile :
-----------------
Code :
MAP
IMAGETYPE PNG
EXTENT -20000000 -20000000 20000000 20000000
SIZE 900 900
IMAGECOLOR 255 255 255
SYMBOLSET "/home/ggat/www/html/position.sym"
PROJECTION
"init=epsg:3857"
END
WEB
TEMPLATE "template_stage.html"
METADATA
"wfs_title" "wfs Server Demonstration"
"wfs_onlineresource"
"https://ggat.alwaysdata.net/cgi-bin/mapserv?map=/home/ggat/www/html/stages.map"
"wfs_srs" "EPSG:3857"
"wfs_enable_request" "*"
END
END
OUTPUTFORMAT
NAME "geojson"
DRIVER "OGR/GEOJSON"
MIMETYPE "application/json; subtype=geojson"
FORMATOPTION "STORAGE=stream"
FORMATOPTION "FORM=SIMPLE"
END
SCALEBAR
LABEL
COLOR 0 0 0
SIZE SMALL
END
END
LAYER
NAME stages
TYPE POINT
STATUS ON
T -20000000 -20000000 20000000 20000000
CONNECTIONTYPE POSTGIS
CONNECTION "host=postgresql-ggat.alwaysdata.net port=5432
dbname='ggat_webmapping' /* Les infos de connexions (privées)*/ "
DATA "geom from webmapping_stages USING UNIQUE id"
PROJECTION
"init=epsg:3857"
END
DUMP TRUE
METADATA
"wfs_title" "les stages"
"wfs_srs" "EPSG:3857"
"gml_include_items" "all"
"gml_featureid" "ID"
"wfs_enable_request" "*"
"wfs_getfeature_formatlist" "geojson"
END
CLASS
NAME "Stages"
STYLE
symbol 'pointeur'
size 30
END
END
END
END
-----------------
----------------------------------------
Le message est situé
https://georezo.net/forum/viewtopic.php?pid=330721#p330721
Pour y répondre : webmapping(a)ml.georezo.net ou reply de votre messagerie
Pour vous désabonner connectez-vous sur le forum puis Profil / Abonnement
--
Association GeoRezo - le portail géomatique
https://georezo.net