當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


JavaScript ArcGIS GeometryService.labelPoints用法及代碼示例

基本信息

以下是所在類或對象的基本信息。

AMD: require(["esri/tasks/GeometryService"], (GeometryService) => { /* code goes here */ });

ESM: import GeometryService from "@arcgis/core/tasks/GeometryService";

類: esri/tasks/GeometryService

繼承: GeometryService > Task > Accessor

自從:用於 JavaScript 4.0 的 ArcGIS API

用法說明

GeometryService.labelPoints函數(或屬性)的定義如下:

labelPoints (polygons, requestOptions) {Promise<Point>}


為每個指定的多邊形計算一個內部點。客戶端可以使用這些內部點來標記多邊形。

參數:

類型說明
polygons Polygon[]

要處理的多邊形圖形。

requestOptions Object
可選的

用於數據請求的附加 options

返回:

類型 說明
Promise<Point> 解析後,返回一個 Point 幾何數組,定義可用於標注的輸入多邊形的內部點。

例子:

if (geometries[0].rings.length > 0) {
 geometryService.labelPoints(geometries).then(function(labelPoints) {
  let graphics = labelPoints.map(function(labelPoint, i){
      let textSymbol = {
        type: "text",  // autocasts as new TextSymbol()
        color: "white",
        haloColor: "black",
        haloSize: "1px",
        text: "X: " + number.format(labelPoint.x) + ", Y: " + number.format(labelPoint.y),
        xoffset: 3,
        yoffset: 3,
        font: {  // autocast as new Font()
          size: 12,
          family: "sans-serif",
          weight: "bolder"
        }
      };
    let labelPointGraphic = new Graphic({
      geometry: labelPoint,
      symbol: textSymbol
    });
    return labelPointGraphic;
  });

  // add the labels to the map
  view.graphics.addMany(graphics);
 });
}

相關用法


注:本文由純淨天空篩選整理自arcgis.com大神的英文原創作品 GeometryService.labelPoints。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。