<< Click to Display Table of Contents >>

SuperGIS Server JavaScript API

 

new sg.layers.FeatureLayer()

 

 

Description

新增一個feature layer來展示SuperGIS Server發佈的圖徵服務

 

Position

FeatureLayer.js

 

 

Parameters

 

Parameter

Type

Description

SuperGIS

String

Server服務網址

options

Object

設定物件

Name

Type

Description

name

String

圖層名稱

mode

String

FeatureLayer的模式

 

Constants

 

Constants

Description

MODE_ONDEMAND

當FeatureLayer為ONDEMAND模式時,每次地圖範圍改變,如進行平移動作時,重新抓取範圍內的圖徵。

MODE_SELECTION

當FeatureLayer為SELECTION模式時,只有被選取的Feature才會從Server抓取下來。

MODE_SNAPSHOT

當FeatureLayer為SNAPSHOT模式時,會將FeatureService中所有的圖徵全部抓取下來。

SELECTION_ADD

加入到現有的集合。

SELECTION_NEW

建立新的集合。

SELECTION_SUBTRACT

從集合中移除。

 

Properties

 

Properties

Type

Description

extent

sg.geometry.Extent

圖層範圍

graphics

Array.<sg.Graphic>

Graphic的陣列

infoTemplate

sg.InfoTemplate

Graphic顯示在訊息視窗的訊息樣板

loadError

Error

如果圖層載入失敗,此欄位有值

map

MapBase

圖層被加入的MapBase

maxScale

Number

可顯示的最大比例尺

minScale

Number

可顯示的最小比例尺

mode

String

FeatureLayer的模式

mouseEventEnabled

Error

是否啟用滑鼠事件

name

String

圖層名稱

fields

String

屬性欄位

ex: pointLayer.fields[5]

node

DOMNODE

圖層html節點

opacity

Number

透明度

renderer

sg.renderers.Render

圖層的Renderer

surface

Object

圖層的繪圖表面

svgContainer

DOMNODE

圖層的div

title

String

圖層標題

visible

Boolean

圖層是否可見

True: 可見
False: 不可見

 

 

Methods

 

Methods

Type

Description

add(graphic)

sg.Graphic

加入Graphic到GraphicsLayer

Name

Type

Description

graphic

sg.Graphic

Graphic

clear()


清除所有Graphic

clearSelection()


Clear selection

disableMouseEvents()


停用圖層中的所有滑鼠事件

enableMouseEvents()


啟用圖層中的所有滑鼠事件

getMap()

Returns:

MapBase

取得圖層所屬的地圖控制項。

Returns:

Type

Description

MapBase

圖層所屬的地圖控制項。

getName()

Returns:

String

取得圖層名稱

Returns:

Type

Description

String

圖層名稱

getNode()

Returns:

DOMNODE

取得圖層html節點

Returns:

Type

Description

DOMNODE

圖層html節點

getResource(index)

index:Number

Returns:String

取得symbol icon

Name

Type

Description

index

Number


Returns:

Type

Description

String

圖層html節點

getTitle()

Returns:

String

取得圖層標題

Returns:

Type

Description

String

圖層標題

getVisible()

Returns:

Boolean

取得圖層可見度

Returns:

Type

Description

Boolean

圖層可見度

True: 可見
False: 不可見

hide()


隱藏圖層

Initialize()


圖層被加入MapBase時所呼叫的初始化方法

isVisibleAtScale(scale)

scale:number

Returns:Boolean

計算圖層在指定比例尺下是否可見

Name

Type

Description

graphic

sg.Graphic

Graphic

Returns:

Type

Description

Boolean

圖層是否可見

True: 可見
False: 不可見

putName(newVal)

String

設定圖層名稱

Name

Type

Description

newVal

String

圖層名稱

putTitle(newVal)

String

設定圖層名稱

Name

Type

Description

newVal

String

圖層名稱

putVisible(newVal)

