[OpenLayers-Users] unable to create WFS layer from Mapserver
sunny74
sb.ray at hotmail.com
Tue Apr 13 09:27:14 EDT 2010
Dear Friends,
I am trying to create a WFS layer,either singly or on top of a WMS layer but
it gives me an error "htmlfile: Unspecified error".
My code is as below:
var lon = 73.25;
var lat = 20.35;
var zoom = 6;
map = new OpenLayers.Map('<%=map.ClientID%>');
layer = new OpenLayers.Layer.WMS("OpenLayers WMS",
"/cgi-bin/mapserv.exe?map=c:/ms4w/apache/htdocs/Shape/newwr1rec.map", {
layers: "state", transparent: false, format: "image/png" }, { isBaseLayer:
true });
map.addLayer(layer);
layer = new OpenLayers.Layer.WFS("myWFS",
"/cgi-bin/mapserv.exe?map=c:/ms4w/apache/cgi-bin/Shape/wfs_map.map", {
typename: 'state', maxfeatures: 10 }, { featureClass: OpenLayers.Feature.WFS
});
map.addLayer(layer);
map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
map.addControl(new OpenLayers.Control.LayerSwitcher());
I tried different codes for the WFS but nothing seems to work.I tried the
following
for eg,
var layer1 = new OpenLayers.Layer.Vector("WFS", {
strategies: [new OpenLayers.Strategy.BBOX()],
protocol: new OpenLayers.Protocol.WFS({
url:
"/cgi-bin/mapserv.exe?map=c:/ms4w/apache/cgi-bin/Shape/wfs_map.map",
featureType: "state",
featureNS:
"/cgi-bin/mapserv.exe?map=c:/ms4w/apache/cgi-bin/Shape/wfs_map.map"
})
});
my wfs map file is as below
<---Map File ---->
# Map file created from QGIS project file D:/QGIS/newwr.qgs
# Edit this file to customize for your map interface
# (Created with PyQgis MapServer Export plugin)
MAP
NAME wfs_map.map
STATUS ON
# Map image size
SIZE 600 600
UNITS dd
EXTENT 67.440106 17.379867 78.390250 25.122977
FONTSET 'fonts.txt'
#SHAPEPATH 'D:\ms4w\Apache\cgi-bin\Shape'
IMAGECOLOR 192 192 192
END
# Legend
# 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 "/ms4w/tmp/ms_tmp/"
# Set IMAGEURL to the url that points to IMAGEPATH
# as defined in your web server configuration
IMAGEURL "/ms_tmp/"
# WFS server settings
METADATA
'wfs_title' 'wfs_map.map'
'wfs_onlineresource'
'http://localhost:81/cgi-bin/mapserv.exe?map=wfs_map.map&'
'wfs_srs' 'EPSG:42304 EPSG:42101 EPSG:4269 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
END
LAYER
NAME "STATE"
TYPE POLYGON
DATA "D:/ms4w/Apache/cgi-bin/Shape/STATE.shp"
METADATA
END
METADATA
"wfs_title" "STATE" ## REQUIRED
"gml_featureid" "1" ## REQUIRED
"gml_include_items" "all"
"wfs_typename" "STATE"
"wfs_version" "1.0.0"
"wfs_request_method" "GET"
"wfs_connectiontimeout" "60"
"wfs_maxfeatures" "1"
END
STATUS ON
#TRANSPARENCY 100
DUMP TRUE
CLASS
NAME 'STATE'
STYLE
OUTLINECOLOR 0 0 0
COLOR 255 255 127
END
TEMPLATE "ttt_query.html"
END
END
LAYER
NAME 'RailwayStations'
TYPE POINT
DATA 'D:\ms4w\Apache\htdocs\Shape\RailwayStations.shp'
LABELITEM 'S_NAME'
METADATA
'wfs_title' 'RailwayStations'
'wfs_include_items' "all"
#'wms_include_items' "S_name"
#'wms_include_items' "S_no"
#'wms_include_items' "Id1"
#'wms_include_items' "Latitude"
#'wms_include_items' "Longitude"
#'wms_include_items' "Distance_k"
END
STATUS ON
#HEADER ../templates/Demo_header.html
#TEMPLATE ../templates/Demo_query_body.html
#FOOTER ../templates/Demo_footer.html
DUMP TRUE
TRANSPARENCY 100
PROJECTION
'proj=longlat'
'ellps=WGS84'
'datum=WGS84'
'no_defs'
''
END
CLASS
NAME 'RailwayStations'
STYLE
SYMBOL 'CIRCLE'
SIZE 8
OUTLINECOLOR 0 0 0
COLOR 255 0 0
END
LABEL
COLOR 132 31 31
SHADOWCOLOR 218 218 218
SHADOWSIZE 2 2
TYPE TRUETYPE
FONT arial-bold
SIZE 6
ANTIALIAS TRUE
POSITION AUTO
FORCE TRUE
PARTIALS FALSE
MINDISTANCE 300
BUFFER 4
END # end of label
END
END
END
Can some correct the OL/map file code so that I am able to create a WFS
layer successfully.
The template file is a blank file.Is it necessary to have any specific
template.
Thanks for your attention and efforts.
--
View this message in context: http://n2.nabble.com/unable-to-create-WFS-layer-from-Mapserver-tp4896070p4896070.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
More information about the Users
mailing list