Bonjour chers tous,
je suis bloquée depuis quelques temps avec ce problème que je ne sais comment résoudre.
Je tente de créer une carte interactive afin de la mettre en ligne sur le site de ma boite.
Pour l'instant je n'en suis pas bien loin et malheureusement le temps me presse. J'ai généré un mapfile à partir de qgis afin de m'en servir avec mapserver. Seulement voilà, dans le mapfile j'ai un soucis de projection.
Je vous fais part des différents fichiers que j'utilise :
mapfile :
javascript :Code:# Map file created from QGIS project file C:/ms4w/apps/tutorial/htdocs/parcelles.qgs # Edit this file to customize for your map interface # (Created with PyQgis MapServer Export plugin) MAP NAME "QGIS-MAP" # Map image size SIZE 1000 1000 UNITS meters EXTENT 474020.891010 6459505.414628 476717.886595 6460896.580121 FONTSET './fonts/fonts.list' PROJECTION 'init=epsg:4326' 'proj=longlat' 'ellps=wgs84' 'datum=wgs84' 'no_defs' END # Background color for the map canvas -- change as desired IMAGECOLOR 255 255 255 IMAGEQUALITY 95 IMAGETYPE agg OUTPUTFORMAT NAME agg DRIVER AGG/PNG IMAGEMODE RGB END # Legend LEGEND IMAGECOLOR 255 255 255 STATUS ON KEYSIZE 18 12 LABEL TYPE BITMAP SIZE MEDIUM COLOR 0 0 89 END END # Web interface definition. Only the template parameter # is required to display a map. See MapServer documentation WEB # Set IMAGEPATH to the path where MapServer should # write its output. IMAGEPATH '/tmp/' # Set IMAGEURL to the url that points to IMAGEPATH # as defined in your web server configuration IMAGEURL '/tmp/' # WMS server settings METADATA 'ows_title' 'QGIS-MAP' 'ows_onlineresource' 'http://localhost/cgi-bin/mapserv.exe?map=C:/ms4w/apps/tutorial/htdocs/EXP_parcelles.map' 'ows_srs' 'EPSG:4326' END #Scale range at which web interface will operate # Template and header/footer settings # Only the template parameter is required to display a map. See MapServer documentation TEMPLATE 'fooOnlyForWMSGetFeatureInfo' END LAYER NAME 'parcelles' TYPE POLYGON DUMP true TEMPLATE fooOnlyForWMSGetFeatureInfo EXTENT 474020.891010 6459505.414628 476717.886595 6460896.580121 DATA 'C:/SIG/SAINT_AULAYE/SOPHIE/SHP/parcelles.shp' METADATA 'ows_title' 'parcelles' END STATUS ON TRANSPARENCY 100 PROJECTION 'init=epsg:4326' 'proj=longlat' END CLASS NAME 'parcelles' STYLE WIDTH 0.91 OUTLINECOLOR 0 0 0 COLOR 255 193 151 END LABEL FONT arial TYPE truetype SIZE 9 COLOR 0 0 0 ANGLE 0 POSITION cc FORCE true ANTIALIAS true PARTIALS true END END END END
html:Code:var map, info; function init(){ var option = { projection: new OpenLayers.Projection("EPSG:4326"), units: "m", numZoomLevels: 14, maxExtent: new OpenLayers.Bounds () }; var ol_wms = new OpenLayers.Layer.WMS("OpenLayers WMS", "http://vmap0.tiles.osgeo.org/wms/vmap0", {layers: 'basic'}); var map = new OpenLayers.Map ('map', { controls: [ new OpenLayers.Control.MousePosition(), new OpenLayers.Control.LayerSwitcher(), new OpenLayers.Control.PanZoomBar(), new OpenLayers.Control.Navigation(), new OpenLayers.Control.ScaleLine() ], numZoomLevels: 14}); var parcelles = new OpenLayers.Layer.WMS ("Parcelles", "http://localhost/cgi-bin/mapserv.exe?MAP=C:/ms4w/apps/tutorial/htdocs/EXP_parcelles.map&LAYERS=ALL&MODE=MAP", {layers:"parcelles", "transparent": true}); var bati = new OpenLayers.Layer.WMS ("Bati Dur", "http://localhost/cgi-bin/mapserv.exe?MAP=C:/ms4w/apps/tutorial/htdocs/EXP_bati_dur.map&LAYERS=ALL&MODE=MAP", {layers:"bati_dur", "transparent": true}); var bati_public = new OpenLayers.Layer.WMS ("Public", "http://localhost/cgi-bin/mapserv.exe?MAP=C:/ms4w/apps/tutorial/htdocs/EXP_public.map&LAYERS=ALL&MODE=MAP", {layers:"public", "transparent": true}); var autre = new OpenLayers.Layer.WMS ("Autre", "http://localhost/cgi-bin/mapserv.exe?MAP=C:/ms4w/apps/tutorial/htdocs/EXP_autre.map&LAYERS=ALL&MODE=MAP", {layers:"autre", "transparent": true}); map.addLayers ([ol_wms, parcelles, bati, bati_public, autre]); map.setCenter(new OpenLayers.LonLat(2, 45), 6); info = new OpenLayers.Control.WMSGetFeatureInfo({ url: 'http://localhost/cgi-bin/mapserv.exe?MAP=C:/ms4w/apps/tutorial/htdocs/EXP_bati_dur.map&LAYERS=ALL&MODE=MAP', title: 'Information', queryVisible: true, eventListeners: { getfeatureinfo: function(event) { map.addPopup(new OpenLayers.Popup.FramedCloud( "info", map.getLonLatFromPixel(event.xy), null, event.text, null, true )); } } }); map.addControl(info); info.activate(); }
Sur un autre forum, Yves me disait que mon extent n'était pas en latlong wgs84, seulement je ne sais pas comment m'y prendre pour que tout soit dans la bonne projection. Merci du coup de main.Code HTML:<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Saint-Aulaye</title> <script src="http://www.openlayers.org/api/2.11/OpenLayers.js"></script> <script type="text/javascript" src="EXPORT.js"></script> </head> <body onload='init();'> <h1 id="title"><font color= "#03224C" size=20><center>Ville de Saint-Aulaye</center></font></h1> <div id="map" style="width:570px;height:570px;border:1px solid #bbb;"></div> </body> </html>
Que la toile soit avec vous!


Répondre avec citation
Vous avez le droit de poster sur différents forums mais prévenez nous qu'on ne perde pas de temps à faire les mêmes réponses !
Un avis, une remarque sur la nouvelle version du


Liens sociaux