Arcgis popup、popupTemplate、Search、FeatureForm、applyEdits学习记录及图层要素icon编辑修改

Arcgis 点标记、popup添加

注:popup主要作用于view

1、组件引入

import marker from './images/marker.svg' // icon图标
import Map from '@arcgis/core/Map'
import MapView from '@arcgis/core/views/MapView'
import esriConfig from '@arcgis/core/config'
import Graphic from '@arcgis/core/Graphic'
import GraphicsLayer from '@arcgis/core/layers/GraphicsLayer'

2、地图实例注册、点击事件绑定、点标记生成

function init() {
  esriConfig.apiKey = '你的key'
  const map = new Map({
    // arcgis-navigation arcgis-imagery  arcgis-light-gray //基础图层
    basemap: 'arcgis-navigation', // Basemap layer service
  })
  const view = new MapView({
    map: map,
    center: [-118.80657463861, 34.000593060888],
    zoom: 11, 
    container: 'viewDiv', 
  })
  // 点
  const graphicsLayer = new GraphicsLayer()
  map.add(graphicsLayer) // 将 GraphicsLayer 添加到地图实例中
  // picture-marker  icon 标记  simple-marker点标记
  const simpleMarkerSymbol = {
    type: 'picture-marker',
    width: '20px',
    height: '20px',
    url: marker,
  }
  view.popup.autoOpenEnabled = false // 此属性指示Popup需要允许或禁止单击事件传播。
  view.on('click', function viewClick(event) {
    // 添加地图点击事件
    const { type, latitude, longitude } = event.mapPoint
    graphicsLayer.add(
      new Graphic({
        geometry: { type, latitude, longitude },
        symbol: simpleMarkerSymbol,
      })
    )
  })
}

3、在2的基础上添加popup

view.popup.autoOpenEnabled = false  
view.on('click', function viewClick(event) {
    const { type, latitude, longitude } = event.mapPoint
    graphicsLayer.add(
      new Graphic({
        geometry: { type, latitude, longitude },
        symbol: simpleMarkerSymbol,
      })
    )
    var popupTemplate = {
      title: '点击了',
      location: event.mapPoint,
      content: `点击在${event.mapPoint.longitude},${event.mapPoint.latitude}`,
    }
    view.popup.open(popupTemplate)
  })

popupTemplate

注:PopupTemplate是一个针对Layer和Graphic的弹窗

1、基础popupTemplate

// 这种方式不需要引入popupTemplate 组件
var template = {
   title: '年: {data_year}',// {}内为数据变量
   content: '...',
 }
const layer = new FeatureLayer({
  url: 'https://services3.arcgis.com/tgYU2qbxZbWPWXPL/arcgis/rest/services/toimages/FeatureServer/0',
  popupTemplate: template
})
// 或者
  const layer = new FeatureLayer({
    url: 'https://services3.arcgis.com/tgYU2qbxZbWPWXPL/arcgis/rest/services/toimages/FeatureServer/0'
  })
 layer.popupTemplate = {
  content: '年: {data_year}',
 }

2、表格格式

import PopupTemplate from '@arcgis/core/PopupTemplate'
  let popupTemplate = new PopupTemplate({
    title: '{data_year} in {Shape_Leng}',
    outFields: ['*'],// 表示显示所有字段
    content: [
      {
        type: 'fields',
        fieldInfos: [
          {
            fieldName: 'data_year', // 字段名
            label: 'Married %', 
          },
          {
            fieldName: 'dq_name',
            label: 'People Married',
          },
        ],
      },
    ],
  })
    const layer = new FeatureLayer({
    url: 'https://services3.arcgis.com/tgYU2qbxZbWPWXPL/arcgis/rest/services/toimages/FeatureServer/0',
    popupTemplate: popupTemplate,
  })

图层编辑、修改、删除

注:图层必须现在控制台允许编辑(Dashboard/Layers/Settings/Editing settings)

1、组件引入

