Skip to content

Latest commit

 

History

History
181 lines (100 loc) · 2.8 KB

GeoJSON.md

File metadata and controls

181 lines (100 loc) · 2.8 KB

FeatureGroup v1.4.0+

Examples

  • Basic Usage

    import {
      RCMap,
      TileLayer,
      GeoJSON,
      Popup
    } from 'rc-leaflet'
    
    (
      <RCMap crs center>
        <TileLayer />
        <GeoJSON data />
    
        <GeoJSON data>
          <Popup />
        </GeoJSON>
      </RCMap>
    )
  • 统一设置Path样式

    const style = { color: 'red' }
    
    (
      <GeoJSON data style={style} />
    )

Props

  • data

    • type: Geometry | Geometry[] | Feature | Feature[] | FeatureCollection

    • required: true

    • geo经纬度json数据

  • pointToLayer

    • type: (feature: geo.Feature<geo.Point>, position: L.LatLng) => L.Layer

    • required: false

    • 点位json数据的渲染函数, 默认渲染点位

  • style

    • type: L.PathOptions | (feature?: geo.Feature<geo.GeometryObject>) => L.PathOptions

    • required: false

    • 设置geo线和多边形的样式

  • onEachFeature

    • type: (feature: geo.Feature<geo.GeometryObject>, layer: L.Layer) => void

    • required: false

    • 对每个添加到地图的geo元素执行一定的操作

  • filter

    • type: (feature: geo.Feature<geo.GeometryObject>) => boolean

    • required: false

    • 对后续添加到地图的geo元素进行过滤

  • coordsToLatLng

    • type: (coords: [number, number] | [number, number, number]) => L.LatLng

    • required: false

    • 点位数组转换成L.LatLng的转换函数, 默认为点位格式为[lng, lat], 通过设置该函数, 可以传入[lat, lng]

Props inherited from LayerGroup

  • zIndex

    • type: number

    • required: false

    • 现阶段不起作用

Props inherited from Layer

  • pane

    • type: string

    • required: false

    • default: overlayPane

    • 放置GeoJSON的地图图层名称

  • attribution

    • type: string

    • required: false

    • 版权描述

  • onCreate

    • type: (layer: L.Layer) => void

    • required: false

    • GeoJSON创建之后的回调

  • onAdd

    • type: (e: L.LeafletEvent, layer: L.Layer) => void

    • required: false

    • GeoJSON添加到图层之后的回调

  • onUpdate

    • type: (layer: L.Layer) => void

    • required: false

    • GeoJSON发生更新之后的回调

  • onBeforeRemove

    • type: (layer: L.Layer) => void

    • required: false

    • GeoJSON在删除之前的回调

  • onRemove

    • type: (e: L.LeafletEvent, layer: L.Layer) => void

    • required: false

    • GeoJSON删除时的回调

Props inherited from Evented

  • onClick

    • type: (e: L.LeafletMouseEvent) => void

    • required: false

    • GeoJSON鼠标点击时的回调

  • onMouseOver

    • type: (e: L.LeafletMouseEvent) => void

    • required: false

    • GeoJSON鼠标进入时的回调

  • onMouseOut

    • type: (e: L.LeafletMouseEvent) => void

    • required: false

    • GeoJSON鼠标离开时的回调