FeatureLayer

继承Layer.

显示GeoJSON要素 。要素如果未指定样式,会使用默认样式。 具体支持属性请见: MarkerPolylinePolygon


示例

var feature = {
    type:"Feature",
    geometry:{
       "type": "Point",
       "coordinates": [116.390879,39.908719] 
    },
    properties:{

    }
}

var layer = W.featureLayer().addTo(map);
layer.addFeature(feature);

构造函数

工厂 描述
W.featureLayer(<Options options> options)  

构造选项

选项名 类型 默认值 描述
defaultStyle Object null 要素的默认样式 ,详见:MarkerPolylinePolygon

事件

事件 数据 描述
featureclick FeatureEvent 左键点击要素时触发
featuredblclick FeatureEvent 左键双击要素时触发
featuremouseover FeatureEvent 鼠标进入要素时触发
featuremouseout FeatureEvent 鼠标离开要素时触发
featurecontextmenu FeatureEvent 右键点击要素时触发
featurepopupopen FeatureEvent 打开气泡时触发
featurepopupclose FeatureEvent 关闭气泡时触发

方法

方法 返回值 描述
addFeature(Object feature,Options option) this 添加一个要素,如果添加的要素没有id,会自动生成一个id,但不会修改传入的要素对象
addFeatures(Object[] features,Options option) this 添加一组要素
removeFeature(String id) this 移除要素
clearFeatures() this 移除所有要素
getFeatures() Object [] 获取所有要素
updateFeature(String id,Object newFeature,Options options) this 更新要素
getFeature(String id) Object 根据id获取要素,
getFeatureId(Object feature) String 获取要素的ID
openPopup(String id,String content,Object options) this 在指定要素上打开一个气泡
closePopup() this 关闭气泡
setStyle(String id,Options styleOptions) this 设置某个要素的样式
setDefaultStyle(Object style) this 设置整体图层的默认样式
enableEdit(String id) this 让某个要素可编辑,(特别强调:要素在地图上编辑结束后不会自动更新到FeatureLayer,需调用disableEdit或commitEdit才会将编辑后的结果更新到FeatureLayer)
enableEdit() this 让所有要素可编辑,(特别强调:要素在地图上编辑结束后不会自动更新到FeatureLayer,需调用disableEdit或commitEdit才会将编辑后的结果更新到FeatureLayer)
disableEdit(String id) this 禁用指定要素的编辑,禁用之前会先保存编辑效果到FeatureLayer对象
disableEdit() this 禁用所有要素的编辑,禁用之前会先保存编辑效果到FeatureLayer对象
commitEdit(String id) this 指定要素的编辑结果更新到FeatureLayer对象
commitEdit() this 所有要素的编辑结果更新到FeatureLayer对象
rollbackEdit(String id) this 回滚指定要素的编辑
rollbackEdit() this 回滚所有要素的编辑
getCenter(String id) Point 获取指定要素的中心点
getFeatureBounds(String id) Bounds 获取指定要素的范围
getBounds() Bounds 获取FeatureLayer的范围

results matching ""

    No results matching ""