import Map from '@arcgis/core/Map'
import MapView from '@arcgis/core/views/MapView'
import esriConfig from '@arcgis/core/config'
import Graphic from '@arcgis/core/Graphic'
import Expand from '@arcgis/core/widgets/Expand'
import FeatureLayer from '@arcgis/core/layers/FeatureLayer'
import FeatureForm from '@arcgis/core/widgets/FeatureForm'
import FeatureTemplates from '@arcgis/core/widgets/FeatureTemplates'

2、图层引入、地图注册

  esriConfig.apiKey = '你的key'
  const featureLayer = new FeatureLayer({
    url: 'https://services3.arcgis.com/tgYU2qbxZbWPWXPL/arcgis/rest/services/toimages/FeatureServer/0',
    outFields: ['*'],
    id: 'incidentsLayer', // id字段不传则无法编辑、删除(主要用于判断点击的地图点是否在此图层上)
  })
    const map = new Map({
    basemap: 'dark-gray-vector',
    layers: [featureLayer],
  })
  const view = new MapView({
    container: 'viewDiv',
    map: map,
    center: [113.5861, 25.037278],
    zoom: 10,
  })

3、添加FeatureForm、FeatureTemplates

  const featureForm = new FeatureForm({
    container: 'formDiv',
    layer: featureLayer,
    fieldConfig: [
      {
        name: 'DATA_YEAR',
        label: 'Choose incident type',
      },
      {
        name: 'CNTY_CODE',
        label: 'Describe',
      },
    ],
  })
    const templates = new FeatureTemplates({
    container: 'addTemplatesDiv',
    layers: [featureLayer],
  })

FeatureForm 可以定义要编辑的属性

FeatureTemplates 主要目的是显示 来自一个或多个要素图层的模板。除了显示要素图层模板之外,还可以对模板进行过滤和分组,以提供更轻松的编辑体验。小部件侦听最终用户以在小部件中选择特定模板。它的select事件被触发并返回生成的模板信息。

4、FeatureTemplates select事件监听、FeatureForm submint事件监听

featureForm.on('submit', () => {
    if (editFeature) {
      const updated = featureForm.getValues()
      Object.keys(updated).forEach((name) => {
        editFeature.attributes[name] = updated[name]
      })
      const edits = {
        updateFeatures: [editFeature],
      }
      applyEditsToIncidents(edits)
      document.getElementById('viewDiv').style.cursor = 'auto'
    }
  })
selectExistingFeature()  
templates.on('select', (evtTemplate) => {
    attributes = evtTemplate.template.prototype.attributes
    unselectFeature()
    document.getElementById('viewDiv').style.cursor = 'crosshair'
    const handler = view.on('click', (event) => {
      handler.remove()
      event.stopPropagation()
      featureForm.feature = null
      if (event.mapPoint) {
        point = event.mapPoint.clone()
        point.z = undefined
        point.hasZ = false
        editFeature = new Graphic({
          geometry: point,
          attributes: {
            IncidentType: attributes.IncidentType,
          },
        })
        const edits = {
          addFeatures: [editFeature],
        }
        applyEditsToIncidents(edits)
        document.getElementById('viewDiv').style.cursor = 'auto'
      } else {
        console.error('event.mapPoint is not defined')
      }
    })
  })

  function applyEditsToIncidents(params) {
    featureLayer
      .applyEdits(params)
      .then((editsResult) => {
        if (editsResult.addFeatureResults.length > 0 || editsResult.updateFeatureResults.length > 0) {
          unselectFeature()
          let objectId
          if (editsResult.addFeatureResults.length > 0) {
            objectId = editsResult.addFeatureResults[0].objectId
          } else {
            featureForm.feature = null
            objectId = editsResult.updateFeatureResults[0].objectId
          }
          selectFeature(objectId)
          if (addFeatureDiv.style.display === 'block') {
            toggleEditingDivs('none', 'block')
          }
        }
        else if (editsResult.deleteFeatureResults.length > 0) {
          toggleEditingDivs('block', 'none')
        }
      })
      .catch((error) => {
        console.log('error = ', error)
      })
  }
  function selectExistingFeature() {
    view.on('click', (event) => {
      unselectFeature()
      if (document.getElementById('viewDiv').style.cursor != 'crosshair') {
        view.hitTest(event).then((response) => {
          if (response.results.length === 0) {
            toggleEditingDivs('block', 'none')
          } else if (response.results[0].graphic && response.results[0].graphic.layer.id == 'incidentsLayer') {
            if (addFeatureDiv.style.display === 'block') {
              toggleEditingDivs('none', 'block')
            }
            selectFeature(response.results[0].graphic.attributes[featureLayer.objectIdField])
          }
        })
      }
    })
  }

  function selectFeature(objectId) {
    featureLayer
      .queryFeatures({
        objectIds: [objectId],
        outFields: ['*'],
        returnGeometry: true,
      })
      .then((results) => {
        if (results.features.length > 0) {
          editFeature = results.features[0]
          featureForm.feature = editFeature
          view.whenLayerView(editFeature.layer).then((layerView) => {
            highlight = layerView.highlight(editFeature)
          })
        }
      })
  }
