Class: CMapView

CMapView

new CMapView(ElementId, EPSGNum)

openlayers/MapDocument.js, line 5000

地圖可視元件

Name Type Description
ElementId DOM

網頁元素ID

EPSGNum number

預設坐標系統編碼

Members

readonlyBoundary

地圖的作畫範圍

Properties:
Name Type Description
Boundary GeoBoundary

地圖的作畫範圍

EnableRange

是否允許限制範圍

Properties:
Name Type Description
EnableRange boolean

是否不可移動到整個Viewport的範圍(ViewportRange)之外

readonlyHeight

作畫的div元素高度

Properties:
Name Type Description
Height number

作畫的div元素高度

HoverFeatureOn

移到圖素事件開關
若為true則開啟移到圖素功能,否則關閉

Properties:
Name Type Description
HoverFeatureOn boolean

是否開啟可移到圖素模式

readonlyIsBind

是否已綁定

Properties:
Name Type Description
ret boolean

回傳值

MeasureProperty

測量功能相關參數設定
設定參數方式:={Key:value, key:value, ...},不需要全部給,只要給有需要調整的參數即可,其餘的會使用預設值或是上次修改的值。

Properties:
Name Type Description
MeasureProperty object

測量功能參數。

Properties
Name Type Description
DeltaPixel number

多少距離內雙擊滑鼠時代表結束測量,單位像素,預設值5

LineWidth number

作畫寬度,單位像素,預設值2

DrawColor_In string

測量時的顏色,預設值"#FF000000"

DrawColor_Out string

測量結束後的顏色,預設值"#FFFFCC33"

FillColor string

填充顏色,預設值"#80FFFFFF"

LengthUnit_1 string

測量長度時,第一級的單位文字,預設值"公尺",注意:核心的基本單位為公尺,即使您指定顯示"公里",核心並不會自動幫您換算數值

AreaUnit_1 string

測量面積時,第一級的單位文字,預設值"平方公尺",注意:核心的基本單位為公尺,即使您指定顯示"平方公里",核心並不會自動幫您換算數值

LengthUnit_2 string

測量長度時,第二級的單位文字,預設值"公里",注意:核心的基本單位為公尺,核心會自動配合measure_property.LengthScale屬性換算第二級的數值,如LengthScale為0.001表示測量的長度達1000公尺時,測量結果會自動換算成當前的千分之一,顯示文字會自動切換成公里

AreaUnit_2 string

測量長度時,第二級的單位文字,預設值"公頃",注意:核心的基本單位為公尺,核心會自動配合measure_property.AreaScale屬性換算第二級的數值,如AreaScale為0.001表示測量的面積達1000平方公尺時,測量結果會自動換算成當前的千分之一,顯示文字會自動切換成公頃

FontFamily string

標示文字字型,預設值"Arial",

FontSize number

標示文字大小,單位像素,預設值15,

FontColor_In string

測量時的標示文字顏色,預設值"#FFFFFFFF"

FontColor_Out string

測量結束後的文字邊框顏色,預設值"#FF000000"

DecimalPrecision number

測量結果顯示到小數以下第幾位,預設值2

TextBGColor_In string

測量時的標示文字邊框顏色,預設值"#80000000"

TextBGColor_Out string

測量結束後的邊是文字邊框顏色,預設值"#80FFCC33"

BeginLengthTips string

開始測量長度的提示文字,預設值"Click to input the starting point of the polyline"

BeginAreaTips string

開始測量面積的提示文字,預設值"Click to input the starting point of the polygon"

EndLengthTips string

結束測量長度的提示文字,預設值"Click to input the point(Double click to end)"

EndAreaTips string

結束測量面積的提示文字,預設值"Click to input the point(Double click to end)"

ShowAreaDetail boolean

測量面積時是否顯示詳細資訊,若為true則每線段 兩點)之間會顯示線段長度,並且結束後會顯示周長,預設值true

ShowLengthDetail boolean

測量長度時是否顯示詳細資訊,若為true則每線段 兩點)之間會顯示線段長度,預設值true

TotalLengthText string

測量長度的總長度標示文字抬頭,預設值為 總長:"

TotalAreaText string

測量面積的總面積標示文字抬頭,預設值為 總面積:"

