close Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": /usr/lib/python2.7/dist-packages/libsvn/_delta.so: failed to map segment from shared object: Cannot allocate memory). Look in the Trac log for more information.

Changes between Version 6 and Version 7 of oid/WorkLog/09-02-04


Ignore:
Timestamp:
Feb 4, 2009, 4:24:42 PM (15 years ago)
Author:
jazz
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • oid/WorkLog/09-02-04

    v6 v7  
    141141  $(function(){
    142142    G_MAP = new RedcliffMap(); # 呼叫 RedcliffMap() 產生 GMap2 物件
    143     LoadLocation();
     143    LoadLocation();            # 呼叫 LoadLocation() 從 location.json 讀檔並畫出歷史古城的位置點
    144144    new TilesSelect();
    145145    new TabManager(['events', 'characters', 'vote'], 'characters');
     
    154154 * 關於 G_MAP = new !RedcliffMap(); 這行程式
    155155{{{
    156 #!
    157 
    158156  ### 首先要看的是 RedcliffMap 這個類別物件的建構子(Constructor)
    159157  ### 以下省略類別中的 method 函數定義,從這裡可以看到 RedcliffMap 定義了 9 個 method
     
    208206  };
    209207}}}
     208 * 關於 !LoadLocation(); 這行程式
     209{{{
     210  function LoadLocation() {
     211
     212    ### 參考 http://code.google.com/intl/zh-TW/apis/gadgets/docs/legacy/remote-content.html#Fetch_text
     213    ### _IG_FetchContent(url, func) 是一個 Mapplet 的 callback 函數,用來定義擷取 url 之後該執行哪個 func 函數
     214
     215    ### 這裡定義要去擷取 URL.location_url ,
     216    ### 也就是 http://redcliff.googlecode.com/svn/trunk/data_tc/location.json?bpc=12191314
     217    ### [備註] 加上 bpc= 是為了清除 google code 的 cache ,這點在程式碼裡面也有寫上註解
     218    ### <!-- NOTE: Add "?bpc=<radnom>" to by pass the cache for the css file. -->
     219
     220    _IG_FetchContent(URL.location_url, function(data) {
     221
     222    ### 宣告 json 變數等於 callback 函數回傳回來的 data
     223    ### 參考 http://www.w3schools.com/jsref/jsref_eval.asp
     224
     225    ### location.json 裡的內容
     226    ### [ {"name" : "成都" , "lat" : 30.670992 , "lng" : 104.067993 }, ... ]
     227
     228      var json = eval(data);
     229
     230    ### 依序把 location.json 裡的 name 跟 location (lat,lng) 設定上去
     231
     232      $.each(json, function(index, location) {
     233
     234    ### var LOCATION = new Hash(); 這裡的 LOCATION 物件是一個 Hash (湊雜)
     235    ### Hash 類別必須參考原始碼中 Hash.prototype 定義了 5 個 method
     236    ### removeItem(in_key), getItem(in_key), setItem(in_key, in_value), hasItem(in_key), getLength()
     237    ### 還有 length 跟 item 兩個 field.
     238    ### 照 setItem(in_key, in_value) 語法看起來應該會產生一個 二維陣列 (Array)
     239
     240    ### 這裡還呼叫了 Location 建構子
     241    ### function Location(raw_location) {
     242    ###   var me = this;
     243    ###   this.location = raw_location;
     244    ###   this.name = location.name;
     245    ###   this.point = new GLatLng(raw_location.lat, raw_location.lng);
     246    ### };
     247
     248    ### 因此這一行的最後結果應該是
     249    ### Location.item=[{"成都",GLatLng(30.670992,104.067993)},{...}] 這樣一個二維陣列
     250
     251        LOCATION.setItem(location.name, new Location(location));
     252      });
     253    ### 呼叫 LoadElement() 跟 LoadEvent()
     254      LoadElement();
     255      LoadEvent();
     256    });
     257  };
     258}}}