`
wangleide414
  • 浏览: 606880 次
  • 性别: Icon_minigender_1
  • 来自: 西安
社区版块
存档分类
最新评论

openlayer feature attributes

 
阅读更多

 

用这种方法可以得到geoserver里的feature  

 var params = {

REQUEST: "GetFeature",

      //BBOX: new OpenLayers.Bounds(-668087, 3908936, -656113, 3917375).toBBOX(),          //如果不写范围,默认查询所有的feature                                              

       maxFeatures:'50',

       srsName: 'EPSG:2008',

       service: 'WFS',

       version: '1.0.0', 

       //PropertyName: properName,

       typeName:'wltest:sensor_geom'      

     };

        //执行查询

        OpenLayers.loadURL("http://localhost:8080/geoserver/wfs", params, this, setHTML, setHTML); 

 

 

 

 

 

function setHTML(response) {

var gmlParse = new OpenLayers.Format.GML();//如果使用wfs1.1.0,则需要增加如下参数:{xy:false }//更改x,y坐标的读取顺序

/***features 为所有的传感器***/

    var features = gmlParse.read(response.responseText);

    //这就得到了所有的Features

   

    wfs.addFeatures(features);

            map.addLayer(wfs);

}

 

 

你如果想得到feature中的具体属性可以用feature.attributes['id'];//id为属性的名字。但是如果你的表中设置了主键。那个得到主键就不能用这种方式。可以用feature.fid。得到。在处理一下就可以了。

 

 

分享到:
评论

相关推荐

    基于openLayers2所写的热力图

    var weight = feature.attributes.weight; // 渐变色谱示例 var color = (weight > 10 ? '#ff0000' : weight > 5 ? '#ff8000' : '#ffff00'); return color; }, fillOpacity: 0.8 } })); // 添加矢量图层到...

    基于gdal的shapeflie文件的读写类(带坐标系)

    feature = self.layer.GetFeature(feature_index) geom = feature.GetGeometryRef().ExportToWkt() for i in range(feature.GetFieldCount()): field_name = feature.GetFieldDefnRef(i).GetName() field_value...

    使用Mapx在Delphi中

    Feature.Style.Color := GetColorBasedOnAttribute(Feature.Attributes['AttributeName']); end; end; function GetColorBasedOnAttribute(AttributeValue: Variant): TColor; // 实现根据属性值返回颜色的逻辑 ...

    datagridview打开shp文件属性表代码

    var attributes = feature.GetFields(); // 处理每个属性 } ``` 4. **填充datagridview**: 针对`datagridview`控件,你需要创建一个DataTable来存储属性表数据,然后将属性值添加到DataTable中。最后,将...

    400guojiaSHP.zip

    attributes = feature.GetFieldNames() for attr_name in attributes: attr_value = feature.GetField(attr_name) print(f"{attr_name}: {attr_value}") # 输出几何信息 print(f"Geometry Type: {geometry....

    Shapefile文件的读取和写入

    attributes = feature.GetFieldValues() # 处理几何对象和属性信息... ``` 使用geopandas: ```python import geopandas as gpd gdf = gpd.read_file('path_to_shapefile.shp') for idx, row in gdf....

    Openlayers经典例子.doc

    var baseLayer = new OpenLayers.Layer.OSM("OpenStreetMap"); var overlayLayer = new OpenLayers.Layer.WMS("WMS Layer", "http://localhost:8080/geoserver/wms", {layers: 'topp:states'}); map.addLayers(...

    TerraExplorer_Pro培训教材

    - **Load Feature Layer - 加载特征层**:加载特征数据层。 - **Load Imagery Layer - 加载影像层**:加载卫星图像层。 - **Load Elevation Layer - 加载高程层**:加载地形高程数据层。 - **Load Kml/Kmz Layer...

    python3.6.5参考手册 chm

    Application-Layer Protocol Negotiation Support Other Changes sqlite3 subprocess sys sysconfig tarfile threading time timeit tkinter traceback types unicodedata unittest unittest.mock ...

    雷达技术知识

    关于雷达方面的知识! EFFECTIVENESS OF EXTRACTING WATER SURFACE SLOPES FROM LIDAR DATA WITHIN THE ACTIVE CHANNEL: SANDY RIVER, OREGON, USA by JOHN THOMAS ENGLISH A THESIS Presented to the Department ...

    Senfore_DragDrop_v4.1

    Just open the forms in the IDE, then select "Ignore All" when the IDE complains that this or that property doesn't exist and finally save the forms. ------------------------------------------- 3. ...

    The Indispensable PC Hardware Book - rar - part1. (1/7)

    Differences and common attributes of i486 and 80386/80387. Differences in register structures. Differences in memory management. i486 reset. i486 real mode. i486 protected mode. i486 virtual ...

Global site tag (gtag.js) - Google Analytics