TotalPerimeterText string

測量面積的總周長標示文字抬頭,預設值為"總周長:"

LengthScale number

測量長度時第一級單位與第二級單位的比例,預設0 001,即第一級為公尺,第二級為公里

AreaScale number

測量長度時第一級單位與第二級單位的比例,預設0 0001,即第一級為平方公尺,第二級為公頃

EPSG number

測量採用的座標基準,預設0表示與圖台相同

MouseWheelZoomCenter

滾輪縮放是否使用中心點(預設false即以滑鼠位置縮放圖台)

Properties:
Name Type Description
get boolean

取得滾輪縮放是否使用中心點

set boolean

設定滾輪縮放是否使用中心點

ScaleLineOn

比例尺開關
若為true則開啟比例尺圖示,否則關閉,比例尺class name為ol-scale-line

Properties:
Name Type Description
ScaleLineOn boolean

是否開啟比例尺圖式

SelectFeatureOn

選取圖素事件開關
若為true則開啟選取圖素功能,否則關閉

Properties:
Name Type Description
SelectFeatureOn boolean | object

是否開啟可選圖素模式,可填入boolean或object。

Properties
Name Type Description
Open boolean

是否開啟可選圖素模式。

ShiftKeyMulti boolean

開關shift多選模式。

Highlight boolean

開關高亮模式。

Viewport

視埠

Properties:
Name Type Description
get GeoBoundary

取得目前視埠

set GeoBoundary

設定目前視埠

readonlyWidth

作畫的div元素寬度

Properties:
Name Type Description
Width number

作畫的div元素寬度

ZoomByMatrixSet

地圖依照預設或指定的矩陣資訊縮放
若為true,呼叫ZoomIn/ZoomOut的時候會依照指定的矩陣資訊縮放比例尺,否則依照下一級為原來比例尺的0.65倍縮放

Properties:
Name Type Description
ZoomByMatrixSet boolean

是否依照預設的矩陣資訊縮放

Methods

AbortInput()

openlayers/MapDocument.js, line 8231

放棄當前輸入幾何的動作

AddEventListener(EventName, callback){boolean}

openlayers/MapDocument.js, line 6683

加入監聽事件

Name Type Description
EventName string

事件名稱,目前支援ViewportChanged(GeoBoundary Viewport,GeoBoundary Window)、ModifyEnd(VectorLayer Layer, number EntityId)、OnServerNotify(VarStruct[] Ret)、GetTileProgress(Obj)、Resized(Obj)、UpdateScreen()、MoveEnd(GeoBoundary Viewport)、ControlTypeChange(string value)、SelectFeature(Obj)、HoverFeature(Obj)

callback callback

當事件觸發要呼叫的函式

Returns:
Type Description
boolean 事件名稱是否存在。

BeginTooltip()

openlayers/MapDocument.js, line 9503

啟動提示功能

Bind(MapDocument, InitBoundary){boolean}

openlayers/MapDocument.js, line 6430

綁定MapDocument

Name Type Description
MapDocument CMapDocument

要綁定的地圖文件

InitBoundary GeoBoundary

初始化視域,綁定後畫面會自動移動到該範圍,並限制圖台移動範圍

Returns:
Type Description
boolean 是否綁定成功

BounceTo(Coordinate)

openlayers/MapDocument.js, line 8831

彈跳到指定位置(類似彈力球)

Name Type Description
Coordinate Array.<number> | GeoPoint

[x,y]或GeoPoint,必須。

Example

BounceTo([0, 0])
BounceTo(new GeoPoint(0,0));

ClearMarkFeatureInfo()

openlayers/MapDocument.js, line 9496

手動清除所有查詢標記

ClearMeasure()

openlayers/MapDocument.js, line 8496

清除測量標記

CreateOverlay(Coordinate, Id, ElementTagName, Callback){ol.Overlay}

openlayers/MapDocument.js, line 9529

在地圖上建立Overlay元件

Name Type Description
Coordinate Array.<number> | GeoPoint

[x,y]或GeoPoint,必須。

Id number | string | undefined

Overlay元件Identifier

ElementTagName string

Overlay Dom元件的標籤名稱

Callback CMapView.CreateOverlayCallback