// featureForm定位到地图上
  const editExpand = new Expand({
    expandIconClass: 'esri-icon-edit',
    expandTooltip: 'Expand Edit',
    expanded: true,
    view: view,
    content: document.getElementById('editArea'),
  })
  view.ui.add(editExpand, 'top-right') 
  // input boxes for the attribute editing
  const addFeatureDiv = document.getElementById('addFeatureDiv')
  const attributeEditing = document.getElementById('featureUpdateDiv')

  // Controls visibility of addFeature or attributeEditing divs
  function toggleEditingDivs(addDiv, attributesDiv) {
    addFeatureDiv.style.display = addDiv
    attributeEditing.style.display = attributesDiv

    document.getElementById('updateInstructionDiv').style.display = addDiv
  }

  function unselectFeature() {
    if (highlight) {
      highlight.remove()
    }
  }
  document.getElementById('btnUpdate').onclick = () => {
    featureForm.submit()
  }

  document.getElementById('btnDelete').onclick = () => {
    const edits = {
      deleteFeatures: [editFeature],
    }
    applyEditsToIncidents(edits)
    document.getElementById('viewDiv').style.cursor = 'auto'
  }

5、给图层添加popupTemplate

  let popupTemplate = new PopupTemplate({
    title: '{type}',
    outFields: ['*'],
    content: [
      {
        type: 'fields',
        fieldInfos: [
          {
            fieldName: 'type',
            label: '类型',
          },
          {
            fieldName: 'name',
            label: '名字',
          },
          {
            fieldName: 'description',
            label: '描述',
          },
          {
            fieldName: 'range',
            label: '项目周期',
          },
          {
            fieldName: 'process',
            label: '项目进度',
          },
        ],
      },
    ],
  })
  popupTemplate.overwriteActions = false
// 在layers中添加popupTemplate: popupTemplate,

6、给图层的要素添加label


    const labelingInfo = [
      new LabelClass({
        labelExpressionInfo: { expression: '$feature.name' },
        symbol: {
          type: 'label-3d',
          symbolLayers: [
            {
              type: 'text',
              material: {
                color: '#FFFFFF',
              },
              halo: {
                size: 1,
                color: [0, 0, 0, 0.5],
              },
              font: {
                size: 11,
                family: 'sans-serif',
              },
            },
          ],
        },
      }),
    ]
    // 在layers中添加labelingInfo: labelingInfo,

效果图

在这里插入图片描述

整个流程完整代码如下:

