GeoJson

概述

用作解析GeoJSON数据,并在地图显示,扩展FeatureGroup

用法示例

FMap.geoJson(data, {
    style: function (feature) {
        return {color: feature.properties.color};
    },
    onEachFeature: function (feature, layer) {
        layer.bindPopup(feature.properties.description);
    }
}).addTo(map);

创建(Creation)

创建:

创建 描述
FMap.geoJson( <Object> geojson?, <GeoJSON options> options? ) 创建GeoJSON层,可以选择接受一个GeoJSON格式的对象用来显示在地图上(也可以稍后用addData方法添加)和一个options对象

选项(Options)

选项:

选项 参数 描述
pointToLayer() <GeoJSON> featureData,<LatLng> latlng 用作创建GeoJSON点的图层的函数(如果未指定,将会创建简单的标记)
style() <GeoJSON> featureData 用作获取为GeoJSON features创建的矢量图层的style options
onEachFeature() <GeoJSON> featureData,<ILayer> layer 每个已创建的feature图层上的回调函数,用作添加事件或popups到features上
filter() <GeoJSON> featureData,<ILayer> layer 用作决定是否展示一个feature
coordsToLatLng() <Array> coords 用于转换GeoJSON为经纬度坐标点(如果未指定,将的coords被假定为WGS84 - 标准[经度,纬度],单位:度)

方法(Methods)

方法:

方法 参数 返回值 描述
addData() <GeoJSON> data this 添加一个GeoJSON对象到图层中
setStyle() <Function> style this 用给定的style function改变GeoJSON矢量图层的styles
resetStyle() <Path> layer this 重置给定矢量图层的style至原来的GeoJSON style,应用于hover事件

静态方法(Static methods)

静态方法:

方法 参数 返回值 描述
geometryToLayer() <GeoJSON> featureData,<Function> pointToLayer? ILayer 根据给定的GeoJSON feature创建一个图层
coordsToLatLng() <Array> coords,<Boolean> reverse? LatLng 将GeoJSON点转换为一个LatLng对象,,如果reverse设置为true,LatLng对象中经纬度位置调换
coordsToLatLngs() <Array> coords,<Number> levelsDeep?,<Boolean> reverse? Array GeoJSON坐标数组转换成多维LatLng 对象数组,如果reverse设置为true,LatLng对象中经纬度位置调换

results matching ""

    No results matching ""