1

I have few shape files (Polygon/Lines/Points) imported into Postgres. I have published the Layers in Geoserver.

The Polygon layer is displayed properly in Openlayers However when I consume Line Layer in openlayers it is not visible neither is the point layer.

Also upon layer preview for line is not as easy as it was for polygon.Line layer preview is as below (it is 1 line , But 3 lines are displayed) :

enter image description here

I am adding Line layer in openlayers as below :

var layers = [
    new ol.layer.Tile({
        source: new ol.source.OSM()
    }),
    new ol.layer.Tile({
        //Polygon layers : Works Fine
        source: new ol.source.TileWMS({
                url: 'http://xxxxxxxxx:8080/geoserver/localhost/wms?',
                params: { 'LAYERS': 'localhost:village_maps', 'TILED': true },
                serverType: 'geoserver',
                // Countries have transparency, so do not fade tiles:
                transition: 0,
                transparent: true
                //format: new ol.format.GeoJSON()
            });
    }),
    new ol.layer.Tile({  
        // Line Layer : Overlaps above polygon layer and Not visible
        // After hiding the above polygon layer also line layer is not visible.
        source: new ol.source.TileWMS({
            url: 'http://xxxxxxxxx:8080/geoserver/localhost/wms?',
            params: { 'LAYERS': 'localhost:proposed_line', 'TILED': true },
            serverType: 'geoserver',
            // Countries have transparency, so do not fade tiles:
            transition: 0,
            transparent: true
            //format: new ol.format.GeoJSON()
        });
    })
  ]

Please suggest.

  • I found the solution , Just in case if it helps to anyone , It was the issue of the projection in shape file. I changed the crs to EPSG:32644 and the line layer was visible at proper place. – user684805 Aug 22 at 8:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.