<< Click to Display Table of Contents >>

SuperGIS Server JavaScript API

 

new sg.layers.CSVLayer()

 

 

Description

建立 CSV 檔案的圖層。

 

Position

CSVLayer.js

 

 

Parameters

 

Parameter

Type

Description

url

String

GeoJSON url

options

Object

設定圖磚圖層

set object

Name

Type

Description

latitudeFieldName

String

緯度欄位名稱

longitudeFieldName

String

經度欄位名稱

outSR

sg.SpatialReference

匯出SpatialReference,

僅支援WebMercator(EPSG3857)

opacity

Number

圖層透明度

0:透明
1:不透明

visible

Boolean

圖層可見度

True:可見
False:不可見

 

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

可顯示的最小比例尺

mouseEventEnabled

Boolean

是否啟用滑鼠事件

name

String

圖層名稱

node

DOMNODE

圖層html節點

opacity

Number

透明度,範圍為0到1

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

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節點

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: 不可見

RebuildElement()


重繪圖層

redraw()


重繪圖層

remove(graphic)

sg.Graphic

移除指定Graphic

Name

Type

Description

graphic

sg.Graphic

要被移除的Graphic

RemoveSelf()


移除圖層

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)

newVal

設定圖層可見度

Name

Type

Description

newVal

Boolean

圖層可見度

True: 可見
False: 不可見

show()


顯示圖層

UpdateElement()


更新圖層

 

Events

 

Event

Description

click

當滑鼠點擊Graphic時引發

dbl-click

當滑鼠雙擊Graphic時引發

drag

當拖曳時引發

drag-end

當拖曳結束時引發

drag-start

當拖曳開始時引發

grapgic-add

當Graphic被加入時引發

grapgic-clear

當所有Graphic被清除時引發

grapgic-remove

當Graphic被移除時引發

load

當圖層讀取完成時觸發

mouse-down

當滑鼠在Graphic上按下時引發

mouse-move

當滑鼠在Graphic上移動時引發

mouse-out

當滑鼠離開Graphic時引發

mouse-over

當滑鼠移入Graphic時引發

mouse-up

當滑鼠在Graphic上放開時引發

 

Example

 

 

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

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

 

var infoTemplate = new sg.InfoTemplate("${YEAR}","${*}");

var csvUrl = "http://sgs.supergeo.com.tw/city/signif_.csv";

var csvLayer = new sg.layers.CSVLayer(csvUrl, {

    outSR: new sg.SpatialReference(3857),

    latitudeFieldName: "LATITUDE",

    longitudeFieldName: "LONGITUDE"

});

csvLayer.setInfoTemplate(infoTemplate);

mapbase.AddLayer(csvLayer);

 

 

 

See live example

 


©2015 Supergeo Technologies Inc.