<template>
  <div class="content">
    <div id="editArea" class="editArea-container esri-widget--panel">
      <div id="addFeatureDiv" style="display:block;">
        <h3 class="list-heading">Report Incidents</h3>
        <ul style="font-size: 13px; padding-left: 1.5em;">
          <li>Select template from the list</li>
          <li>Click on the map to create a new feature</li>
          <li>Update associated attribute data</li>
          <li>Click <i>Update Incident Info</i></li>
        </ul>
        <div id="addTemplatesDiv" style="background:#fff;"></div>
      </div>

      <div id="featureUpdateDiv" style="display:none; margin-top: 1em;">
        <h3 class="list-heading">Enter the incident information</h3>
        <div id="attributeArea">
          <div id="formDiv"></div>
          <input type="button" class="esri-button" value="Update incident info" id="btnUpdate" />
        </div>
        <br />
        <div id="deleteArea">
          <input type="button" class="esri-button" value="Delete incident" id="btnDelete" />
        </div>
      </div>

      <div id="updateInstructionDiv" style="text-align:center; display:block">
        <p class="or-wrap"><span class="or-text">Or</span></p>
        <p id="selectHeader">Select an incident to edit or delete.</p>
      </div>
    </div>
    <div id="viewDiv"></div>
  </div>
</template>

<script>
import { onMounted, ref } from 'vue'
import Map from '@arcgis/core/Map'
// import MapView from "@arcgis/core/views/MapView";
import esriConfig from '@arcgis/core/config'
import FeatureLayer from '@arcgis/core/layers/FeatureLayer'
import ElevationLayer from '@arcgis/core/layers/ElevationLayer'
import SceneView from '@arcgis/core/views/SceneView'
import LabelClass from '@arcgis/core/layers/support/LabelClass'
import Basemap from '@arcgis/core/Basemap'
import TileLayer from '@arcgis/core/layers/TileLayer'

import GraphicsLayer from '@arcgis/core/layers/GraphicsLayer'
import LayerList from '@arcgis/core/widgets/LayerList'
import PopupTemplate from '@arcgis/core/PopupTemplate'

// 加点
import Graphic from '@arcgis/core/Graphic'
import FeatureForm from '@arcgis/core/widgets/FeatureForm'
import Expand from '@arcgis/core/widgets/Expand'
import FeatureTemplates from '@arcgis/core/widgets/FeatureTemplates'

// 坐标转换
import SpatialReference from '@arcgis/core/geometry/SpatialReference'

