PilotGaea 2D O'view
    正在準備搜尋索引...

    類別 CVectorLayer

    向量圖層。

    const vectorLayer = myMapDoc.NewVectorLayer({ Name: "test" });
    

    層級 (查看層級一覽)

    索引

    方法

    • 新增點圖素 (圓形顏色)。

      參數

      • p: GeoPoint

        點中心位置。

      • color: string

        顏色。

      • radius: number

        圓半徑。

      • 可選unit: UNIT

        圖素大小單位。

      • 可選textStyle: CTextStyle

        標籤樣式,沒指定就不顯示標籤。

      回傳 string | number

      傳回圖素 ID。

      棄用,建議使用 NewPoint

      let id = vectorLayer.NewPoint_Color(new GeoPoint(), "#ffffff", 10, UNIT.PIXEL);
      let id = vectorLayer.NewPoint_Color(new GeoPoint(), "rgb(0,0,0)", 10000, UNIT.MAP);
      let id = vectorLayer.NewPoint_Color(new GeoPoint(), "rgb(0,0,0)", 10, UNIT.PIXEL, text);
    • 新增點圖素 (符號)。

      參數

      • p: GeoPoint

        點中心位置。

      • symbolUrl: string

        符號圖片的連結。

      • 可選size: CSize

        符號大小,沒給則用符號圖片本身的大小。

      • 可選textStyle: CTextStyle

        標籤樣式,沒指定就不顯示標籤。

      回傳 string | number

      傳回圖素 ID。

      棄用,建議使用 NewPoint

      let id = vectorLayer.NewPoint_Symbol(new GeoPoint(), "http://127.0.0.1:8080/Position48.png", new CSize(128, 128), text );
      let id = vectorLayer.NewPoint_Symbol(new GeoPoint(), "http://127.0.0.1:8080/Position48.png");
    • 新增點,若要大量新增建議使用 NewBatchPoint

      如果有需要文字標籤,先建立文字樣式物件,見 CTextStyle

      參數

      回傳 string | number | ol.Feature

      傳回圖素 ID (預設) 或圖素本身。

      // 新增圓點
      this.VectorLayer.NewPoint({
      Point: new GeoPoint(163887.80, 2600000),
      FillColor: "rgba(0, 0, 1, 0)",
      Radius: 1000,
      RadiusUnit: UNIT.MAP,
      TextStyle: textStyle
      });

      // 新增符號
      this.VectorLayer.NewPoint({
      Point: new GeoPoint(165000, 2650000),
      SymbolUrl: "http://127.0.0.1:8080/台灣全圖_84TM2.jpg",
      SymbolSize: new CSize(48, 48),
      TextStyle: textStyle
      });

      // 預設回傳 Feature ID,設定 ReturnType: "SELF" 則回傳 Feature 物件
      this.VectorLayer.NewPoint({
      //...
      ReturnType: "SELF"
      });
    • 批量新增點圖素。

      如果有需要文字標籤,先建立文字樣式物件,見 CTextStyle

      參數

      • params: BatchPointParameter[]

        參數。

      • callback: (featureId: number[] | ol.Feature[]) => void

        回呼函式。

      • doNotAddToSource: boolean = false

        true 則不自動將圖素加入圖層,之後手動加入,預設為false

      • returnType: string = ""

        回呼函式傳入型態,"SELF"則傳入 Feature 物件,預設傳入 Feature ID。

      回傳 void

      let callback = (featureId) => console.log(featureId);

      // 批量新增圓點
      this.VectorLayer.NewBatchPoint([
      {
      Point: new GeoPoint(163887.80, 2600000),
      FillColor: "rgba(0, 0, 1, 0)",
      Radius: 1000,
      RadiusUnit: UNIT.MAP,
      TextStyle: textStyle
      },
      //...
      ], callback);

      // 批量新增符號
      this.VectorLayer.NewBatchPoint([
      {
      Point: new GeoPoint(165000, 2650000),
      SymbolUrl: "http://127.0.0.1:8080/台灣全圖_84TM2.jpg",
      SymbolSize: new CSize(48, 48),
      TextStyle: textStyle
      },
      //...
      ], callback);
    • 新增聚合線圖素。

      參數

      回傳 string | number | ol.Feature

      傳回圖素 ID。

      棄用,建議使用 NewPolylineByParam

      const id = vectorLayer.NewPolyline(new GeoPolyline(buffer), "#FFFFFF", 5 );
      const id = vectorLayer.NewPolyline(new GeoPolyline(buffer), "#FFFFFF", 5, text);
    • 新增聚合線圖素。

      如果有需要文字標籤,先建立文字樣式物件,見 CTextStyle

      參數

      回傳 string | number | ol.Feature

      傳回圖素 ID (預設) 或圖素本身。

      // 新增線圖素
      vectorLayer.NewPolylineByParam({
      Polyline: new GeoPolyline(buffer),
      StrokeColor: "black",
      StrokeWidth: 5,
      TextStyle: textStyle,
      ShowArrow: true,
      LineDash: [4, 8]
      });
    • 新增面圖素。

      參數

      • polygon: PolygonEntityParameter | GeoPolygon

        圖素設定參數。

      • strokeColor: string

        外框顏色。

      • strokeWidth: number

        外框寬度。

      • fillColor: string

        塗滿顏色。

      • 可選textStyle: CTextStyle

        標籤樣式,沒指定就不顯示標籤。

      • ...args: unknown[]

      回傳 string | number | ol.Feature

      傳回圖素 ID (預設) 或圖素本身。

      棄用,建議使用 NewPolygonByParam

      const id = vectorLayer.NewPolygon(new GeoPolygon(buffer), "#FFFFFF", 5, "rgb(255, 0, 0)" );
      // 使用預設的文字樣式
      const id = vectorLayer.NewPolygon(new GeoPolygon(buffer), "#FFFFFF", 5, "rgb(255, 0, 0)", new CTextStyle());
    • 新增面圖素。

      如果有需要文字標籤,先建立文字樣式物件,見 CTextStyle

      參數

      回傳 string | number | ol.Feature

      傳回圖素 ID (預設) 或圖素本身。

      // 新增面圖素
      this.VectorLayer.NewPolygonByParam({
      Polygon: new GeoPolygon(buffer) ,
      StrokeColor: "#FFFFFF",
      StrokeWidth: 5,
      FillColor: "rgba(255, 0, 0, 0.5)",
      TextStyle: textStyle,
      LineDash: [4, 8]
      });
    • 新增多面圖素。

      參數

      • polygonSet: PolygonSetEntityParameter | GeoPolygonSet

        多面圖素。

      • strokeColor: string

        外框顏色。

      • strokeWidth: number

        外框寬度。

      • fillColor: string

        塗滿顏色。

      • 可選textStyle: CTextStyle

        標籤樣式,沒指定就不顯示標籤。

      • nullInside: boolean = true

        是否要空心,預設為 true

      • ...args: unknown[]

      回傳 string | number | ol.Feature

      傳回圖素 ID (預設) 或圖素本身。

      棄用,建議使用 NewPolygonSetByParam

      const polygonSet = new GeoPolygonSet(buffer);
      const strokeColor = "#ffffff";
      const strokeWidth = 5;
      const fillColor = "rgb(255, 0, 0)";
      let id = vectorLayer.NewPolygonSet(polygonSet, strokeColor, strokeWidth, fillColor);
      // 不顯示標籤
      let id = vectorLayer.NewPolygonSet(polygonSet, strokeColor, strokeWidth, fillColor, "" , true);
      // 顯示標籤
      let id = vectorLayer.NewPolygonSet(polygonSet, strokeColor, strokeWidth, fillColor, text, true);
    • 新增多面圖素。

      如果有需要文字標籤,先建立文字樣式物件,見 CTextStyle

      參數

      回傳 string | number | ol.Feature

      傳回圖素 ID (預設) 或圖素本身。

      // 新增線圖素
      this.VectorLayer.NewPolygonSetByParam({
      PolygonSet: polygonSet,
      StrokeColor: "#ff00ff",
      StrokeWidth: 5,
      FillColor: "rgb(255, 0, 0)",
      TextStyle: textStyle, // 見 CTextStyle
      NullInside: true,
      LineDash: [4, 8]
      });
    • 新增文字圖素。

      參數

      • point: GeoPoint | TextEntityParameter

        文字坐標 (世界)。

      • textStyle: CTextStyle

        標籤樣式。

      • showPoint: boolean = false

        是否要顯示圓點,預設false

      • 可選pointColor: string

        圓點顏色,預設為紅色。

      • 可選pointRadius: number

        圓點半徑,預設為1

      • 可選pointUnit: UNIT

        半徑單位類型,預設為UNIT.PIXEL

      • ...args: unknown[]

      回傳 string | number | ol.Feature

      傳回圖素 ID (預設) 或圖素本身。

      棄用,建議使用 NewTextByParam

      const id = CVectorLayer.NewText(new GeoPoint(5,5), text);
      const id = CVectorLayer.NewText(new GeoPoint(5,5), text, false); // 不顯示圓點
      const id = CVectorLayer.NewText(new GeoPoint(5,5), text, true, "#FF0000", 20, UNIT.PIXEL); // 顯示圓點
    • 新增文字圖素。

      參數

      回傳 string | number | ol.Feature

      傳回圖素 ID。

      // 先建立文字樣式物件
      let textStyle = new CTextStyle();
      textStyle.Text = "New Text";
      textStyle.ContentStyle = "Shorten";
      textStyle.Weight = "bold";
      textStyle.FillColor = "yellow"
      textStyle.Baseline = "middle";
      textStyle.StrokeColor = "rgba(0, 0, 0, 0.5)";
      textStyle.StrokeWidth = 3;
      textStyle.Rotation = 1.57;
      textStyle.Size = 12;

      // 新增文字圖素
      this.VectorLayer.NewTextByParam({
      Point: new GeoPoint(175000, 2542575.6165581764),
      TextStyle: textStyle,
      ShowPoint: true,
      PointFillColor: "#00ff00",
      PointRadius: 100,
      PointRadiusUnit: UNIT.PIXEL,
      Tooltip: "<h1>Tooltip</h1><p>Lorem Ipsum</p>"
      });
    • 批次加入圖素。

      參數

      回傳 void

    • 設定是否顯示圖素

      參數

      • id: number

        指定圖素id

      • show: boolean

        是否顯示

      回傳 boolean

      回傳更新是否成功

    • 設定 Tooltip

      參數

      • id: number
      • tooltip: string

      回傳 void

    • 移除圖層上指定圖素。

      參數

      • id: number

        指定圖素 id。

      回傳 boolean

      是否成功移除,找不到指定圖素時回傳 false

    • 移除圖層上所有圖素。

      回傳 void

    • 取得指定圖素的類型

      參數

      • id: number

        指定圖素Id

      回傳 ENTITY_TYPE

      圖素類型,若id沒有找到指定的圖素則回傳為ENTITY_TYPE.NONE(=0)

    • 取得圖層上所有圖素的Id。

      回傳 number[]

      圖素Id陣列。

    • 在圖層上搜尋固定範圍(螢幕上5px)內的圖素Id

      參數

      回傳 number[]

      圖素Id陣列

    • 設定叢集合併的最大距離

      參數

      • distance: number

        叢集合併最大距離

      回傳 void

    • 把所有圖素轉成Json陣列字串

      回傳 string

      Json字串

    訪問器屬性

    • get type(): LAYER_TYPE_2D

      圖層類別

      回傳 LAYER_TYPE_2D

    • get Boundary(): GeoBoundary

      圖層範圍

      回傳 GeoBoundary

    • get Show(): boolean

      是否顯示圖層

      回傳 boolean

    • set Show(value: boolean): void

      是否顯示圖層

      參數

      • value: boolean

      回傳 void

    • get Alpha(): number

      圖層透明度

      回傳 number

    • set Alpha(value: number): void

      圖層透明度

      參數

      • value: number

      回傳 void

    • get Name(): string

      圖層名稱

      回傳 string

    • get MaxResolution(): number

      圖層的最大解析度

      回傳 number

    • get MinResolution(): number

      圖層的最小解析度

      回傳 number

    • get ZIndex(): number

      圖層Z-Index (圖層的繪製順序)

      回傳 number

    • set ZIndex(zIndex: number): void

      圖層Z-Index (圖層的繪製順序)

      參數

      • zIndex: number

      回傳 void