openlayers wfs层不出现

时间:2019-01-24 14:27:42

标签: javascript openlayers mapserver

在openlayers 4.4中,我有一个图层,其来源来自mapserver。 通过执行AdministrationSource.getFeatures()。 ForEach(功能(功能){     console.log(feature.getGeometry()getCoordinates()。); 我有一个几何列表,但是它们没有出现在我的图层上。 我不知道它是否来自mapserver .map文件或openlayers。geometry array openlayers代码

var administrationSource =  new ol.source.Vector({
    format: new ol.format.GeoJSON(),
    url: function (extent,resolution) { 
     if (resolution<2) {return 'http://10.210.1.32:8080/cgi-bin/mapserv.exe?map=C:/ms4w/map/fond_mapserver_wfs_ol4.map&SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&TYPENAME=administration2&OUTPUTFORMAT=geojson&SRSNAME=EPSG:2154&bbox='+ extent.join(',') + ',EPSG:3857';
      }},
    strategy: ol.loadingstrategy.bbox
    });
     var administrationwfs =  new ol.layer.Vector({
    source: administrationSource,
    maxResolution: 2 ,
    style: new ol.style.Style({
      stroke: new ol.style.Stroke({
        color: 'rgba(255, 51, 0, 1.0)',
        width: 2
      })
    })
  });
     map.addLayer(administrationwfs);

地图文件

    MAP
  NAME "Mapserver-Inrap"
  STATUS ON
  #SIZE 400 300
  SYMBOLSET "C:\ms4w\map\symbols\symbols.sym"
  OUTPUTFORMAT
  NAME "geojson"
  DRIVER "OGR/GEOJSON"
  MIMETYPE "application/json; subtype=geojson"
  FORMATOPTION "STORAGE=stream"
  FORMATOPTION "FORM=SIMPLE"
    END
  EXTENT 93501.1 6044342.00 1248133.25 7115784.50 #xmin ymin xmax ymax
  UNITS METERS
  #SHAPEPATH "../data"
  #IMAGECOLOR 255 255 255
  FONTSET "./fonts/fonts.txt"
  DEBUG 5
    CONFIG "CPL_DEBUG" "ON"
    CONFIG "PROJ_DEBUG" "ON"
    CONFIG MS_ERRORFILE "C:/ms4w/errorMapFile.txt"

    PROJECTION # proj de sortie
        "init=epsg:2154"
    END #fin projection
  #
  # Start of web interface definition
  #
  WEB
    IMAGEPATH "/ms4w/tmp/ms_tmp/"
    IMAGEURL "/ms_tmp/"
    METADATA
      "wfs_title"          "WFS-Inrap, outil d'aide au montage des operations" ## REQUIRED
      "wfs_onlineresource" "http://10.210.1.32:8080/cgi-bin/mapserv.exe?MAP=C:/ms4w/map/fond_mapserver_wfs_ol4.map" ## Recommended
      "wfs_srs"            "EPSG:2154 EPSG:3857" ## Recommended
      "wfs_abstract"       "This text describes my WFS service." ## Recommended
      "wfs_enable_request" "*"  # necessary
      "wfs_getfeature_formatlist" "geojson"
    END #fin metadata
  END #end web





#
  # Start of layer definitions
  #-----debut layer adminstration
LAYER
    NAME "administration2"
    #STATUS ON
    TYPE POLYGON
    PROJECTION
        "init=epsg:2154"
    END #fin projection
    CONNECTIONTYPE POSTGIS
    CONNECTION "host=10.210.1.32 dbname=activite user=POSTGIS password=xxxxxxxx port=5432"
    DATA "geom from (select gid, geom, numope, numprescr, nomope, ro, typope from activite.administration) as foo using unique gid SRID=2154"
    PROCESSING "CLOSE_CONNECTION=DEFER"
    MAXSCALEDENOM 80000
    #CLASSITEM "typope"
    LABELITEM "numprescr"
    CLASS
        NAME "administration"
        STYLE
            COLOR 146 255 3
            OPACITY 35
            OUTLINECOLOR 146 255 3
            WIDTH 1
            LINECAP round
        END #end Style
        LABEL
            FONT "verdana"
            SIZE 5
            COLOR 0 0 0
            OUTLINECOLOR 255 255 255
            OUTLINEWIDTH 1
            POSITION auto #uc
            MAXSCALEDENOM 80000
            TYPE truetype
        END #fin label
    TEMPLATE "bidon2.html"  
    END #fin class
    METADATA
        "wfs_title"         "administration2" ##REQUIRED
        "wfs_srs"           "EPSG:2154" ## REQUIRED
        "gml_include_items" "all" ## Optional (serves all attributes for layer)
        "gml_featureid"     "ID" ## REQUIRED
        #"wfs_getfeature_formatlist" "OGRGML"
        #"wfs_getfeature_formatlist” "geojson" 
        "wfs_enable_request" "*"
    END #fin metadata administration
END #fin layer administration
  #

END #mapfile

和控制台

0 个答案:

没有答案