export default {
  data() {
    return {}
  },
  setup() {
    const map = ref(null)
    onMounted(init)
    return { map }
  },
}
function init() {
  let editFeature, highlight, point, attributes
  const WKT = {
    GZ2000:
 'PROJCS["GUANGZHOU2000",GEOGCS["GCS_China_Geodetic_Coordinate_System_2000",DATUM["D_China_2000",SPHEROID["CGCS2000",6378137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Gauss_Kruger"],PARAMETER["False_Easting",0.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",113.28],PARAMETER["Scale_Factor",1.0],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0]]',
  }
  const spatialRefference = new SpatialReference({
    wkt: WKT.GZ2000,
  })
  esriConfig.apiKey = '你的key-'
  const basemap = new Basemap({
    baseLayers: [
      // 新龙地图
      new TileLayer({
        url: '你的底图url',
        maxScale: 0,
        spatialRefference,
      }),
    ],
  })
  const map = new Map({
    ground: {
      layers: [
        new ElevationLayer({
          url: 'https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer',
        }),
      ],
      surfaceColor: '#004C73',
      opacity: 0.7,
    },
    basemap: basemap,
  })
  let popupTemplate = new PopupTemplate({
    title: '{type}',
    outFields: ['*'],
    content: [
      {
        type: 'fields',
        fieldInfos: [
          {
            fieldName: 'type',
            label: '类型',
          },
          {
            fieldName: 'name',
            label: '名字',
          },
          {
            fieldName: 'description',
            label: '描述',
          },
          {
            fieldName: 'range',
            label: '项目周期',
          },
          {
            fieldName: 'process',
            label: '项目进度',
          },
        ],
      },
    ],
  })
  popupTemplate.overwriteActions = false
  const featureLayer = new FeatureLayer({
    url: '你的图层',
  })

  // Arcgis服务器自建几何图层
  const pointLayer = new FeatureLayer({
    url: 'https://services3.arcgis.com/epoWLYQESXEPLkZd/arcgis/rest/services/0830/FeatureServer/0',
    popupTemplate: popupTemplate,
    id: 'incidentsLayer',
    labelingInfo: [
      new LabelClass({
        labelExpressionInfo: { expression: '$feature.name' },
        symbol: {
          type: 'label-3d',
          symbolLayers: [
            {
              type: 'text',
              material: {
                color: '#FFFFFF',
              },
              halo: {
                size: 1,
                color: [0, 0, 0, 0.5],
              },
              font: {
                size: 11,
                family: 'sans-serif',
              },
            },
          ],
        },
      }),
    ],
  })

  // client几何图层
  const graphicsLayer = new GraphicsLayer()
  map.addMany([pointLayer, graphicsLayer, featureLayer])
  const view = new SceneView({
    container: 'viewDiv',
    map: map,
    qualityProfile: 'high',
    camera: {
      position: [113.88951058035408, 2.2075023372885347, 1604.65501],
      heading: 0.51,
      tilt: 78.99,
    },
    spatialRefference,
  })


  const layerList = new LayerList({
    view: view,
  })
  view.ui.add(layerList, 'bottom-left')

  const featureForm = new FeatureForm({
    container: 'formDiv',
    layer: pointLayer,
    fieldConfig: [
      {
        name: 'name',
        label: '点位名称',
      },
      {
        name: 'id',
        label: 'id',
      },
      {
        name: 'type',
        label: '类型',
      },
      {
        name: 'range',
        label: '项目周期',
      },
      {
        name: 'process',
        label: '项目进度',
      },
    ],
  })

  featureForm.on('submit', () => {
    if (editFeature) {
      const updated = featureForm.getValues()
      Object.keys(updated).forEach((name) => {
        editFeature.attributes[name] = updated[name]
      })

      const edits = {
        updateFeatures: [editFeature],
      }
      applyEditsToIncidents(edits)
      document.getElementById('viewDiv').style.cursor = 'auto'
    }
  })

  selectExistingFeature()

  const templates = new FeatureTemplates({
    container: 'addTemplatesDiv',
    layers: [pointLayer],
  })

  templates.on('select', (evtTemplate) => {
    attributes = evtTemplate.template.prototype.attributes
    unselectFeature()
    document.getElementById('viewDiv').style.cursor = 'crosshair'
    const handler = view.on('click', (event) => {
      handler.remove()
      event.stopPropagation()
      featureForm.feature = null

      if (event.mapPoint) {
        point = event.mapPoint.clone()
        point.z = undefined
        point.hasZ = false

        editFeature = new Graphic({
          geometry: point,
          attributes: {
            IncidentType: attributes.IncidentType,
          },
        })
        const edits = {
          addFeatures: [editFeature],
        }
        applyEditsToIncidents(edits)
        document.getElementById('viewDiv').style.cursor = 'auto'
      } else {
        console.error('event.mapPoint is not defined')
      }
    })
  })

  function applyEditsToIncidents(params) {
    pointLayer
      .applyEdits(params)
      .then((editsResult) => {
        if (editsResult.addFeatureResults.length > 0 || editsResult.updateFeatureResults.length > 0) {
          unselectFeature()
          let objectId
          if (editsResult.addFeatureResults.length > 0) {
            objectId = editsResult.addFeatureResults[0].objectId
          } else {
            featureForm.feature = null
            objectId = editsResult.updateFeatureResults[0].objectId
          }
          selectFeature(objectId)
          if (addFeatureDiv.style.display === 'block') {
            toggleEditingDivs('none', 'block')
          }
        }
        else if (editsResult.deleteFeatureResults.length > 0) {
          toggleEditingDivs('block', 'none')
        }
      })
      .catch((error) => {
        console.log('error = ', error)
      })
  }

  function selectExistingFeature() {
    view.on('click', (event) => {
      unselectFeature()
      if (document.getElementById('viewDiv').style.cursor != 'crosshair') {
        view.hitTest(event).then((response) => {
          if (response.results.length === 0) {
            toggleEditingDivs('block', 'none')
          } else if (response.results[0].graphic && response.results[0].graphic.layer.id == 'incidentsLayer') {
            if (addFeatureDiv.style.display === 'block') {
              toggleEditingDivs('none', 'block')
            }
            selectFeature(response.results[0].graphic.attributes[pointLayer.objectIdField])
          }
        })
      }
    })
  }
  function selectFeature(objectId) {
    pointLayer
      .queryFeatures({
        objectIds: [objectId],
        outFields: ['*'],
        returnGeometry: true,
      })
      .then((results) => {
        if (results.features.length > 0) {
          editFeature = results.features[0]
          featureForm.feature = editFeature
          view.whenLayerView(editFeature.layer).then((layerView) => {
            highlight = layerView.highlight(editFeature)
          })
        }
      })
  }
  const editExpand = new Expand({
    expandIconClass: 'esri-icon-edit',
    expandTooltip: 'Expand Edit',
    expanded: true,
    view: view,
    content: document.getElementById('editArea'),
  })
  view.ui.add(editExpand, 'top-right')
  const addFeatureDiv = document.getElementById('addFeatureDiv')
  const attributeEditing = document.getElementById('featureUpdateDiv')
  function toggleEditingDivs(addDiv, attributesDiv) {
    addFeatureDiv.style.display = addDiv
    attributeEditing.style.display = attributesDiv
    document.getElementById('updateInstructionDiv').style.display = addDiv
  }
  function unselectFeature() {
    if (highlight) {
      highlight.remove()
    }
  }

  document.getElementById('btnUpdate').onclick = () => {
    featureForm.submit()
  }
  document.getElementById('btnDelete').onclick = () => {
    const edits = {
      deleteFeatures: [editFeature],
    }
    applyEditsToIncidents(edits)
    document.getElementById('viewDiv').style.cursor = 'auto'
  }
}
</script>