Boolean

設定圖層可見度

Name

Type

Description

newVal

Boolean

圖層可見度

True: 可見
False: 不可見

queryRelatedFeatures(index, query, callback, errBack)

index:Number

query:sg.tasks.RelationshipQuery

callback:sg.tasks.QueryTask~queryCallback
errCallback:function

Get features related to this layer

Name

Type

Description

query

Number

Symbol index

query

sg.tasks.RelationshipQuery

Relationship query

callback

sg.tasks.QueryTask~queryCallback

執行成功時觸發的方法

errCallback

sg.tasks.QueryTask~errorCallback

執行失敗時觸發的方法

RebuildElement()


重繪圖層

redraw()


重繪圖層

remove(graphic)

sg.Graphic

移除指定Graphic

Name

Type

Description

graphic

sg.Graphic

要被移除的Graphic

RemoveSelf()


移除圖層

selectFeatures(query, method, callback, errCallback)

query:sg.tasks.Query

method:        String

callback:        sg.layers.FeatureLayer~successCallback
errCallback:function

Select features

Name

Type

Description

query

sg.tasks.Query        

Query

method

String

Selection 方法模式.參考 constant 中 SELECTION 模式

callback

sg.layers.FeatureLayer~successCallback

執行成功時觸發的方法

errCallback

function

執行失敗時觸發的方法

setInfoTemplate(temp)

sg.InfoTemplate        

設定訊息樣版

Name

Type

Description

temp

sg.InfoTemplate        

訊息樣版

setMaxScale(maxScale)

Number

設定圖層可見的最大比例尺

Name

Type

Description

maxScale

Number

最大比例尺

setMinScale(minScale)

Number

設定圖層可見的最小比例尺

Name

Type

Description

minScale

Number

最小比例尺

setOpacity(opacity)

Number

設定圖層透明度

Name

Type

Description

opacity

Number

圖層透明度

0: 透明
1: 不透明

setRenderer(renderer)

sg.renderers.Renderer

設定圖層Renderer

Name

Type

Description

renderer

sg.renderers.Renderer        

圖層Renderer

setVisibility(newVal)

Boolean

設定圖層可見度

Name

Type

Description

newVal

Boolean

圖層可見度

True: 可見
False: 不可見

show()


顯示圖層

UpdateElement()


更新圖層

 

Type Definitions

 

Type Definition

Type

Description

successCallback(results)

Object

執行成功時所觸發的方法

 

 

Events

 

Event

Description

click

當滑鼠點擊Graphic時引發

dbl-click

當滑鼠雙擊Graphic時引發

graphic-add

當Graphic被加入時引發

graphic-clear

當所有Graphic被清除時引發

graphic-remove

當Graphic被移除時引發

load

當圖層讀取完成時引發

mouse-down

當滑鼠在Graphic上按下時引發

mouse-move

當滑鼠在Graphic上移動時引發

mouse-out

當滑鼠離開Graphic時引發

mouse-over

當滑鼠移入Graphic時引發

mouse-up

當滑鼠在Graphic上放開時引發

update-start

當更新開始時引發

update-end

當更新結束時引發

selection-complete

當選取完成時引發

selection-clear

當清除選取時引發

edits-complete

當編輯完成時引發

 

 

Example

 

 

<script type="text/javascript" src="scripts/FeatureLayer.js"></script>

<script type="text/javascript" src="scripts/Infowindow.js"></script>

 

//Define InfoTemplate

var infoTemp = new sg.InfoTemplate("${admin}", "${*}");

 

//Create a FeatureLayer using the Infotemplate to show attributes in a popup window.

var featureLayer = new sg.FeatureLayer('agent.aspx', {

               name: 'Countries',

               mode: sg.FeatureLayer.MODE_ONDEMAND

           });

featureLayer.setInfoTemplate(infoTemp);

 

 

 

 


©2015 Supergeo Technologies Inc.