2012-03-30 33 views
1

我有這個實現與融合表層,我嘗試使用字母A-Z的預定義標記圖標來顯示搜索查詢在地圖上的結果(很像原來的谷歌地圖)。融合層中可以有多少個不同的標記是否有限制?

我實現這一目標是先建立一個層,與所有標記的通用圖標的方式..

var layer = new google.maps.FusionTablesLayer({ 
    query: { 
     select: 'Geometry', 
     from: 0000000 
    }, 
    map: map, 
    options: { 
     suppressInfoWindows: true 
    }, 
    styles: [{ 
     markerOptions: { 
      iconName: "measle_white" 
     } 
    }] 
}); 

同時,我詢問同桌的25個結果與ST_DISTANCE排序基於我的地方地圖的中心(geopositioned)

var queryUrlHead = 'http://www.google.com/fusiontables/api/query?sql=', 
    queryUrlTail = '&jsonCallback=success', 
    query = 'SELECT+ID+FROM+0000000+ORDER+BY+ST_DISTANCE(Geometry,LATLNG('+position.coords.latitude+','+position.coords.longitude+'))+LIMIT+25'; 

var queryurl = queryUrlHead + query + queryUrlTail; 

返回的JSON對象是唯一的ID的我稱之爲「IDS」的數組。然後我使用一些觸發器(zoomchanged)來重新繪製帶有字母圖標的25個最近的圖標(由this啓發)。

google.maps.event.addListener(map, 'zoom_changed', function() { 

layer.setOptions({ 
    styles: [{ 
      markerOptions: { 
       iconName: "measle_white" 
      } 
     }, //fallback 
     { 
      where: "'ID' = " + ids.table.rows[0][0], 
      markerOptions: { 
       iconName: "a_blue" 
      } 
     }, { 
      where: "'ID' = " + ids.table.rows[1][0], 
      markerOptions: { 
       iconName: "b_blue" 
      } 
     }, { 
      where: "'ID' = " + ids.table.rows[2][0], 
      markerOptions: { 
       iconName: "c_blue" 
      } 
     }, { 
      where: "'ID' = " + ids.table.rows[3][0], 
      markerOptions: { 
       iconName: "d_blue" 
      } 
     }, { 
      where: "'ID' = " + ids.table.rows[4][0], 
      markerOptions: { 
       iconName: "e_blue" 
      } 
     }, { 
      where: "'ID' = " + ids.table.rows[5][0], 
      markerOptions: { 
       iconName: "f_blue" 
      } 
     }, { 
      where: "'ID' = " + ids.table.rows[6][0], 
      markerOptions: { 
       iconName: "g_blue" 
      } 
     }, { 
      where: "'ID' = " + ids.table.rows[7][0], 
      markerOptions: { 
       iconName: "h_blue" 
      } 
     }, { 
      where: "'ID' = " + ids.table.rows[8][0], 
      markerOptions: { 
       iconName: "i_blue" 
      } 
     }, { 
      where: "'ID' = " + ids.table.rows[9][0], 
      markerOptions: { 
       iconName: "j_blue" 
      } 
     }, { 
      where: "'ID' = " + ids.table.rows[10][0], 
      markerOptions: { 
       iconName: "k_blue" 
      } 
     }, { 
      where: "'ID' = " + ids.table.rows[11][0], 
      markerOptions: { 
       iconName: "l_blue" 
      } 
     }, { 
      where: "'ID' = " + ids.table.rows[12][0], 
      markerOptions: { 
       iconName: "m_blue" 
      } 
     }, { 
      where: "'ID' = " + ids.table.rows[13][0], 
      markerOptions: { 
       iconName: "n_blue" 
      } 
     }, { 
      where: "'ID' = " + ids.table.rows[14][0], 
      markerOptions: { 
       iconName: "o_blue" 
      } 
     }, { 
      where: "'ID' = " + ids.table.rows[15][0], 
      markerOptions: { 
       iconName: "p_blue" 
      } 
     }, { 
      where: "'ID' = " + ids.table.rows[16][0], 
      markerOptions: { 
       iconName: "q_blue" 
      } 
     }, { 
      where: "'ID' = " + ids.table.rows[17][0], 
      markerOptions: { 
       iconName: "r_blue" 
      } 
     }, { 
      where: "'ID' = " + ids.table.rows[18][0], 
      markerOptions: { 
       iconName: "s_blue" 
      } 
     }, { 
      where: "'ID' = " + ids.table.rows[19][0], 
      markerOptions: { 
       iconName: "t_blue" 
      } 
     }, { 
      where: "'ID' = " + ids.table.rows[20][0], 
      markerOptions: { 
       iconName: "u_blue" 
      } 
     }, { 
      where: "'ID' = " + ids.table.rows[21][0], 
      markerOptions: { 
       iconName: "v_blue" 
      } 
     }, { 
      where: "'ID' = " + ids.table.rows[22][0], 
      markerOptions: { 
       iconName: "w_blue" 
      } 
     }, { 
      where: "'ID' = " + ids.table.rows[23][0], 
      markerOptions: { 
       iconName: "x_blue" 
      } 
     }, { 
      where: "'ID' = " + ids.table.rows[24][0], 
      markerOptions: { 
       iconName: "z_blue" 
      } 
     } 
    ] 
}); 

現在,除了前5個結果A-D(回退圖標的+1)外,這個實際上效果非常出色。這裏出了什麼問題?我是否遇到了一些限制(markerOptions只有5個值)還是我弄亂了代碼?

旁註:This example每層看起來有5個以上的圖標,但Google做了它,我不明白它中的任何一個。

回答

0

很抱歉,只能通過Maps API設置5種款式。該限制在developers guide中提及。 我懷疑顯示所有可能圖標的地圖不是FT圖層。如果通過FT用戶界面完成,您可以擁有更多樣式,但這不是動態的,可能不適合您的情況。

相關問題