2013-07-23 35 views
1

我有一張帶有兩個融合表層的Google地圖,其中一個帶有標記,另一個帶有多邊形。如果我在沒有樣式的情況下顯示兩個圖層,則會顯示出來。如果我畫出標記,他們都顯示出來。但是,當我嘗試設計多邊形的樣式時,標記不顯示。我沒有想法。One FusionTableLayer似乎與另一個競爭

// Initialize the first layer 
    var firstLayer = new google.maps.FusionTablesLayer({ 
     query: { 
      select: "'geometry'", 
      from: '1eiyhdpl-5xnO7-csWgdrxxYHgFWRLjN0JADIX9o' 
     }, 
     styles: [{ 
      where: "'ABORTIONS' < 100", 
      polygonOptions: { 
       fillColor: '#cc0000', 
       fillOpacity: 0.2 
      } 
     },{ 
      where: "'ABORTIONS' > 100 AND 'ABORTIONS' < 1000", 
      polygonOptions: { 
       fillColor: '#cc0000', 
       fillOpacity: 0.4 
      } 
     },{ 
      where: "'ABORTIONS' > 1000 AND 'ABORTIONS' < 10000", 
      polygonOptions: { 
       fillColor: '#cc0000', 
       fillOpacity: 0.6 
      } 
     },{ 
      where: "'ABORTIONS' > 10000 AND 'ABORTIONS' < 100000", 
      polygonOptions: { 
       fillColor: '#cc0000', 
       fillOpacity: 0.8 
      } 
     }], 
     map: map, 
     suppressInfoWindows: true 
    }); 

    // Initialize the second layer 
     var secondLayer = new google.maps.FusionTablesLayer({ 
     query: { 
     select: "'address'", 
      from: '1j7ogamqx3pXfiG0Eh1Ah0givle_thZE-OBgvQho' 
     }, 
     styles: [{ 
     where: "rank = 1", 
      markerOptions: { 
      iconName: 'small_green' 
      } 
     },{ 
      where: "rank = 0", 
       markerOptions: { 
        iconName: 'small_blue' 
       } 
     }], 
     map: map, 
     suppressInfoWindows: true 
    }); 

如果我從第一層刪除或評論樣式,第二層的樣式標記就在那裏。它們只位於第一層的默認紅色多邊形之上。使用第一層樣式,第二層的標記消失。

謝謝!

回答

2

您只能在地圖上設置一個FusionTablesLayer的樣式。

https://developers.google.com/maps/documentation/javascript/layers#fusion_table_styles

樣式可以只適用於每個圖中的單個融合表層。您最多可以爲該圖層應用五種樣式。

+0

呃。任何解決方法? – Layne

+0

您可以使用FusionTables UI對兩個表([Polygons](https://support.google.com/fusiontables/answer/2681556?hl=en),[Markers](https://support.google。 com/fusiontables/answer/2679986?hl = en)),而不是使用javascript樣式(或僅用於其中一個表格)。 – geocodezip

+0

我會很樂意這樣做。 Noob問題,我如何讓這兩個融合風格的地圖出現在同一張地圖上?我經歷過的所有默認樣式都顯示出來,無論我如何在融合表中對它們進行樣式設置。謝謝。 – Layne