<style lang="scss" scoped>
@import url('https://js.arcgis.com/4.20/esri/themes/light/main.css');
.content {
  margin: 0;
  padding: 0;
}
#viewDiv {
  padding: 0;
  margin: 0;
  height: 80vh;
  width: 70vw;
}
#formDiv {
  width: 100%;
}

.esri-item-list__scroller {
  overflow-y: visible;
}

.editArea-container {
  background: #fff;
  line-height: 1.5em;
  overflow: auto;
  padding: 12px 15px;
  width: 300px;
}

.list-heading {
  font-weight: normal;
  margin-top: 20px;
  margin-bottom: 10px;
  color: #323232;
}

.or-wrap {
  background-color: #e0e0e0;
  height: 1px;
  margin: 2em 0;
  overflow: visible;
}

.or-text {
  background: #fff;
  line-height: 0;
  padding: 0 1em;
  position: relative;
  bottom: 0.75em;
}

/* override default styles */
.esri-feature-form {
  background: #fff;
}

.esri-feature-templates {
  width: 256px;
}

.esri-feature-templates__section-header {
  display: none;
}

.esri-feature-templates__section {
  box-shadow: none;
}

.esri-feature-templates__scroller {
  max-height: 200px;
}
</style>

Search 组件引入

1、组件引入

import Search from '@arcgis/core/widgets/Search'

2、注册到view中

  const view = new SceneView({
    container: 'viewDiv',
    map: map,
    qualityProfile: 'high',
    camera: {
      position: [113.88951058035408, 2.2075023372885347, 1604.65501],
      heading: 0.51,
      tilt: 78.99,
    },
    spatialRefference,
  })
  const searchWidget = new Search({
    view: view,
    includeDefaultSources: false,
    sources: [
      {
        layer: pointLayer,
        placeholder: 'search here',
        maxResults: 10,
        searchFields: ['name'],
        suggestionTemplate: '{name}',
      },
    ],
  })
  view.ui.add(searchWidget, {
    position: 'top-left',
    index: 2,
  })