回呼函式,function(element)

Returns:
Type Description
ol.Overlay openlayers overlay 元件
Example

var overlay = CreateOverlay([13465046.15542, 2709138.0502025], 'overlay', 'div', function (element) {
var content = document.createElement('div');
element.appendChild(content);
content.innerHTML = "testContent";
element.className = 'ol-popup';
});

CreateScaleLine(DivID)

openlayers/MapDocument.js, line 9027

在指定外部的div上加入比例尺,比例尺class name為'ol-scale-line'

Name Type Description
DivID string

外部Div的ID

Example

CreateScaleLine('map')

ElasticTo(Coordinate)

openlayers/MapDocument.js, line 8801

彈到指定位置(類似彈簧的方式)

Name Type Description
Coordinate Array.<number> | GeoPoint

[x,y]或GeoPoint,必須。

Example

ElasticTo([0, 0])
ElasticTo(new GeoPoint(0,0));

EndMeasure()

openlayers/MapDocument.js, line 8552

結束一次的測量動作

EndTooltip()

openlayers/MapDocument.js, line 9510

關閉提示功能

ExportMap(options)

openlayers/MapDocument.js, line 9583

取得當前圖台截圖

Name Type Description
options object

參數物件。

Name Type Default Description
FileName string "map.png" optional

檔案名稱。

FileType string "image/png" optional

檔案類型。

FileCompressedQuality number 1.0 optional

JPEG下的壓縮率。

Example

MapView.ExportMap({FileName: 'map.png', FileType:'image/png'});

FlyTo(Coordinate)

openlayers/MapDocument.js, line 8913

飛到到指定位置

Name Type Description
Coordinate Array.<number> | GeoPoint

[x,y]或GeoPoint,必須。

Example

FlyTo([0, 0])
FlyTo(new GeoPoint(0,0));

GetCanvasOverMap(Id){Object}

openlayers/MapDocument.js, line 9170

取得一個剛好覆蓋整個Map的畫布(canvas)

Name Type Description
Id string

canvas的id

Returns:
Type Description
Object canvas HTML元素

GetOverlayById(OverlayId){ol.Overlay}

openlayers/MapDocument.js, line 9570

透過Id取得地圖上的Overlay元件

Name Type Description
OverlayId number | string | undefined

overlay元件Id

Returns:
Type Description
ol.Overlay openlayers overlay 元件

GoTo(Array)

openlayers/MapDocument.js, line 8948

飛到到指定範圍

Name Type Description
Array Array.<number> | GeoBoundary

[west,south,east,north]或GeoBoundary,必須。

Example

GoTo([0, 0, 1, 1])
GoTo(new GeoBoundary(0,0,1,1));

InputCircle(Input_Ok, Input_Abort, Sender, InputObj)

openlayers/MapDocument.js, line 8196

在地圖上輸入圓,點擊左鍵一下開始,移動滑鼠決定半徑,再左鍵一下結束輸入,點擊右鍵一下放棄輸入
備註:
1.Input_Ok收到的第一個參數為GeoPoint物件,物件當中包含一個Radius屬性為半徑長度
2.InputGeo系列不會自動為您畫輸入的幾何,也不會自動搜尋,所有功能須透過Input_Ok拿到的幾何實現

Name Type Description
Input_Ok function

結束輸入時的回呼函數,function(geo , Sender)

Input_Abort function

放棄輸入時的回呼函數,function(Sender)

Sender object

任意物件,會取代回呼函數作用範圍的this

InputObj object

任意物件,會傳遞到結束或放棄輸入的函數裡面

Example

var function inputGeo_Ok = function(geo , sender){
......
else if(sender === "circle"){
alert("輸入圓成功");
}
};
var function inputGeo_Abort = function(sender){
......
else if(sender === "circle"){
alert("放棄輸入圓");
}
};
var memo = "circle";
MapView.InputCircle(inputGeo_Ok , inputGeo_Abort, this, memo);

InputPoint(Input_Ok, Input_Abort, Sender, InputObj)

openlayers/MapDocument.js, line 7994

