source: oceandb/jQuery_Prototype/script/oceandb.js @ 60

Last change on this file since 60 was 60, checked in by jazz, 15 years ago
  • 新增視窗大小改變事件處理函式
File size: 1.6 KB
Line 
1// 註冊 onReady Event
2// 參考: http://docs.jquery.com/Events
3$(document).ready(function() {
4
5  // 顯示 Loading 字樣
6
7  // 設定地圖高度
8  var map_height=document.documentElement.clientHeight - 68;
9  $('#main').css( { height: map_height } );
10
11  // 設定左側選單的 Accordion 風格
12  $('#map-menu').accordion({ header: "h3" });
13
14  // 設定點選 "MENU" 的行為
15  $('#btnMenu').click(function()
16  {
17    if($('#map-menu').css("display") != "none")
18    {
19      $('#map-menu').css({ display: 'none' });
20      $('#map').css({ width: '100%' });
21    } else {
22      $('#map-menu').css({ display: 'block'});
23      $('#map').css({ width: '80%'});
24    }
25  });
26});
27
28// 註冊 window 物件的 onResize Event
29// 參考: http://docs.jquery.com/Events
30$(window).resize(function() {
31  // 當改變瀏覽器大小時,重新設定地圖高度
32  var map_height=document.documentElement.clientHeight - 68;
33  $('#main').css( { height: map_height } );
34});
35
36function load() {
37  if (GBrowserIsCompatible()) {
38    var map = new GMap2(document.getElementById("map"));  // 取得 DOM 中,名稱為 map 的元件
39    map.addControl(new GLargeMapControl());               // 加入左上角比例尺規控制列
40    map.addControl(new GScaleControl());                  // 加入左下角比例尺狀態列
41    map.addControl(new GMapTypeControl());                // 加入右上角"地圖","衛星","混合地圖"按鈕
42    map.setCenter(new GLatLng(23.8,121), 7);              // 設定預設經緯度北緯 23.8, 東經 121, 預設比例尺 100 公里(7)
43    map.setMapType(G_SATELLITE_MAP);                      // 設定預設底圖為"衛星"
44  }
45}
Note: See TracBrowser for help on using the repository browser.