JSON文件生成图层

1、图层转JSON文件
在这里插入图片描述

// 示例文件 注意 根据ArcMap导出的JSON 需要在features字段geometry添加type 可选值为 'extent','multipoint','point','polyline','polygon'
// features字段geometry x y属性需要看是否是正确的经纬度 如果不是改为经纬度
{
  "displayFieldName" : "",
  "fieldAliases" : {
    "FID" : "FID",
    "GB" : "GB",
    "CNTY_CODE" : "CNTY_CODE",
    "NAME" : "NAME",
    "PYNAME" : "PYNAME",
    "code99" : "code99",
    "FULLNAME" : "FULLNAME",
    "prov_name" : "prov_name",
    "dq_name" : "dq_name",
    "note1" : "note1",
    "note2" : "note2",
    "note3" : "note3",
    "Lon" : "Lon",
    "Lat" : "Lat",
    "DATA_YEAR" : "DATA_YEAR",
    "CLASID" : "CLASID"
  },
  "geometryType" : "point",
  "spatialReference" : {
    "wkt" : "PROJCS[\"WGS_1984_Albers\",GEOGCS[\"GCS_WGS_1984\",DATUM[\"D_WGS_1984\",SPHEROID[\"WGS_1984\",6378137.0,298.257223563]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.0174532925199433]],PROJECTION[\"Albers\"],PARAMETER[\"false_easting\",0.0],PARAMETER[\"false_northing\",0.0],PARAMETER[\"central_meridian\",105.0],PARAMETER[\"standard_parallel_1\",25.0],PARAMETER[\"standard_parallel_2\",47.0],PARAMETER[\"latitude_of_origin\",0.0],UNIT[\"Meter\",1.0]]"
  },
  "fields" : [
    {
      "name" : "FID",
      "type" : "oid",
      "alias" : "FID"
    },
    {
      "name" : "GB",
      "type" : "double",
      "alias" : "GB"
    },
    {
      "name" : "CNTY_CODE",
      "type" : "double",
      "alias" : "CNTY_CODE"
    },
    {
      "name" : "NAME",
      "type" : "string",
      "alias" : "NAME",
      "length" : 254
    },
    {
      "name" : "PYNAME",
      "type" : "string",
      "alias" : "PYNAME",
      "length" : 254
    },
    {
      "name" : "code99",
      "type" : "double",
      "alias" : "code99"
    },
    {
      "name" : "FULLNAME",
      "type" : "string",
      "alias" : "FULLNAME",
      "length" : 254
    },
    {
      "name" : "prov_name",
      "type" : "string",
      "alias" : "prov_name",
      "length" : 254
    },
    {
      "name" : "dq_name",
      "type" : "string",
      "alias" : "dq_name",
      "length" : 254
    },
    {
      "name" : "note1",
      "type" : "string",
      "alias" : "note1",
      "length" : 254
    },
    {
      "name" : "note2",
      "type" : "string",
      "alias" : "note2",
      "length" : 254
    },
    {
      "name" : "note3",
      "type" : "string",
      "alias" : "note3",
      "length" : 254
    },
    {
      "name" : "Lon",
      "type" : "double",
      "alias" : "Lon"
    },
    {
      "name" : "Lat",
      "type" : "double",
      "alias" : "Lat"
    },
    {
      "name" : "DATA_YEAR",
      "type" : "double",
      "alias" : "DATA_YEAR"
    },
    {
      "name" : "CLASID",
      "type" : "string",
      "alias" : "CLASID",
      "length" : 254
    }
  ],
  "features" : [
    {
      "attributes" : {
        "FID" : 0,
        "GB" : 31060,
        "CNTY_CODE" : 440224,
        "NAME" : "仁化县",
        "PYNAME" : "Renhua Xian",
        "code99" : 440224,
        "FULLNAME" : "仁化县(仁化镇)",
        "prov_name" : "广东省",
        "dq_name" : "韶关市",
        "note1" : "1 ",
        "note2" : "1 ",
        "note3" : "1 ",
        "Lon" : 113.743736,
        "Lat" : 25.090707999999999,
        "DATA_YEAR" : 1996,
        "CLASID" : "440224"
      },
      "geometry" : {
        "x" : 113.743736,
        "y" : 25.090707999999999,
        "type": "point"
      }
    },
    {
      "attributes" : {
        "FID" : 1,
        "GB" : 31050,
        "CNTY_CODE" : 440225,
        "NAME" : "乐昌市",
        "PYNAME" : "Lechang Shi",
        "code99" : 440281,
        "FULLNAME" : "乐昌市",
        "prov_name" : "广东省",
        "dq_name" : "韶关市",
        "note1" : "2 ",
        "note2" : "22 ",
        "note3" : " ",
        "Lon" : 113.34586299999999,
        "Lat" : 25.133410000000001,
        "DATA_YEAR" : 1996,
        "CLASID" : "440225"
      },
      "geometry" : {
        "x" : 113.34586299999999,
        "y" : 25.133410000000001,
        "type": "point"
      }
    },
    {
      "attributes" : {
        "FID" : 2,
        "GB" : 31060,
        "CNTY_CODE" : 440223,
        "NAME" : "南雄市",
        "PYNAME" : "Nanxiong Shi",
        "code99" : 440282,
        "FULLNAME" : "南雄市",
        "prov_name" : "广东省",
        "dq_name" : "韶关市",
        "note1" : "撤销南雄县,设立南雄市(县级)",
        "note2" : "增设",
        "note3" : "3 ",
        "Lon" : 114.30789900000001,
        "Lat" : 25.119730000000001,
        "DATA_YEAR" : 1996,
        "CLASID" : "440223"
      },
      "geometry" : {
        "x" : 114.30789900000001,
        "y" : 25.119730000000001,
        "type": "point"
      }
    }
  ]
}

