96
用用 Drupal 打造 打造 GIS 網站 網站 Presented by Pomin Wu, 台灣環境資訊協會.

用 Drupal 打造 GIS 網站

  • Upload
    pomin5

  • View
    2.043

  • Download
    4

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: 用 Drupal 打造 GIS 網站

用用 Drupal 打造打造 GIS 網站網站Presented by Pomin Wu,台灣環境資訊協會.

www.princexml.com
Prince - Non-commercial License
This document was created with Prince, a great way of getting web content onto paper.
Page 2: 用 Drupal 打造 GIS 網站

經驗分享與主題經驗分享與主題

1.其實我不是 GIS 專家。

2.但是用 Drupal 做個網站還可以。

3.所以有天某人(我老闆)就跟我說

02

Page 3: 用 Drupal 打造 GIS 網站

“Make it so.”

Page 4: 用 Drupal 打造 GIS 網站

台灣海岸守護網台灣海岸守護網

04

Page 5: 用 Drupal 打造 GIS 網站

實地踏查的監測資訊中心實地踏查的監測資訊中心

05

Page 6: 用 Drupal 打造 GIS 網站

To explore strange new worlds

06

Page 7: 用 Drupal 打造 GIS 網站

“Elementary, Dear Data”, TNG 2x03Geofield is a module for storing geographic data in Drupal 7. It supports

all geo-types (points, lines, polygons, multitypes etc.)

PostGIS provides a field for geospatial data that can be added to entities.

To the end user this module is similar to the Geofield module, but spatial

operations and data storage rely on PostGIS.

07

Page 8: 用 Drupal 打造 GIS 網站

關於格式關於格式

• Well-known Text (WKT).

• POINT (121.52861583171 25.043122959287)

• GeoJSON.

{"type":"Point","coordinates":[121.52861583171,25.043122959287]}

• Latitude and Longitude (經緯度)

• 25.043123 121.528616

08

Page 9: 用 Drupal 打造 GIS 網站

“Put it on the view screen.”OpenLayers integartes the OpenLayers JavaScript mapping library and is

full of features: maps, styles, layers, behaviors, and projections.

Leaflet integrates the Leaflet JavaScript mapping library.

09

Page 10: 用 Drupal 打造 GIS 網站

GIS CMS stacks using Drupal

10

Page 11: 用 Drupal 打造 GIS 網站

“A Matter of Perspective”, TNG 3x14不論做什麼都要用到 Views。

11

Page 12: 用 Drupal 打造 GIS 網站

(以下會有一點枯燥。)

“Proceed.”

Page 13: 用 Drupal 打造 GIS 網站

Geofield

Page 14: 用 Drupal 打造 GIS 網站

Geofield安裝

$ drush dl geofield

$ drush en -y geofield_map # dl & en geofield, geoPHP

01.

02.

14

Page 15: 用 Drupal 打造 GIS 網站

Geofield: Latitude Longitude widget

15

Page 16: 用 Drupal 打造 GIS 網站

GeofieldLatitude and Longitude widget

• Decimal Degrees (122.340932)

• Degrees-Minutes-Seconds (-123° 49’ 55.2” W)

• 可以配合 Feeds批次匯入經緯度資料。

16

Page 17: 用 Drupal 打造 GIS 網站

Geofield: HTML5 Geofield widget

17

Page 18: 用 Drupal 打造 GIS 網站

GeofieldHTML5 Geolocation widget

• 從瀏覽器取得使用者的地理位置。

• ask Google for non-supportive browsers.

18

Page 19: 用 Drupal 打造 GIS 網站

Geofield再選個 display… 不過先等一下。

19

Page 20: 用 Drupal 打造 GIS 網站

OpenLayers安裝

$ drush dl openlayers views

# dl & en views, ctools, proj4js, libraries, too.

$ drush en -y openlayers_views openlayers_ui views_ui

01.

02.

03.

20

Page 21: 用 Drupal 打造 GIS 網站

Geofield: OpenLayers Map widget

21

Page 22: 用 Drupal 打造 GIS 網站

GeofieldDraw on an OpenLayers Map widget

• 直接在地圖上點出位置。

• 可以描點、線、面。

• 可是地圖預設的中心是經緯度 (0, 0) (在非洲大陸西南方)

22

Page 23: 用 Drupal 打造 GIS 網站

Geofield

23

Page 24: 用 Drupal 打造 GIS 網站

Geofield: OpenLayers Map display

24

Page 25: 用 Drupal 打造 GIS 網站

GeofieldOpenLayers Map display

• 用地圖呈現這個 node 的位置。

• 可是地圖預設的中心是經緯度 (0, 0) (在非洲大陸西南方)

25

Page 26: 用 Drupal 打造 GIS 網站

Geofield

26

Page 27: 用 Drupal 打造 GIS 網站

OpenLayers Map

27

Page 28: 用 Drupal 打造 GIS 網站

OpenLayers Map

28

Page 29: 用 Drupal 打造 GIS 網站

OpenLayers Map

29

Page 30: 用 Drupal 打造 GIS 網站

Geofield: set OpenLayers Map center

30

Page 31: 用 Drupal 打造 GIS 網站

Geofield: OpenLayers Map display

31

Page 32: 用 Drupal 打造 GIS 網站

Geofield: OpenLayers Map widget

32

Page 33: 用 Drupal 打造 GIS 網站

OpenLayers

Page 34: 用 Drupal 打造 GIS 網站

OpenLayers• 但是我們得從 Views 開始。

34

Page 35: 用 Drupal 打造 GIS 網站

OpenLayers: add a view.

35

Page 36: 用 Drupal 打造 GIS 網站

OpenLayers: add location field.

36

Page 37: 用 Drupal 打造 GIS 網站

OpenLayers: choose WKT format.

37

Page 38: 用 Drupal 打造 GIS 網站

OpenLayers: check result.

38

Page 39: 用 Drupal 打造 GIS 網站

OpenLayers: OpenLayers Data Overlay.

39

Page 40: 用 Drupal 打造 GIS 網站

OpenLayers: change format.

40

Page 41: 用 Drupal 打造 GIS 網站

OpenLayers: choose the only format.

41

Page 42: 用 Drupal 打造 GIS 網站

OpenLayers: fill in options.

42

Page 43: 用 Drupal 打造 GIS 網站

OpenLayers: check result.

43

Page 44: 用 Drupal 打造 GIS 網站

(記得把剛才的 view 存起來。)

喘口氣喘口氣

Page 45: 用 Drupal 打造 GIS 網站

OpenLayers

45

Page 46: 用 Drupal 打造 GIS 網站

OpenLayers Layers

46

Page 47: 用 Drupal 打造 GIS 網站

OpenLayers Layers: check result

47

Page 48: 用 Drupal 打造 GIS 網站

OpenLayers Layers: goto map

48

Page 49: 用 Drupal 打造 GIS 網站

OpenLayers Layers: edit the default map

49

Page 50: 用 Drupal 打造 GIS 網站

OpenLayers Layers: edit layers and styles

50

Page 51: 用 Drupal 打造 GIS 網站

OpenLayers Layers: add our layer

51

Page 52: 用 Drupal 打造 GIS 網站

OpenLayers Layers: check result

52

Page 53: 用 Drupal 打造 GIS 網站

OpenLayers Layers: check result

53

Page 54: 用 Drupal 打造 GIS 網站

OpenLayers Layers: edit behaviors

54

Page 55: 用 Drupal 打造 GIS 網站

OpenLayers Layers: add pop up

55

Page 56: 用 Drupal 打造 GIS 網站

OpenLayers Layers: check result

56

Page 57: 用 Drupal 打造 GIS 網站

OpenLayers Layers: set map center

57

Page 58: 用 Drupal 打造 GIS 網站

(記得把剛才的 openlayer map 存起來。)

喘口氣喘口氣

Page 59: 用 Drupal 打造 GIS 網站

OpenLayers: show the map in a page• 可以用 Panels.

• 也可以用 Views.

59

Page 60: 用 Drupal 打造 GIS 網站

OpenLayers: show with a view

60

Page 61: 用 Drupal 打造 GIS 網站

OpenLayers: show with a view

61

Page 62: 用 Drupal 打造 GIS 網站

相當麻煩相當麻煩

Page 63: 用 Drupal 打造 GIS 網站

Why?1. Defaults do not work very well.

2. The whole Views -> OpenLayers -> Views process is confusing.

3. OpenLayers adds another level of abstraction.

• Does not fit into the Views-centric workflow of Drupal very well.

63

Page 64: 用 Drupal 打造 GIS 網站

Leaflet

Page 65: 用 Drupal 打造 GIS 網站

Leaflet安裝

$ drush dl leaflet

$ drush en -y leaflet_views # dl & en leaflet, entity

Download Leaflet library, extract and put the files in sites/all/

libraries/leaflet .

01.

02.

65

Page 66: 用 Drupal 打造 GIS 網站

Geofield: Leaflet display

66

Page 67: 用 Drupal 打造 GIS 網站

Geofield: Leaflet display

67

Page 68: 用 Drupal 打造 GIS 網站

Leaflet Map• 仍然要從 Views 開始。

68

Page 69: 用 Drupal 打造 GIS 網站

Leaflet: create a view page

69

Page 70: 用 Drupal 打造 GIS 網站

Leaflet: choose Leaflet Map format

70

Page 71: 用 Drupal 打造 GIS 網站

Leaflet: add location field

71

Page 72: 用 Drupal 打造 GIS 網站

Leaflet: choose WKT format

72

Page 73: 用 Drupal 打造 GIS 網站

Leaflet: set page style

73

Page 74: 用 Drupal 打造 GIS 網站

Leaflet: check result

74

Page 75: 用 Drupal 打造 GIS 網站

Leaflet: check result

75

Page 76: 用 Drupal 打造 GIS 網站

Why?1. Leaflet has nice defaults.

2. Just render a view (a list of query result) as a map.

• Intuitive (at least for Drupal developers.)

3. And this brings some new features (in a moment).

4. But Leaflet lacks a few important features.

• among them, a Geofield widget.

76

Page 77: 用 Drupal 打造 GIS 網站

那就自己做一那就自己做一個個 Drupical 吧吧

Page 78: 用 Drupal 打造 GIS 網站
Page 79: 用 Drupal 打造 GIS 網站

Search and filter• Leaflet Map 只是一個 view page。

• 所以 Views 的功能都可以用。

• 可以加 filter,可以 expose form。

• 可以對文字欄位搜尋,可以開 Ajax。

79

Page 80: 用 Drupal 打造 GIS 網站

Search and filter

80

Page 81: 用 Drupal 打造 GIS 網站

Search and filter

81

Page 82: 用 Drupal 打造 GIS 網站

Search and filter

82

Page 83: 用 Drupal 打造 GIS 網站

Search and filter

83

Page 84: 用 Drupal 打造 GIS 網站

Search and filter

84

Page 85: 用 Drupal 打造 GIS 網站

Search and filter

85

Page 86: 用 Drupal 打造 GIS 網站

Search and filter• 這比 OpenLayers 的圖層好用!

• 而且可以對文字欄位搜尋。

86

Page 87: 用 Drupal 打造 GIS 網站

修改修改 OpenLayers• OpenLayers Javascript Library 其實還有很多功能沒有整合進 Drupal。

• http://openlayers.org/dev/examples/有一大堆範例程式,in Javascript。

• 要用這些範例程式裡的功能,要自己寫 Javascript(用 jQuery 不會很難

啦)。

• 並且要知道怎麼 access 網站上的 OpenLayers.Map object。

87

Page 88: 用 Drupal 打造 GIS 網站

修改修改 OpenLayers

88

Page 89: 用 Drupal 打造 GIS 網站

修改修改 OpenLayers

89

Page 90: 用 Drupal 打造 GIS 網站

修改修改 OpenLayers

90

Page 91: 用 Drupal 打造 GIS 網站

PostGIS

Page 92: 用 Drupal 打造 GIS 網站

Cartaro, Geospatial CMS based on Drupal

92

Page 93: 用 Drupal 打造 GIS 網站

Architecture

93

Page 94: 用 Drupal 打造 GIS 網站

以上以上

Page 95: 用 Drupal 打造 GIS 網站

參考資源參考資源

• Geofield、PostGIS、OpenLayers、Leaflet、GeoServer 等等 Drupal 模組

都在 Drupal.org。

• Drupical http://drupical.org/

• Cartaro http://cartaro.org/

• 台灣海岸守護網 http://coast.e-info.org.tw/

95

Page 96: 用 Drupal 打造 GIS 網站

聯絡方式聯絡方式

• Pomin Wu http://twitter.com/pm5

• 台灣環境資訊協會 http://www.e-info.org.tw/

96