在地圖上輸入點,點擊左鍵一下就結束輸入,點擊右鍵一下放棄輸入
備註:
1.Input_Ok收到的第一個參數為GeoPoint物件
2.InputGeo系列不會自動為您畫輸入的幾何,也不會自動搜尋,所有功能須透過Input_Ok拿到的幾何實現

Name Type Description
Input_Ok function

結束輸入時的回呼函數,function(geo , Sender)

Input_Abort function

放棄輸入時的回呼函數,function(Sender)

Sender object

任意物件,會取代回呼函數作用範圍的this

InputObj object

任意物件,會傳遞到結束或放棄輸入的函數裡面

Example

var function inputGeo_Ok = function(geo , sender){
if(sender === "point"){
alert("輸入點成功");
}
......
};
var function inputGeo_Abort = function(sender){
if(sender === "point"){
alert("放棄輸入點");
}
......
};
var memo = "point";
MapView.InputPoint(inputGeo_Ok , inputGeo_Abort, this, memo);

InputPolygon(Input_Ok, Input_Abort, Sender, InputObj)

openlayers/MapDocument.js, line 8088

在地圖上輸入面,點擊左鍵一下加入點,點擊左鍵兩下結束輸入,點擊右鍵一下放棄輸入
備註:
1.注意每次InputPolygon的callback收到幾何的是GeoPolygon不是GeoPolygonSet
2.InputGeo系列不會自動為您畫輸入的幾何,也不會自動搜尋,所有功能須透過Input_Ok拿到的幾何實現

Name Type Description
Input_Ok function

結束輸入時的回呼函數,function(geo , Sender)

Input_Abort function

放棄輸入時的回呼函數,function(Sender)

Sender object

任意物件,會取代回呼函數作用範圍的this

InputObj object

任意物件,會傳遞到結束或放棄輸入的函數裡面

Example

var function inputGeo_Ok = function(geo , sender){
......
else if(sender === "polylgon"){
alert("輸入面成功");
}
......
};
var function inputGeo_Abort = function(sender){
......
else if(sender === "polygon"){
alert("放棄輸入面");
}
......
};
var memo = "polygon";
MapView.InputPolygon(inputGeo_Ok , inputGeo_Abort, this, memo);

InputPolyline(Input_Ok, Input_Abort, Sender, InputObj)

openlayers/MapDocument.js, line 8036

在地圖上輸入線,點擊左鍵一下加入點,點擊左鍵兩下結束輸入,點擊右鍵一下放棄輸入
備註:
1.Input_Ok收到的第一個參數為GeoPolyline物件
2.InputGeo系列不會自動為您畫輸入的幾何,也不會自動搜尋,所有功能須透過Input_Ok拿到的幾何實現

Name Type Description
Input_Ok function

結束輸入時的回呼函數,function(geo , Sender)

Input_Abort function

放棄輸入時的回呼函數,function(Sender)

Sender object

任意物件,會取代回呼函數作用範圍的this

InputObj object

任意物件,會傳遞到結束或放棄輸入的函數裡面

Example

var function inputGeo_Ok = function(geo , sender){
......
else if(sender === "polyline"){
alert("輸入線成功");
}
......
};
var function inputGeo_Abort = function(sender){
......
else if(sender === "polyline"){
alert("放棄輸入線");
}
......
};
var memo = "polyline";
MapView.InputPolyline(inputGeo_Ok , inputGeo_Abort, this, memo);

InputRectangle(Input_Ok, Input_Abort, Sender, InputObj)

openlayers/MapDocument.js, line 8142

在地圖上輸入框,點擊左鍵一下開始,移動滑鼠改變形狀,再左鍵一下結束輸入,點擊右鍵一下放棄輸入
備註:
1.Input_Ok收到的第一個參數為GeoBoundary物件
2.InputGeo系列不會自動為您畫輸入的幾何,也不會自動搜尋,所有功能須透過Input_Ok拿到的幾何實現

Name Type Description
Input_Ok function

結束輸入時的回呼函數,function(geo , Sender)

Input_Abort function

放棄輸入時的回呼函數,function(Sender)

Sender object

任意物件,會取代回呼函數作用範圍的this

InputObj object

任意物件,會傳遞到結束或放棄輸入的函數裡面

Example

