new CVectorLayer(MapDocument, Obj)
向量圖層
不能直接呼叫CVectorLayer的建構函式,您應該從已經存在的CMapDocument物件,透過NewVectorLayer新增CVectorLayer
Name | Type | Description |
---|---|---|
MapDocument |
CMapDocument | undefined |
地圖文件。 |
Obj |
string | Object | undefined |
圖層設定。 |
Example
var vLayerId = myMapDoc.NewVectorLayer("test");
Extends
Members
-
Alpha
-
圖層透明度
Properties:
Name Type Description Alpha
number 透明度
-
readonlyBoundary
-
圖層範圍
Properties:
Name Type Description Boundary
GeoBoundary 圖層範圍
-
readonlyMaxResolution
-
圖層的最大解析度
Properties:
Name Type Description MaxResolution
number 最大解析度
-
readonlyMinResolution
-
圖層的最小解析度
Properties:
Name Type Description MinResolution
number 最小解析度
-
readonlyName
-
圖層名稱
Properties:
Name Type Description Name
number 名稱
-
Show
-
是否顯示圖層
Properties:
Name Type Description Show
boolean 是否顯示
-
readonlytype
-
圖層類別
Properties:
Name Type Description type
LAYER_TYPE_2D 類別
-
readonlyZIndex
-
圖層Z-Index
Properties:
Name Type Description Z-Index
number 圖層的繪製順序
Methods
-
GetAllEntity(){Array.<int>}
openlayers/MapDocument.js, line 2960 -
取得圖層上所有圖素的Id
Returns:
Type Description Array.<int> 圖素Id陣列 -
GetEntityGeo(id){GeoPoint|GeoPolyline|GeoPolygon}
openlayers/MapDocument.js, line 3074 -
取得指定圖素的幾何
Name Type Description id
number 指定圖素Id
Returns:
Type Description GeoPoint | GeoPolyline | GeoPolygon 圖素幾何,若id沒有找到指定的圖素則回傳為null -
GetEntityParam(id){object}
openlayers/MapDocument.js, line 2790 -
取得指定圖素的參數
Name Type Description id
number 指定圖素id
Returns:
Type Description object {key: value, key: value, ...} 傳回圖素設定的參數,Point Keys種類:Point Keys種類:Point(GeoPoint), FillColor(openlayers-colorlike), Radius(number), RadiusUnit(UNIT.PIXEL/UNIT.MAP), SymbolUrl(text), SymbolSize(CSize), SymbolScale(number), SymbolRotation(number), Tooltip(text), TextStyle(CTextStyle)。 Polyline Keys種類:Polyline(GeoPolyline), StrokeColor(openlayers-colorlike), StrokeWidth(number), ShowArrow(boolean), Tooltip, TextStyle。Polygon Keys種類:Polygon(GeoPolygon), StrokeColor, StrokeWidth, FillColor, Tooltip, TextStyle。PolygonSet Keys種類:PolygonSet(GeoPolygonSet), StrokeColor, StrokeWidth, FillColor, NullInside(boolean), Tooltip, TextStyle。Text Keys種類: Point, ShowPoint(boolean), PointRadius(number), PointRadiusUnit(UNIT.MAP/UNIT.PIXEL), Tooltip, TextStyle。 -
GetEntityType(id){ENTITY_TYPE}
openlayers/MapDocument.js, line 3060 -
取得指定圖素的類型
Name Type Description id
number 指定圖素Id
Returns:
Type Description ENTITY_TYPE 圖素類型,若id沒有找到指定的圖素則回傳為ENTITY_TYPE.NONE(=0) -
NewBatchFeatures(features)
openlayers/MapDocument.js, line 2034 -
批次加入圖素
Name Type Description features
Array.<ol.Feature> 圖素陣列
-
NewBatchPoint(Param, Callback, LaterAddToSource, ReturnType)
openlayers/MapDocument.js, line 1111 -
新增批量點圖素
Name Type Description Param
Array.<Object> 參數
Callback
callback 回呼函式,function(featureId)
LaterAddToSource
Boolean 是否之後手動加入圖素,true則不會將圖素加入圖層,預設為false
ReturnType
String 回呼函式傳入型態,"SELF"則傳入Feature物件,預設傳入Feature ID
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.NewPoint([{ 'Point': new GeoPoint(163887.80, 2600000), 'FillColor': 'argb(0,0,0,1)', 'Radius': 1000, 'RadiusUnit': UNIT.MAP, 'TextStyle': text },...], callback);
//新增符號
this.VectorLayer.NewPoint([{ 'Point': new GeoPoint(165000, 2650000), 'SymbolUrl': 'http://127.0.0.1:8080/台灣全圖_84TM2.jpg', 'SymbolSize': new CSize(48, 48), 'TextStyle': text },...], callback); -
NewPoint(Obj){number|ol.Feature}
openlayers/MapDocument.js, line 975 -
新增點,若要大量新增則請使用NewBatchPoint
Name Type Description Obj
Object 圖素設定參數
Returns:
Type Description number | ol.Feature 傳回圖素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。 -
NewPoint_Color(p, color, radius, unit, textStyle){number}
openlayers/MapDocument.js, line 850 -
Name Type Description p
GeoPoint 點中心位置
color
string 顏色
radius
number 圓半徑
unit
UNIT | undefined 圖素大小單位 UNIT.MAP:半徑以公尺為單位, UNIT.PIXEL:半徑以螢幕上的像素為單位,不給預設為UNIT.PIXEL
textStyle
CTextStyle | undefined 標籤樣式,沒指定就不顯示標籤
- Deprecated
- 新增點圖素(圓形顏色)
Returns:
Type Description number 傳回圖素ID 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); -
NewPoint_Symbol(p, SymbolUrl, size, textStyle){number}
openlayers/MapDocument.js, line 906 -
Name Type Description p
GeoPoint 點中心位置
SymbolUrl
string 符號圖片的連結
size
CSize | undefined 符號大小,沒給則用符號圖片本身的大小
textStyle
CTextStyle | undefined 標籤樣式,沒指定就不顯示標籤
- Deprecated
- 新增點-符號圖素
Returns:
Type Description number 傳回圖素ID 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'); -
NewPolygon(Polygon, StrokeColor, StrokeWidth, FillColor, textStyle){number|ol.Feature}
openlayers/MapDocument.js, line 1434 -
新增面圖素
Name Type Description Polygon
GeoPolygon | Object 圖素設定參數
StrokeColor
string 外框顏色
StrokeWidth
number 外框寬度
FillColor
string 塗滿顏色
textStyle
CTextStyle | undefined 標籤樣式,沒指定就不顯示標籤
Returns:
Type Description number | ol.Feature 傳回圖素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()); //使用預設的文字樣式 -
NewPolygonByParam(Obj){number|ol.Feature}
openlayers/MapDocument.js, line 1517 -
新增面圖素
Name Type Description Obj
Object 圖素設定參數
Returns:
Type Description number | ol.Feature 傳回圖素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]}); -
NewPolygonSet(PolygonSet, StrokeColor, StrokeWidth, FillColor, TextStyle, NullInside){number|ol.Feature}
openlayers/MapDocument.js, line 1582 -
新增多面圖素
Name Type Description PolygonSet
GeoPolygonSet 多面圖素
StrokeColor
string 外框顏色
StrokeWidth
number 外框寬度
FillColor
string 塗滿顏色
TextStyle
CTextStyle | undefined 標籤樣式,沒指定就不顯示標籤
NullInside
bool | undefined 是否要空心,預設為true
Returns:
Type Description number | ol.Feature 傳回圖素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);顯示標籤 -
NewPolygonSetByParam(Obj){number|ol.Feature}
openlayers/MapDocument.js, line 1706 -
新增多面圖素
Name Type Description Obj
Object 線條
Returns:
Type Description number | ol.Feature 傳回圖素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]}); -
NewPolyline(Polyline, Color, Width, textStyle){number|ol.Feature}
openlayers/MapDocument.js, line 1260 -
新增聚合線圖素
Name Type Description Polyline
GeoPolyline | Object 線條
Color
string 線條顏色
Width
number 線條寬度
textStyle
CTextStyle | undefined 標籤樣式,沒指定就不顯示標籤
Returns:
Type Description number | ol.Feature 傳回圖素ID(預設)或圖素本身 Example
var id = CVectorLayer.NewPolyline(new GeoPolyline(buffer), '#FFFFFF', 5 );
var id = CVectorLayer.NewPolyline(new GeoPolyline(buffer), '#FFFFFF', 5, text); -
NewPolylineByParam(Obj){number|ol.Feature}
openlayers/MapDocument.js, line 1343 -
新增聚合線圖素
Name Type Description Obj
Object 圖素設定參數
Returns:
Type Description number | ol.Feature 傳回圖素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] }); -
NewText(P, TextStyle, bShowPoint, PointColor, PointRadius, PointUnit){number|ol.Feature}
openlayers/MapDocument.js, line 1824 -
新增文字圖素
Name Type Description P
GeoPoint 文字坐標(世界)
TextStyle
CTextStyle 標籤樣式
bShowPoint
bool | undefined 是否要顯示圓點,預設false
PointColor
string | undefined 圓點顏色,不給預設紅色
PointRadius
number | undefined 圓點半徑,不給預設為1
PointUnit
UNIT | undefined 半徑單位類型,UNIT.MAP:半徑以公尺為單位, UNIT.PIXEL:半徑以螢幕上的像素單位,不給預設為UNIT.PIXEL
Returns:
Type Description number | ol.Feature 傳回圖素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) 顯示圓點 -
NewTextByParam(Obj){number}
openlayers/MapDocument.js, line 1947 -
新增文字圖素
Name Type Description Obj
Object 圖素設定參數
Returns:
Type Description number 傳回圖素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': "<td colspan="2">關渡觀測站 HOUR_3 0.00 HOUR_6 -999.00 HOUR_12 -999.00 HOUR_24 -999.00 MIN_10 0.00 NOW 0.00
"
}); -
Remove(id){boolean}
openlayers/MapDocument.js, line 2936 -
移除圖層上指定圖素
Name Type Description id
number 指定圖素id
Returns:
Type Description boolean 若找不到指定圖素,return false -
RemoveAll(){void}
openlayers/MapDocument.js, line 2951 -
移除圖層上所有圖素
Returns:
Type Description void -
SelectEntityAtPoint(Point){Array.<number>}
openlayers/MapDocument.js, line 3004 -
在圖層上搜尋固定範圍(螢幕上5px)內的圖素Id
Name Type Description Point
GeoPoint 輸入點(世界坐標)
Returns:
Type Description Array.<number> 圖素Id陣列 -
SelectEntityByDistance(Geo, Distance){Array.<number>}
openlayers/MapDocument.js, line 2975 -
在圖層上搜尋範圍內的圖素Id
Name Type Description Geo
GeoPoint | GeoPolyline | GeoPolygon | GeoPolygonSet | GeoBoundary 輸入幾何(世界坐標)
Distance
number 搜索半徑(單位:公尺)
Returns:
Type Description Array.<number> 圖素Id陣列 -
SelectEntityByInclude(Geo){Array.<number>}
openlayers/MapDocument.js, line 3034 -
在圖層上搜尋指定幾何範圍內的圖素Id
Name Type Description Geo
GeoPoint | GeoPolyline | GeoPolygon | GeoPolygonSet | GeoBoundary 輸入幾何(世界坐標)
Returns:
Type Description Array.<number> 圖素Id陣列 -
SetClusterDistance(distance){void}
openlayers/MapDocument.js, line 3296 -
設定叢集合併的最大距離
Name Type Description distance
number 叢集合併最大距離
Returns:
Type Description void -
SetEntityShow(id, show){bool}
openlayers/MapDocument.js, line 2097 -
設定是否顯示圖素
Name Type Description id
Number 指定圖素id
show
Boolean 是否顯示
Returns:
Type Description bool 回傳更新是否成功 -
SetTooltip(){void}
openlayers/MapDocument.js, line 3286 -
設定tooltip
Returns:
Type Description void -
ToAllEntityArrayJson(){string}
openlayers/MapDocument.js, line 3087 -
把所有圖素轉成Json陣列字串
Returns:
Type Description string Json字串 -
UpdateEntity(id, Obj){bool}
openlayers/MapDocument.js, line 2059 -
更新與指定圖素相關的參數
點圖素間的轉換,需要給完整資訊,可以參考NewPoint_Color和NewPoint_Symbol(symbol轉color需要指定SymbolUrl為空字串)
不要顯示文字的話Text給空字串或TextStyle.Text給空字串,如果有指定TextStyle,以TextStyle為主Name Type Description id
number 指定圖素id
Obj
object {key: value, key: value, ...} 需要變更的參數: Point Keys種類:Point(GeoPoint), FillColor(openlayers-colorlike), Radius(number), RadiusUnit(UNIT.PIXEL/UNIT.MAP), SymbolUrl(text), SymbolSize(CSize), SymbolScale(number), Tooltip(text), TextStyle(CTextStyle)。 Polyline Keys種類:Polyline(GeoPolyline), StrokeColor(openlayers-colorlike), StrokeWidth(number), ShowArrow(boolean), Tooltip, TextStyle。Polygon Keys種類:Polygon(GeoPolygon), StrokeColor, StrokeWidth, FillColor, Tooltip, TextStyle。PolygonSet Keys種類:PolygonSet(GeoPolygonSet), StrokeColor, StrokeWidth, FillColor, NullInside(boolean), Tooltip, TextStyle。Text Keys種類: Point, ShowPoint(boolean), PointRadius(number), PointRadiusUnit(UNIT.MAP/UNIT.PIXEL), Tooltip, TextStyle。
Returns:
Type Description bool 回傳更新是否成功