组件引入等

import Map from '@arcgis/core/Map'
import MapView from '@arcgis/core/views/MapView'
import FeatureSet from '@arcgis/core/rest/support/FeatureSet'
import FeatureLayer from '@arcgis/core/layers/FeatureLayer'
import countypoint from '../assets/countypoint.json'  // 到处的JSON文件
var featureSet = FeatureSet.fromJSON(countypoint)
const graphics = countypoint.features
var featureCollection = {
    source: graphics,
    objectIdField: 'FID',
    geometryType: 'point',
  }
var featurelayer = new FeatureLayer(featureCollection)
const map = new Map({
    basemap: 'dark-gray-vector',
    layers: [featurelayer],
})
new MapView({
    container: 'viewDiv',
    map: map,
    center: [113.5861, 25.037278],
    zoom: 10,
})

图层的特征渲染

SimpleRenderer

import SimpleRenderer from "@arcgis/core/renderers/SimpleRenderer";
let citiesRenderer = {
  type: "simple", 
  symbol: {
    type: "simple-marker", 
    size: 6,
    color: "black",
    outline: {  
      width: 0.5,
      color: "white"
    }
  }
};
let citiesLayer = new FeatureLayer({
  url: "https://services3.arcgis.com/tgYU2qbxZbWPWXPL/arcgis/rest/services/toimages/FeatureServer/0",
  renderer: citiesRenderer
});

arsgis 点图层导入及icon编辑

1、进入Arcgis Online

2、进入Content标签,找到需要编辑的图层。点击view item details
在这里插入图片描述

3、图层详情页面 点击Visualization 在左侧点击Change Style
在这里插入图片描述

4、选择出自己图层需要分类的属性字段、select a drawing seyle 点击 Types 后点击options

在这里插入图片描述

5、点击分类这里的图标可进行替换(默认为小圆点)、在icon页面可选择自有图标(Use an Image)

注:图标格式最好为png gif jpeg并且是网络图片

在这里插入图片描述

6、点击右侧的Save Layer 如不替换原图层则点击Save As New Layer

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值