2015-05-04 96 views
0

我有google fusion table文件的列namegeometry,那麼我想改變地圖的樣式與不同顏色的每個不同的名稱在融合表,並顯示在我的地圖應用程序(我使用google map api v3 )這是我的腳本:造型谷歌Fusion Tables的使用JavaScript

layer = new google.maps.FusionTablesLayer({ 
     query : { 
      select : 'geometry', 
      from : 'xxx' 
     }, 
     styles : [{ 
       where: 'name IN (Agro Industri)', 
       polygonOptions : { 
        fillColor : '#66cc66' 
       } 
      },{ 
       where: 'name IN (Bandara)', 
       polygonOptions : { 
        fillColor : '#007fff' 
       } 
      },{ 
       where: 'name IN (Fasilitas Pendidikan)', 
       polygonOptions : { 
        fillColor : '#cc0000' 
       } 
      },{ 
       where: 'name IN (Gardu Induk)', 
       polygonOptions : { 
        fillColor : '#ff0000' 
       } 
      },{ 
       where: 'name IN (Horti & Kebun)', 
       polygonOptions : { 
        fillColor : '#66cc66' 
       } 
      },{ 
       where: 'name IN (Hutan Lindung)', 
       polygonOptions : { 
        fillColor : '#007f00' 
       } 
      },{ 
       where: 'name IN (Hutan Rakyat)', 
       polygonOptions : { 
        fillColor : '#007f1f' 
       } 
      },{ 
       where: 'name IN (Industri)', 
       polygonOptions : { 
        fillColor : '#c0c0c0' 
       } 
      },{ 
       where: 'name IN (Kawasan Pariwisata)', 
       polygonOptions : { 
        fillColor : '#ffbf7f' 
       } 
      },{ 
       where: 'name IN (Kawasan Pemerintahan)', 
       polygonOptions : { 
        fillColor : '#ff0000' 
       } 
      },{ 
       where: 'name IN (Perdagangan & Jasa)', 
       polygonOptions : { 
        fillColor : '#ff00ff' 
       } 
      },{ 
       where: 'name IN (Kawasan Permukiman)', 
       polygonOptions : { 
        fillColor : '#ffff00' 
       } 
      },{ 
       where: 'name IN (KKP)', 
       polygonOptions : { 
        fillColor : '#bf00ff' 
       } 
      },{ 
       where: 'name IN (Kompleks Militer)', 
       polygonOptions : { 
        fillColor : '#00994c' 
       } 
      },{ 
       where: 'name IN (KPS)', 
       polygonOptions : { 
        fillColor : '#7dd000' 
       } 
      },{ 
       where: 'name IN (Minapolitan)', 
       polygonOptions : { 
        fillColor : '#007fff' 
       } 
      },{ 
       where: 'name IN (Pertanian Tanaman Pangan)', 
       polygonOptions : { 
        fillColor : '#a0ffa0' 
       } 
      },{ 
       where: 'name IN (RSUD)', 
       polygonOptions : { 
        fillColor : '#ff0000' 
       } 
      },{ 
       where: 'name IN (RTH)', 
       polygonOptions : { 
        fillColor : '#00ff00' 
       } 
      },{ 
       where: 'name IN (Sentral Parkir)', 
       polygonOptions : { 
        fillColor : '#007fff' 
       } 
      },{ 
       where: 'name IN (Tahura)', 
       polygonOptions : { 
        fillColor : '#bc50f0' 
       } 
      },{ 
       where: 'name IN (Terminal Barang)', 
       polygonOptions : { 
        fillColor : '#007fff' 
       } 
      },{ 
       where: 'name IN (Terminal Penumpang)', 
       polygonOptions : { 
        fillColor : '#007fff' 
       } 
      },{ 
       where: 'name IN (TWA Sangeh)', 
       polygonOptions : { 
        fillColor : '#007f3e' 
       } 
     }] 
    }); 
    layer.setMap(map); 

地圖顏色有改變,但遺憾的是所有的顏色相同,顏色不希望按照名稱變更。
有人可以幫助我解決問題嗎?我該怎麼辦才能解決這個問題?

回答

0

documentation


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


...您已經定義了5種以上的樣式。

爲了能夠擁有超過5種不同的fillColors,您可以創建一個新列並將所需顏色存儲在這些列中。使用這些列創建樣式並通過FusionTablesLayerOptions的styleId屬性添加此樣式的ID

+0

謝謝您的解決方案 – Adi