向量圖層 不能直接呼叫CVectorLayer的建構函式,您應該從已經存在的CMapDocument物件,透過NewVectorLayer新增CVectorLayer

Param: MapDocument

地圖文件。

Param: Obj

圖層設定。

Example

var vLayerId = myMapDoc.NewVectorLayer("test");

Hierarchy

Methods

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

    Returns number[]

    圖素Id陣列

  • 取得指定圖素的類型

    Parameters

    • id: number

      指定圖素Id

    Returns number

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

  • 批次加入圖素

    Parameters

    • features: Feature[]

      圖素陣列

    Returns void

  • 新增批量點圖素

    Parameters

    • Param: NewBatchPointParameter[]

      參數

    • Callback: NewBatchPointCallback

      回呼函式,function(featureId)

    • Optional LaterAddToSource: boolean = false

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

    • Optional ReturnType: string = ""

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

    Returns undefined | -1

    Example

    //可以設定參數有:Point, FillColor, Radius, RadiusUnit, SymbolUrl, SymbolSize, SymbolRotation(弧度), TextStyle, Tooltip。
    //如果有需要文字標籤,先建立文字樣式物件
    var text = new CTextStyle();
    text.Text = "jgoah-ih;fjaghaihf-kajsnvoahgihufkjakhgqaihf";
    text.ContentStyle = 'Shorten';
    text.Weight = 'bold';
    text.FillColor = 'yellow'
    text.Baseline = 'middle';
    text.StrokeColor = 'rgba(0,0,0,0.5)';
    text.StrokeWidth = 3;
    text.Rotation = 1.57;
    text.Size = 12;
    var callback = function(featureId){}
    //新增圓點
    this.VectorLayer.NewBatchPoint([{ 'Point': new GeoPoint(163887.80, 2600000), 'FillColor': 'argb(0,0,0,1)', 'Radius': 1000, 'RadiusUnit': UNIT.MAP, 'TextStyle': text },...], callback);
    //新增符號
    this.VectorLayer.NewBatchPoint([{ 'Point': new GeoPoint(165000, 2650000), 'SymbolUrl': 'http://127.0.0.1:8080/台灣全圖_84TM2.jpg', 'SymbolSize': new CSize(48, 48), 'TextStyle': text },...], callback);
  • 新增點,若要大量新增則請使用NewBatchPoint

    Parameters

    • Obj: {
          FillColor: undefined | string | CanvasPattern | CanvasGradient;
          LaterAddToSource: undefined | boolean;
          Point: GeoPoint;
          Radius: undefined | number;
          RadiusUnit: undefined | number;
          ReturnType: undefined | "SELF";
          SymbolRotation: undefined | number;
          SymbolSize: undefined | CSize;
          SymbolUrl: undefined | string;
          TextStyle: undefined | CTextStyle;
          Tooltip: undefined | string;
      }

      圖素設定參數

      • FillColor: undefined | string | CanvasPattern | CanvasGradient

        顏色。

      • LaterAddToSource: undefined | boolean

        是否稍後再加入。

      • Point: GeoPoint

        點座標。

      • Radius: undefined | number

        半徑。

      • RadiusUnit: undefined | number

        作畫單位。

      • ReturnType: undefined | "SELF"

        回傳型態,"SELF"為ol.Feature。

      • SymbolRotation: undefined | number

        圖片旋轉角度(弧度)。

      • SymbolSize: undefined | CSize

        圖片大小。

      • SymbolUrl: undefined | string

        圖片來源。

      • TextStyle: undefined | CTextStyle

        文字樣式。

      • Tooltip: undefined | string

        提示文字。

    Returns any

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

    Example

    //可以設定參數有:Point, FillColor, Radius, RadiusUnit, SymbolUrl, SymbolSize, SymbolRotation(弧度), TextStyle, Tooltip, LaterAddToSource, ReturnType。
    //如果有需要文字標籤,先建立文字樣式物件
    var text = new CTextStyle();
    text.Text = "jgoah-ih;fjaghaihf-kajsnvoahgihufkjakhgqaihf";
    text.ContentStyle = 'Shorten';
    text.Weight = 'bold';
    text.FillColor = 'yellow'
    text.Baseline = 'middle';
    text.StrokeColor = 'rgba(0,0,0,0.5)';
    text.StrokeWidth = 3;
    text.Rotation = 1.57;
    text.Size = 12;
    //新增圓點
    this.VectorLayer.NewPoint({ 'Point': new GeoPoint(163887.80, 2600000), 'FillColor': 'argb(0,0,0,1)', 'Radius': 1000, 'RadiusUnit': UNIT.MAP, 'TextStyle': text });
    //新增符號
    this.VectorLayer.NewPoint({ 'Point': new GeoPoint(165000, 2650000), 'SymbolUrl': 'http://127.0.0.1:8080/台灣全圖_84TM2.jpg', 'SymbolSize': new CSize(48, 48), 'TextStyle': text });
    //回傳型態
    this.VectorLayer.NewPoint({ ..., ReturnType: 'SELF' }); 則回傳Feature物件,預設回傳Feature ID
  • Parameters

    • p: GeoPoint

      點中心位置

    • color: string

      顏色

    • Radius: any
    • Optional unit: number

      圖素大小單位 UNIT.MAP:半徑以公尺為單位, UNIT.PIXEL:半徑以螢幕上的像素為單位,不給預設為UNIT.PIXEL

    • Optional textStyle: CTextStyle

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

    Returns number

    傳回圖素ID

    Deprecated

    新增點圖素(圓形顏色)

    Example

    var id = CVectorLayer.NewPoint_Color(new GeoPoint(), '#FFFFFF', 10, UNIT.PIXEL);
    var id = CVectorLayer.NewPoint_Color(new GeoPoint(), 'rgb(0,0,0)', 10000, UNIT.MAP);
    var id = CVectorLayer.NewPoint_Color(new GeoPoint(), 'rgb(0,0,0)', 10, UNIT.PIXEL, text);
  • Parameters

    • p: GeoPoint

      點中心位置

    • SymbolUrl: string

      符號圖片的連結

    • Optional size: CSize

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

    • Optional textStyle: CTextStyle

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

    Returns number

    傳回圖素ID

    Deprecated

    新增點-符號圖素

    Example

    var id = CVectorLayer.NewPoint_Symbol(new GeoPoint(), 'http://127.0.0.1:8080/Position48.png', new CSize(128,128), text );
    var id = CVectorLayer.NewPoint_Symbol(new GeoPoint(), 'http://127.0.0.1:8080/Position48.png');
  • 新增面圖素

    Parameters

    • Polygon: object | GeoPolygon

      圖素設定參數

    • StrokeColor: string

      外框顏色

    • StrokeWidth: number

      外框寬度

    • FillColor: string

      塗滿顏色

    • Optional textStyle: CTextStyle

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

    • Rest ...args: any

    Returns any

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

    Example

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

    Parameters

    • Obj: {
          FillColor: undefined | string | CanvasPattern | CanvasGradient;
          LaterAddToSource: undefined | boolean;
          LineDash: undefined | boolean | number[];
          Polygon: GeoPolygon;
          ReturnType: undefined | "SELF";
          StrokeColor: undefined | string | CanvasPattern | CanvasGradient;
          StrokeWidth: undefined | number;
          TextStyle: undefined | CTextStyle;
          Tooltip: undefined | string;
      }

      圖素設定參數。

      • FillColor: undefined | string | CanvasPattern | CanvasGradient

        面顏色。

      • LaterAddToSource: undefined | boolean

        是否稍後再加入。

      • LineDash: undefined | boolean | number[]

        虛線間隔或開啟虛線。

      • Polygon: GeoPolygon

        面幾何。

      • ReturnType: undefined | "SELF"

        回傳型態,"SELF"為ol.Feature。

      • StrokeColor: undefined | string | CanvasPattern | CanvasGradient

        邊線顏色。

      • StrokeWidth: undefined | number

        邊線寬。

      • TextStyle: undefined | CTextStyle

        文字樣式。

      • Tooltip: undefined | string

        提示文字。

    Returns any

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

    Example

    //可以設定參數有:Polygon, StrokeColor, StrokeWidth, FillColor, TextStyle,Tooltip, LaterAddToSource, LineDash, ReturnType。
    //如果有需要文字標籤,先建立文字樣式物件
    var text = new CTextStyle();
    text.Text = "jgoah-ih;fjaghaihf-kajsnvoahgihufkjakhgqaihf";
    text.ContentStyle = 'Shorten';
    text.Weight = 'bold';
    text.FillColor = 'yellow'
    text.Baseline = 'middle';
    text.StrokeColor = 'rgba(0,0,0,0.5)';
    text.StrokeWidth = 3;
    text.Rotation = 1.57;
    text.Size = 12;
    //新增面圖素
    this.VectorLayer.NewPolygonByParam({ 'Polygon': new GeoPolygon(buffer) , 'StrokeColor': '#FFFFFF', 'StrokeWidth': 5, 'FillColor': 'rgba(255,0,0,0.5)', 'TextStyle': text, 'LineDash' : [4,8]});
  • 新增多面圖素

    Parameters

    • PolygonSet: GeoPolygonSet

      多面圖素

    • StrokeColor: string

      外框顏色

    • StrokeWidth: number

      外框寬度

    • FillColor: string

      塗滿顏色

    • textStyle: any
    • Optional NullInside: boolean

      是否要空心,預設為true

    • Rest ...args: any

    Returns any

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

    Example

    var id = CVectorLayer.NewPolygonSet(new GeoPolygonSet(buffer), '#FFFFFF', 5, 'rgb(255,0,0)' );
    var id = CVectorLayer.NewPolygonSet(new GeoPolygonSet(buffer), '#FFFFFF', 5, 'rgb(255,0,0)', '' , true); 不顯示標籤
    var id = CVectorLayer.NewPolygonSet(new GeoPolygonSet(buffer), '#FFFFFF', 5, 'rgb(255,0,0)', text, true);顯示標籤
  • 新增多面圖素

    Parameters

    • Obj: {
          FillColor: undefined | string | CanvasPattern | CanvasGradient;
          LaterAddToSource: undefined | boolean;
          LineDash: undefined | boolean | number[];
          NullInside: undefined | boolean;
          PolygonSet: GeoPolygonSet;
          ReturnType: undefined | "SELF";
          StrokeColor: undefined | string | CanvasPattern | CanvasGradient;
          StrokeWidth: undefined | number;
          TextStyle: undefined | CTextStyle;
          Tooltip: undefined | string;
      }

      圖素設定參數。

      • FillColor: undefined | string | CanvasPattern | CanvasGradient

        面顏色。

      • LaterAddToSource: undefined | boolean

        是否稍後再加入。

      • LineDash: undefined | boolean | number[]

        虛線間隔或開啟虛線。

      • NullInside: undefined | boolean

        是否不畫面。

      • PolygonSet: GeoPolygonSet

        多面幾何。

      • ReturnType: undefined | "SELF"

        回傳型態,"SELF"為ol.Feature。

      • StrokeColor: undefined | string | CanvasPattern | CanvasGradient

        邊線顏色。

      • StrokeWidth: undefined | number

        邊線寬。

      • TextStyle: undefined | CTextStyle

        文字樣式。

      • Tooltip: undefined | string

        提示文字。

    • Rest ...args: any

    Returns any

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

    Example

    //可以設定參數有:PolygonSet, StrokeColor, StrokeWidth, FillColor, TextStyle, NullInside, Tooltip, LaterAddToSource, LineDash, ReturnType。
    //如果有需要文字標籤,先建立文字樣式物件
    var text = new CTextStyle();
    text.Text = "jgoah-ih;fjaghaihf-kajsnvoahgihufkjakhgqaihf";
    text.ContentStyle = 'Shorten';
    text.Weight = 'bold';
    text.FillColor = 'yellow'
    text.Baseline = 'middle';
    text.StrokeColor = 'rgba(0,0,0,0.5)';
    text.StrokeWidth = 3;
    text.Rotation = 1.57;
    text.Size = 12;
    //新增線圖素
    this.VectorLayer.NewPolygonSetByParam({ 'PolygonSet': pgs2 , 'StrokeColor': '#FF00FF', 'StrokeWidth': 5, 'FillColor': 'rgb(255,0,0)', 'TextStyle': text, 'NullInside': true, 'LineDash' : [4,8]});
  • 新增聚合線圖素

    Parameters

    • Polyline: Object | GeoPolyline

      線條

    • color: any
    • Width: number

      線條寬度

    • Optional textStyle: CTextStyle

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

    • Rest ...args: any

    Returns any

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

    Example

    var id = CVectorLayer.NewPolyline(new GeoPolyline(buffer), '#FFFFFF', 5 );
    var id = CVectorLayer.NewPolyline(new GeoPolyline(buffer), '#FFFFFF', 5, text);
  • 新增聚合線圖素

    Parameters

    • Obj: {
          LaterAddToSource: undefined | boolean;
          LineDash: undefined | boolean | number[];
          Polyline: GeoPolyline;
          ReturnType: undefined | "SELF";
          ShowArrow: undefined | boolean;
          StrokeColor: undefined | string | CanvasPattern | CanvasGradient;
          StrokeWidth: undefined | number;
          TextStyle: undefined | CTextStyle;
          Tooltip: undefined | string;
      }

      圖素設定參數

      • LaterAddToSource: undefined | boolean

        是否稍後再加入。

      • LineDash: undefined | boolean | number[]

        虛線間隔或開啟虛線。

      • Polyline: GeoPolyline

        聚合線幾何。

      • ReturnType: undefined | "SELF"

        回傳型態,"SELF"為ol.Feature。

      • ShowArrow: undefined | boolean

        是否顯示箭頭。

      • StrokeColor: undefined | string | CanvasPattern | CanvasGradient

        邊線顏色。

      • StrokeWidth: undefined | number

        邊線寬。

      • TextStyle: undefined | CTextStyle

        文字樣式。

      • Tooltip: undefined | string

        提示文字。

    Returns any

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

    Example

    //可以設定參數有:Polyline, StrokeColor, StrokeWidth, TextStyle, ShowArrow,Tooltip, LaterAddToSource, LineDash, ReturnType。
    //如果有需要文字標籤,先建立文字樣式物件
    var text = new CTextStyle();
    text.Text = "jgoah-ih;fjaghaihf-kajsnvoahgihufkjakhgqaihf";
    text.ContentStyle = 'Shorten';
    text.Weight = 'bold';
    text.FillColor = 'yellow'
    text.Baseline = 'middle';
    text.StrokeColor = 'rgba(0,0,0,0.5)';
    text.StrokeWidth = 3;
    text.Rotation = 1.57;
    text.Size = 12;
    //新增線圖素
    this.VectorLayer.NewPolylineByParam({ 'Polyline': new GeoPolyline(buffer), 'StrokeColor': 'black', 'StrokeWidth': 5, 'TextStyle': text, 'ShowArrow': true, 'LineDash' : [4,8] });
  • 新增文字圖素

    Parameters

    • p: any
    • textStyle: any
    • Optional bShowPoint: boolean

      是否要顯示圓點,預設false

    • Optional PointColor: string

      圓點顏色,不給預設紅色

    • Optional PointRadius: number

      圓點半徑,不給預設為1

    • Optional PointUnit: number

      半徑單位類型,UNIT.MAP:半徑以公尺為單位, UNIT.PIXEL:半徑以螢幕上的像素單位,不給預設為UNIT.PIXEL

    • Rest ...args: any

    Returns any

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

    Example

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

    Parameters

    • Obj: {
          LaterAddToSource: undefined | boolean;
          Point: GeoPoint;
          PointFillColor: undefined | string | CanvasPattern | CanvasGradient;
          PointRadius: undefined | number;
          PointRadiusUnit: undefined | number;
          ReturnType: undefined | "SELF";
          ShowPoint: undefined | boolean;
          TextStyle: CTextStyle;
          Tooltip: undefined | string;
      }

      圖素設定參數。

      • LaterAddToSource: undefined | boolean

        是否稍後再加入。

      • Point: GeoPoint

        幾何點。

      • PointFillColor: undefined | string | CanvasPattern | CanvasGradient

        圓點顏色。

      • PointRadius: undefined | number

        圓點半徑。

      • PointRadiusUnit: undefined | number

        圓點半徑單位類型。

      • ReturnType: undefined | "SELF"

        回傳型態,"SELF"為ol.Feature。

      • ShowPoint: undefined | boolean

        是否顯示圓點。

      • TextStyle: CTextStyle

        標籤樣式

      • Tooltip: undefined | string

        提示文字。

    Returns any

    傳回圖素ID

    Example

    //可以設定參數有:Point, ShowPoint, PointFillColor, PointRadius, PointRadiusUnit, TextStyle, Tooltip, LaterAddToSource,ReturnType。
    //先建立文字樣式物件
    var text = new CTextStyle();
    text.Text = "jgoah-ih;fjaghaihf-kajsnvoahgihufkjakhgqaihf";
    text.ContentStyle = 'Shorten';
    text.Weight = 'bold';
    text.FillColor = 'yellow'
    text.Baseline = 'middle';
    text.StrokeColor = 'rgba(0,0,0,0.5)';
    text.StrokeWidth = 3;
    text.Rotation = 1.57;
    text.Size = 12;
    //新增文字圖素
    this.VectorLayer.NewTextByParam({
    'Point': new GeoPoint(175000, 2542575.6165581764), 'TextStyle': text, 'ShowPoint': true, 'PointFillColor': '#00FF00', 'PointRadius': 100, 'PointRadiusUnit': UNIT.PIXEL,
    'Tooltip': "<table><tbody><tr><td colspan=\"2\">關渡觀測站</td></tr><tr><td>HOUR_3</td><td>0.00</td></tr><tr><td>HOUR_6</td><td>-999.00</td></tr><tr><td>HOUR_12</td><td>-999.00</td></tr><tr><td>HOUR_24</td><td>-999.00</td></tr><tr><td>MIN_10</td><td>0.00</td></tr><tr><td>NOW</td><td>0.00</td></tr></tbody></table><br>"
    });
  • 移除圖層上指定圖素

    Parameters

    • id: number

      指定圖素id

    Returns boolean

    若找不到指定圖素,return false

  • 移除圖層上所有圖素

    Returns void

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

    Parameters

    Returns number[]

    圖素Id陣列

  • 在圖層上搜尋範圍內的圖素Id

    Parameters

    Returns number[]

    圖素Id陣列

  • 在圖層上搜尋指定幾何範圍內的圖素Id

    Parameters

    Returns number[]

    圖素Id陣列

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

    Parameters

    • distance: number

      叢集合併最大距離

    Returns void

  • 設定是否顯示圖素

    Parameters

    • id: number

      指定圖素id

    • show: boolean

      是否顯示

    Returns boolean

    回傳更新是否成功

  • 設定tooltip

    Parameters

    • id: any
    • tooltip: any

    Returns void

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

    Returns string

    Json字串

  • 更新與指定圖素相關的參數 點圖素間的轉換,需要給完整資訊,可以參考NewPoint_Color和NewPoint_Symbol(symbol轉color需要指定SymbolUrl為空字串) 不要顯示文字的話Text給空字串或TextStyle.Text給空字串,如果有指定TextStyle,以TextStyle為主

    Parameters

    Returns boolean

    回傳更新是否成功

Generated using TypeDoc