var function inputGeo_Ok = function(geo , sender){
......
else if(sender === "boundary"){
alert("輸入框成功");
}
};
var function inputGeo_Abort = function(sender){
......
else if(sender === "boundary"){
alert("放棄輸入框");
}
};
var memo = "boundary";
MapView.InputRectangle(inputGeo_Ok , inputGeo_Abort, this, memo);

MeasureArea(Listen, Obj, DeltaPixel, bMeasureLength){boolean}

openlayers/MapDocument.js, line 8435

量測面積

Name Type Description
Listen function

結束時的回呼函數,function(Geo, MeasureValue, Obj),只需要標記功能可以給null

Obj Object

任意物件,給Listen辨識或傳遞物件用

DeltaPixel number

兩次點擊相離多少像素內即結束,可以不給,預設值為5

bMeasureLength boolean | undefined

開啟鎖點時,測量面積只有兩點當作測距離,預設true

Returns:
Type Description
boolean 回傳啟動測量是否成功

MeasureLength(Listen, Obj, DeltaPixel){boolean}

openlayers/MapDocument.js, line 8377

量測距離

Name Type Description
Listen function

結束時的回呼函數,function(Geo, MeasureValue, Obj),只需要標記功能可以給null

Obj Object

任意物件,給Listen辨識或傳遞物件用

DeltaPixel number

兩次點擊相離多少像素內即結束,可以不給,預設值為5

Returns:
Type Description
boolean 回傳啟動測量是否成功

PanTo(Coordinate)

openlayers/MapDocument.js, line 8773

平移到指定位置

Name Type Description
Coordinate Array.<number> | GeoPoint

[x,y]或GeoPoint,必須。

Example

PanTo([0, 0])
PanTo(new GeoPoint(0,0));

QueryFeatureInfoWithMark(LayerNames, StrokeColor, FillColor, Type, Callback, ProxyUrl)

openlayers/MapDocument.js, line 9209

查詢圖層屬性

Name Type Description
LayerNames string

圖層名稱,多個用逗號隔開

StrokeColor string

線框顏色

FillColor string

填滿顏色

Type QUERY_TYPE

查詢類型,目前支援: CLICK 點擊拿最上層的唯一圖素,INCLUDE 框選所有圖素

Callback function | undefined

回呼函式,function(QueryFeatures)

ProxyUrl string | undefined

代理網址,預設''

RemoveElement(Id)

openlayers/MapDocument.js, line 9196

移除指定的元素

Name Type Description
Id string

元素Id

RemoveEventListener(EventName, callback){boolean}

openlayers/MapDocument.js, line 6728

移除指定的監聽事件

Name Type Description
EventName string

事件名稱

callback callback

要移除(當事件觸發要呼叫)的函式

Returns:
Type Description
boolean 事件名稱是否存在並且已移除。

RemoveOverlay(Overlay)

openlayers/MapDocument.js, line 9561

從地圖上移除Overlay元件

Name Type Description
Overlay ol.Overlay

overlay元件

RestorePreviousSnapPointSetting()

openlayers/MapDocument.js, line 9092

回復上一個鎖點設定,若沒有上一個則恢復預設值

SetGetTileProgress(Interval_ms)

openlayers/MapDocument.js, line 9153

設定取圖進度相關參數

Name Type Description
Interval_ms number | undefined

時間間隔(毫秒)

SetMinMaxScaleDenominator(a_MinScaleDenominator, a_MaxScaleDenominator){boolean}

openlayers/MapDocument.js, line 8358

設定影響ZoomIn、ZoomOut、滾輪的最小和最大比例尺分母

Name Type Description
a_MinScaleDenominator number

最小比例尺分母,須大於等於0,限制縮放無法小於最小比例尺,0代表不限制

a_MaxScaleDenominator number

最大比例尺分母,須大於等於0,限制縮放無法大於最大比例尺,0代表不限制

Returns:
Type Description
boolean 是否設定成功 最小或最大比例尺小於0,或數值的大小關係不符邏輯都會回傳false

SetOnServerNotify(ServerURLs, Interval_ms)

openlayers/MapDocument.js, line 9120

設定監聽伺服器功能

Name Type Description
ServerURLs string | Array.<string>

指定server端的IP:PORT

Interval_ms number | undefined

時間間隔(毫秒)

