<span class="ul-threaded" style="margin: 0.5em 0pt 0pt -20px;"><span class="text-cell">Hi there!
<br><br>I want to display the content of a shapefile using mapserver
with openlayers. I did it successfully in cases where the layer's type
is POLYGON but I still don't know where is the problem to do it when
the layer's type is LINE.
<br><br>Here are informations about my shapefile displayed with ogr info:<br><br><span style="background-color: rgb(255, 255, 51);">INFO: Open of `C:\ms4w\Apache\htdocs\my_shape_files\shape_ams\EXP_SEGMENT_FONCTIONNEL.shp'
</span><br style="background-color: rgb(255, 255, 51);"><span style="background-color: rgb(255, 255, 51);">using driver `ESRI Shapefile' successful.
</span><br style="background-color: rgb(255, 255, 51);"><span style="background-color: rgb(255, 255, 51);">Layer name: EXP_SEGMENT_FONCTIONNEL
</span><br style="background-color: rgb(255, 255, 51);"><span style="background-color: rgb(255, 255, 51);">Geometry: Line String
</span><br style="background-color: rgb(255, 255, 51);"><span style="background-color: rgb(255, 255, 51);">Feature Count: 6
</span><br style="background-color: rgb(255, 255, 51);"><span style="background-color: rgb(255, 255, 51);">Extent: (633527.743437, 2517184.387950) - (669562.958005, 2556945.272294)
</span><br style="background-color: rgb(255, 255, 51);"><span style="background-color: rgb(255, 255, 51);">Layer SRS WKT:
</span><br style="background-color: rgb(255, 255, 51);"><span style="background-color: rgb(255, 255, 51);">(unknown)
</span><br style="background-color: rgb(255, 255, 51);"><span style="background-color: rgb(255, 255, 51);">ID_SEGMENT: Real (24.5)
</span><br style="background-color: rgb(255, 255, 51);"><span style="background-color: rgb(255, 255, 51);">ID_RESEAU: Real (24.5)
</span><br style="background-color: rgb(255, 255, 51);"><span style="background-color: rgb(255, 255, 51);">TYPE_ETB_O: String (5.0)
</span><br style="background-color: rgb(255, 255, 51);"><span style="background-color: rgb(255, 255, 51);">ID_ETB_ORI: Real (24.5)
</span><br style="background-color: rgb(255, 255, 51);"><span style="background-color: rgb(255, 255, 51);">TYPE_ETB_E: String (5.0)
</span><br style="background-color: rgb(255, 255, 51);"><span style="background-color: rgb(255, 255, 51);">ID_ETB_EXT: Real (24.5)
</span><br style="background-color: rgb(255, 255, 51);"><span style="background-color: rgb(255, 255, 51);">CODE_OUVRA: String (30.0)
</span><br style="background-color: rgb(255, 255, 51);"><span style="background-color: rgb(255, 255, 51);">ID_RAMONAB: Real (24.5)
</span><br style="background-color: rgb(255, 255, 51);"><span style="background-color: rgb(255, 255, 51);">CLASSIFICA: String (80.0)
</span><br style="background-color: rgb(255, 255, 51);"><span style="background-color: rgb(255, 255, 51);">LONGUEUR_S: Real (24.5)
</span><br style="background-color: rgb(255, 255, 51);"><span style="background-color: rgb(255, 255, 51);">PME: Real (24.5)
</span><br style="background-color: rgb(255, 255, 51);"><span style="background-color: rgb(255, 255, 51);">EXPL_DEGS_: String (80.0)
</span><br style="background-color: rgb(255, 255, 51);"><span style="background-color: rgb(255, 255, 51);">COMMENTAIR: String (255.0)
</span><br style="background-color: rgb(255, 255, 51);"><span style="background-color: rgb(255, 255, 51);">PK_INIT: Real (24.5)
</span><br style="background-color: rgb(255, 255, 51);"><span style="background-color: rgb(255, 255, 51);">ID_ENTITE_: String (30.0)
</span><br style="background-color: rgb(255, 255, 51);"><span style="background-color: rgb(255, 255, 51);">STATUT_CON: String (1.0)
</span><br style="background-color: rgb(255, 255, 51);"><span style="background-color: rgb(255, 255, 51);">AUTEUR: String (80.0)
</span><br style="background-color: rgb(255, 255, 51);"><span style="background-color: rgb(255, 255, 51);">DATE_DERNI: Date (10.0)</span><br><br>Here is the content of my mapfile:
<br><br><span style="background-color: rgb(255, 255, 255); color: rgb(255, 102, 102);">MAP
</span><br style="background-color: rgb(255, 255, 255); color: rgb(255, 102, 102);"><span style="background-color: rgb(255, 255, 255); color: rgb(255, 102, 102);"> IMAGETYPE PNG
</span><br style="background-color: rgb(255, 255, 255); color: rgb(255, 102, 102);"><span style="background-color: rgb(255, 255, 255); color: rgb(255, 102, 102);"> EXTENT 633527.743437 2517184.387950 669562.958005 2556945.272294
</span><br style="background-color: rgb(255, 255, 255); color: rgb(255, 102, 102);"><span style="background-color: rgb(255, 255, 255); color: rgb(255, 102, 102);"> SIZE 400 300
</span><br style="background-color: rgb(255, 255, 255); color: rgb(255, 102, 102);"><span style="background-color: rgb(255, 255, 255); color: rgb(255, 102, 102);"> SHAPEPATH "/ms4w/Apache/htdocs/my_shape_files/shape_ams"
</span><br style="background-color: rgb(255, 255, 255); color: rgb(255, 102, 102);"><span style="background-color: rgb(255, 255, 255); color: rgb(255, 102, 102);"> IMAGECOLOR 255 255 255
</span><br style="background-color: rgb(255, 255, 255); color: rgb(255, 102, 102);"><span style="background-color: rgb(255, 255, 255); color: rgb(255, 102, 102);"> LAYER
</span><br style="background-color: rgb(255, 255, 255); color: rgb(255, 102, 102);"><span style="background-color: rgb(255, 255, 255); color: rgb(255, 102, 102);"> NAME EXP_SEGMENT_FONCTIONNEL
</span><br style="background-color: rgb(255, 255, 255); color: rgb(255, 102, 102);"><span style="background-color: rgb(255, 255, 255); color: rgb(255, 102, 102);"> DATA EXP_SEGMENT_FONCTIONNEL
</span><br style="background-color: rgb(255, 255, 255); color: rgb(255, 102, 102);"><span style="background-color: rgb(255, 255, 255); color: rgb(255, 102, 102);"> STATUS OFF
</span><br style="background-color: rgb(255, 255, 255); color: rgb(255, 102, 102);"><span style="background-color: rgb(255, 255, 255); color: rgb(255, 102, 102);"> TYPE LINE
</span><br style="background-color: rgb(255, 255, 255); color: rgb(255, 102, 102);"><span style="background-color: rgb(255, 255, 255); color: rgb(255, 102, 102);"> STATUS DEFAULT
</span><br style="background-color: rgb(255, 255, 255); color: rgb(255, 102, 102);"><span style="background-color: rgb(255, 255, 255); color: rgb(255, 102, 102);"> CLASS
</span><br style="background-color: rgb(255, 255, 255); color: rgb(255, 102, 102);"><span style="background-color: rgb(255, 255, 255); color: rgb(255, 102, 102);"> NAME "AMS Example"
</span><br style="background-color: rgb(255, 255, 255); color: rgb(255, 102, 102);"><span style="background-color: rgb(255, 255, 255); color: rgb(255, 102, 102);"> STYLE
</span><br style="background-color: rgb(255, 255, 255); color: rgb(255, 102, 102);"><span style="background-color: rgb(255, 255, 255); color: rgb(255, 102, 102);"> COLOR 0 0 0
</span><br style="background-color: rgb(255, 255, 255); color: rgb(255, 102, 102);"><span style="background-color: rgb(255, 255, 255); color: rgb(255, 102, 102);"> OUTLINECOLOR 32 32 32
</span><br style="background-color: rgb(255, 255, 255); color: rgb(255, 102, 102);"><span style="background-color: rgb(255, 255, 255); color: rgb(255, 102, 102);"> END
</span><br style="background-color: rgb(255, 255, 255); color: rgb(255, 102, 102);"><span style="background-color: rgb(255, 255, 255); color: rgb(255, 102, 102);"> END
</span><br style="background-color: rgb(255, 255, 255); color: rgb(255, 102, 102);"><span style="background-color: rgb(255, 255, 255); color: rgb(255, 102, 102);"> END
</span><br style="background-color: rgb(255, 255, 255); color: rgb(255, 102, 102);"><span style="background-color: rgb(255, 255, 255); color: rgb(255, 102, 102);">END</span><br style="color: rgb(255, 102, 102);"><br>finally here is the content of the html file with the javascript code:<br>
<br style="color: rgb(51, 204, 0);"><span style="color: rgb(51, 204, 0);"><html xmlns="</span><a style="color: rgb(51, 204, 0);" href="http://www.w3.org/1999/xhtml" target="_top" rel="nofollow">http://www.w3.org/1999/xhtml</a><span style="color: rgb(51, 204, 0);">">
</span><br style="color: rgb(51, 204, 0);"><span style="color: rgb(51, 204, 0);"> <head>
</span><br style="color: rgb(51, 204, 0);"><span style="color: rgb(51, 204, 0);"> <title>MapServer Layer: AMS Example</title>
</span><br style="color: rgb(51, 204, 0);"><span style="color: rgb(51, 204, 0);"> <script src="../../lib/OpenLayers.js"></script>
</span><br style="color: rgb(51, 204, 0);"><span style="color: rgb(51, 204, 0);"> <script type="text/javascript">
</span><br style="color: rgb(51, 204, 0);"><span style="color: rgb(51, 204, 0);"> var map, layer, mybounds;
</span><br style="color: rgb(51, 204, 0);"><span style="color: rgb(51, 204, 0);"> function init(){
</span><br style="color: rgb(51, 204, 0);"><span style="color: rgb(51, 204, 0);"> map = new OpenLayers.Map("map");
</span><br style="color: rgb(51, 204, 0);"><span style="color: rgb(51, 204, 0);"> layer = new OpenLayers.Layer.MapServer( "Exemple AMS", "</span><a style="color: rgb(51, 204, 0);" href="http://localhost:8081/cgi-bin/mapserv.exe?map=/ms4w/Apache/htdocs/my_examples_MS/ams_exp.map" target="_top" rel="nofollow">http://localhost:8081/cgi-bin/mapserv.exe?map=/ms4w/Apache/htdocs/my_examples_MS/ams_exp.map</a><span style="color: rgb(51, 204, 0);">", {layers: "EXP_SEGMENT_FONCTIONNEL", format: 'image/png', isBaseLayer: false, opacity: 1});
</span><br style="color: rgb(51, 204, 0);"><span style="color: rgb(51, 204, 0);"> map.addLayer(layer);
</span><br style="color: rgb(51, 204, 0);"><span style="color: rgb(51, 204, 0);"> mybounds = new OpenLayers.Bounds(633527.743437,2517184.387950,669562.958005,2556945.272294);
</span><br style="color: rgb(51, 204, 0);"><span style="color: rgb(51, 204, 0);"> map.zoomToExtent(mybounds);
</span><br style="color: rgb(51, 204, 0);"><span style="color: rgb(51, 204, 0);"> map.addControl( new OpenLayers.Control.LayerSwitcher() );
</span><br style="color: rgb(51, 204, 0);"><span style="color: rgb(51, 204, 0);"> }
</span><br style="color: rgb(51, 204, 0);"><span style="color: rgb(51, 204, 0);"> </script>
</span><br style="color: rgb(51, 204, 0);"><span style="color: rgb(51, 204, 0);"> </head>
</span><br style="color: rgb(51, 204, 0);"><span style="color: rgb(51, 204, 0);"> <body onload="init()">
</span><br style="color: rgb(51, 204, 0);"><span style="color: rgb(51, 204, 0);"> <div id="title">MapServer Layer: AMS Example</div>
</span><br style="color: rgb(51, 204, 0);"><span style="color: rgb(51, 204, 0);"> <div id="map"></div>
</span><br style="color: rgb(51, 204, 0);"><span style="color: rgb(51, 204, 0);"> </body>
</span><br style="color: rgb(51, 204, 0);"><span style="color: rgb(51, 204, 0);"></html></span><br><br>I tried to display this shapefile without using openlayers and
it worked so I guess the problem is in the javascript code probabily
when calling the method <i><b>OpenLayers.Layer.MapServer()</b></i> but when I
tried to debug the code I found no errors! Note that I did the same way
to display other shapefiles content having TYPE POLYGON with openlayers using mapserver and that
worked well so I don't know what else to do now!
<br><br>Please HELP!
</span></span><br clear="all"><br>-- <br>Abir Rezgui<br>-----------------------<br>Elève Ingénieur à l'Ecole Nationale des Sciences Informatiques ( ENSI )<br>