多段线 - Polyline

约 120 字小于 1 分钟

简单示例

import Map from "@arcgis/core/Map"
import MapView from "@arcgis/core/views/MapView"
import Graphic from "@arcgis/core/Graphic"

const map = new Map({
  basemap: 'dark-gray',
})

const mapView = new MapView({
  map,
  container: 'js_map',
  center: [102.92934063304513, 25.102234987110343]
})

const polylineGraphic = new Graphic({
  geometry: {
    type: "polyline",
    paths: [
      [-111.3, 52.68],
      [-98, 49.5],
      [-93.94, 29.89]
    ]
  },
  symbol: {
    type: "simple-line",
    color: [226, 119, 40],
    width: 4
  }
})

mapView.graphics.add(polylineGraphic)

更新 geometry

polylineGraphic.geometry = {
  type: "polyline",
  paths: [
    [  // 第1个 path
      [-97.06138,32.837,5],
      [-97.06133,32.836,6],
      [-97.06124,32.834,7]
    ], [  // 第2个 path
      [-97.06326,32.759],
      [-97.06298,32.755]
    ]
  ]
}

更新 symbol

polylineGraphic.symbol = {
  type: "simple-line",
  color: [226, 119, 40],
  width: 4
}
上次编辑于: