Skip to content
On this page

特征(geojson)

添加特征

javascript
(data, comp) => {
    const geojson = {
        "features": [
          {
            "type": "Feature",
            "properties": {
              "type": "LineString"
            },
            "geometry": {
              "type": "LineString",
              "coordinates": [[0,30],[180,30]]
            }
          },
          {
            "type": "Feature",
            "properties": {
              "type": "Point",
              "text": "北纬30度"
            },
            "geometry": {
              "type": "Point",
              "coordinates": [121.76861985666675,30]
            }
          }
        ],
        "type": "FeatureCollection"
    }
    comp.featureManager.addFeatures({
        data:geojson,
        options:[
            { type: 'LineString', lineWidth: 2, lineColor: '#66cccc',onclick(entity){},ondblclick(entity){} },
            { type: 'Point', textSize: 12, textColor: 'yellow',backgroundColor:'#000000',backgroundOpacity:0.5,onclick(entity){},ondblclick(entity){} },
        ],
        fit:true,
    })
}
(data, comp) => {
    const geojson = {
        "features": [
          {
            "type": "Feature",
            "properties": {
              "type": "LineString"
            },
            "geometry": {
              "type": "LineString",
              "coordinates": [[0,30],[180,30]]
            }
          },
          {
            "type": "Feature",
            "properties": {
              "type": "Point",
              "text": "北纬30度"
            },
            "geometry": {
              "type": "Point",
              "coordinates": [121.76861985666675,30]
            }
          }
        ],
        "type": "FeatureCollection"
    }
    comp.featureManager.addFeatures({
        data:geojson,
        options:[
            { type: 'LineString', lineWidth: 2, lineColor: '#66cccc',onclick(entity){},ondblclick(entity){} },
            { type: 'Point', textSize: 12, textColor: 'yellow',backgroundColor:'#000000',backgroundOpacity:0.5,onclick(entity){},ondblclick(entity){} },
        ],
        fit:true,
    })
}

注:properties下面的type是必须项,样式会根据这个进行样式设置

特征options

javascript
//Point
{
  type:'Point',
  textSize,
  textColor,
  backgroundColor,
  backgroundOpacity,
  image,
  imageScale
}
//Polygon
{
  type:'Polygon',
  lineColor,
  lineOpacity=1,
  lineWidth,
  fillColor,
  fillOpacity=1,
  extrudedHeight=0
}
//LineString
{
  type:'LineString',
  lineColor,
  lineOpacity=1,
  lineWidth=1
}
//Point
{
  type:'Point',
  textSize,
  textColor,
  backgroundColor,
  backgroundOpacity,
  image,
  imageScale
}
//Polygon
{
  type:'Polygon',
  lineColor,
  lineOpacity=1,
  lineWidth,
  fillColor,
  fillOpacity=1,
  extrudedHeight=0
}
//LineString
{
  type:'LineString',
  lineColor,
  lineOpacity=1,
  lineWidth=1
}

移除特征

javascript
(data, comp) => {
    comp.featureManager.removeAll()
}
(data, comp) => {
    comp.featureManager.removeAll()
}

条件移除特征

javascript
(data, comp) => {
    comp.featureManager.removeFn((entity)=>true)
}
(data, comp) => {
    comp.featureManager.removeFn((entity)=>true)
}

Last updated: