|
1 | 1 | <!DOCTYPE html> |
2 | | -<html lang="en"> |
| 2 | +<html lang="zh-TW"> |
3 | 3 | <head> |
4 | 4 | <meta charset="utf-8" /> |
5 | 5 | <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"> |
|
12 | 12 | margin: 0; |
13 | 13 | } |
14 | 14 | #map { |
15 | | - /* configure the size of the map */ |
| 15 | + /* 設定地圖的大小 */ |
16 | 16 | width: 100%; |
17 | 17 | height: 100%; |
18 | 18 | } |
19 | 19 | </style> |
20 | | - <!-- The line below is only needed for old environments like Internet Explorer and Android 4.x --> |
| 20 | + <!-- 以下的行是為了舊的環境,例如 Internet Explorer 與 Android 4.x --> |
21 | 21 | <script src="http://cdn.polyfill.io/v2/polyfill.min.js?features=requestAnimationFrame,Element.prototype.classList,URL"></script> |
22 | 22 | <script src="http://openlayers.org/en/v3.18.2/build/ol.js"></script> |
23 | 23 | </head> |
|
28 | 28 | var map = new ol.Map({ |
29 | 29 | layers: [ |
30 | 30 | new ol.layer.Tile({ |
31 | | - // This illustrates a custom tiles source but for using |
32 | | - // official OpenStreetMap server new ol.source.OSM() |
33 | | - // instead of new ol.source.XYZ(...) is enough |
| 31 | + // 這描述自訂圖磚來源但使用 |
| 32 | + // 官方開放街圖伺服器新 ol.source.OSM() |
| 33 | + // 而非新 ol.source.XYZ(...) 已經足夠 |
34 | 34 | source: new ol.source.XYZ({ |
35 | 35 | attributions: [ |
36 | 36 | ol.source.OSM.ATTRIBUTION, |
|
44 | 44 | }) |
45 | 45 | ], |
46 | 46 | controls: ol.control.defaults({ |
47 | | - // Set to display OSM attributions on the bottom right control |
| 47 | + // 設定在右下角顯示 OSM 署名 |
48 | 48 | attributionOptions: { |
49 | 49 | collapsed: false |
50 | 50 | } |
51 | 51 | }).extend([ |
52 | | - new ol.control.ScaleLine() // Add scale line to the defaults controls |
| 52 | + new ol.control.ScaleLine() // 在預設位置新增比例尺 |
53 | 53 | ]), |
54 | 54 | target: 'map', |
55 | 55 | view: new ol.View({ |
|
58 | 58 | }) |
59 | 59 | }); |
60 | 60 |
|
61 | | - // Add vector layer with a feature and a style using an icon |
| 61 | + // 在向量圖層新增圖徵與圖示樣式 |
62 | 62 | var vectorLayer = new ol.layer.Vector({ |
63 | 63 | source: new ol.source.Vector({ |
64 | 64 | features: [ |
65 | 65 | new ol.Feature({ |
66 | 66 | geometry: new ol.geom.Point( |
67 | 67 | ol.proj.fromLonLat([0, 0]) |
68 | 68 | ), |
69 | | - name: 'The center of the world' |
| 69 | + name: '全世界的中心' |
70 | 70 | }) |
71 | 71 | ] |
72 | 72 | }), |
|
82 | 82 |
|
83 | 83 | map.addLayer(vectorLayer); |
84 | 84 |
|
85 | | - // Overlay to manage popup on the top of the map |
| 85 | + // 套疊來管理地圖上跳出選單 |
86 | 86 | var popup = document.getElementById('popup'); |
87 | 87 | var overLay = new ol.Overlay({ |
88 | 88 | element: popup, |
|
91 | 91 |
|
92 | 92 | map.addOverlay(overLay); |
93 | 93 |
|
94 | | - // Manage click on the map to display/hide popup |
| 94 | + // 管理地圖上點擊行為來顯示/隱藏跳出選單 |
95 | 95 | map.on('click', function(e) { |
96 | 96 | var info = []; |
97 | 97 | map.forEachFeatureAtPixel(e.pixel, function (feature) { |
|
0 commit comments