SetSnapPointSetting(LayerName, Pixel, Type, Radius, FillColor, StrokeColor, ProxyUrl)

openlayers/MapDocument.js, line 9063

設定鎖點功能

Name Type Description
LayerName string | null

從指定的client端圖層名稱取鎖點,多圖層名用逗號分隔,若有值則啟動鎖點功能,null則關閉功能(其他參數無作用),預設關閉

Pixel number | undefined

搜尋鎖點範圍,單位pixel,預設5

Type string | undefined

指定鎖點類型,支援'node'-取最近的幾何(點)作為鎖點、'perpendicular_foot'-取最近的垂足作為鎖點,預設:'node'

Radius number | undefined

鎖點半徑大小,單位pixel,預設3

FillColor string | undefined

鎖點填滿顏色,預設紅色

StrokeColor string | undefined

鎖點外框顏色,預設黑色

ProxyUrl string | undefined

代理網址,預設''

Example

SetSnapPointSetting('wmts', 10, 'node', 3, 'rgba(255,0,0,1)', 'rgba(0,0,0,1)') 自動開啟
SetSnapPointSetting(null) 關閉鎖點功能

SpinTo(Coordinate)

openlayers/MapDocument.js, line 8878

旋轉到指定位置

Name Type Description
Coordinate Array.<number> | GeoPoint

[x,y]或GeoPoint,必須。

Example

SpinTo([0, 0])
SpinTo(new GeoPoint(0,0));

SpiralTo(Coordinate)

openlayers/MapDocument.js, line 8988

以螺旋方式到指定位置

Name Type Description
Coordinate Array.<number> | GeoPoint

[x,y]或GeoPoint,必須。

Example

SpiralTo([0, 0])
SpiralTo(new GeoPoint(0,0));

StoreCurrentSnapPointSetting()

openlayers/MapDocument.js, line 9077

紀錄當前的鎖點設定

Unbind()

openlayers/MapDocument.js, line 6595

解除與MapDocument的綁定

UpdateScreen()

openlayers/MapDocument.js, line 6633

強制更新畫面,如果作畫範圍(div)有改變,也會重新計算視域

ViewportToWindow(Obj){undefined|double}

openlayers/MapDocument.js, line 7277

將Viewport座標轉至Window座標,若為GeoPoint與GeoBoundary,則直接轉換傳入的參數,若是double,則將轉換後的答案傳回

Name Type Description
Obj GeoPoint | GeoBoundary | double

欲轉換的座標。

Returns:
Type Description
undefined | double 若參數為double,則傳回轉換後的答案。

WindowToViewport(Obj){undefined|double}

openlayers/MapDocument.js, line 7268

將Window座標轉至Viewport座標,若為GeoPoint與GeoBoundary,則直接轉換傳入的參數,若是double,則將轉換後的答案傳回

Name Type Description
Obj GeoPoint | GeoBoundary | double

欲轉換的座標。

Returns:
Type Description
undefined | double 若參數為double,則傳回轉換後的答案。

ZoomAll()

openlayers/MapDocument.js, line 7238

地圖移動到最大可視範圍

ZoomCenter(p)

openlayers/MapDocument.js, line 7227

平移到指定的中心點

Name Type Description
p GeoPoint

指定的中心點

Example

var p = new GeoPoint(121,22);
MapView.ZoomCenter(p);

ZoomIn()

openlayers/MapDocument.js, line 7092

地圖比例尺放大一級

ZoomOut()

openlayers/MapDocument.js, line 7147

地圖比例尺縮小一級

ZoomPreview()

openlayers/MapDocument.js, line 7254

地圖移動到前一畫面

ZoomScale(ScaleDenominator)

openlayers/MapDocument.js, line 7205

縮放到指定的比例尺(分母)下

Name Type Description
ScaleDenominator number

比例尺(分母)

Example

MapView.ZoomScale(25000);//縮放到兩萬五千分之一的比例尺

ZoomWindow()

openlayers/MapDocument.js, line 7071

框選並移動視域到該範圍,呼叫後會自動進入輸入框模式

Type Definitions

CMapView.CreateOverlayCallback(element)

openlayers/MapDocument.js, line 9550
Name Type Description
element HTMLElement
See: