2013-01-24 53 views
0

我想用Google Fusion Tables和Javascript製作熱圖。 This is what I made so far in JSfiddle在熱圖+融合表中自定義半徑和顏色

 function initialize() { 

    var style = [ 
    { 
     featureType: 'all', 
     elementType: 'all', 
     stylers: [ 
     { saturation: -99 } 
     ] 
    }, 
    { 
     featureType: 'road.highway', 
     elementType: 'all', 
     stylers: [ 
     { visibility: 'off' } 
     ] 
    }, 
    { 
     featureType: 'road.arterial', 
     elementType: 'all', 
     stylers: [ 
     { visibility: 'off' } 
     ] 
    }, 
    { 
     featureType: 'road.local', 
     elementType: 'all', 
     stylers: [ 
     { visibility: 'off' } 
     ] 
    }, 
    { 
     featureType: 'administrative.country', 
     elementType: 'all', 
     stylers: [ 
     { visibility: 'off' } 
     ] 
    }, 
    { 
     featureType: 'administrative.province', 
     elementType: 'all', 
     stylers: [ 
     { visibility: 'off' } 
     ] 
    }, 
    { 
     featureType: 'administrative.locality', 
     elementType: 'all', 
     stylers: [ 
     { visibility: 'off' } 
     ] 
    }, 
    { 
     featureType: 'administrative.neighborhood', 
     elementType: 'all', 
     stylers: [ 
     { visibility: 'off' } 
     ] 
    }, 
    { 
     featureType: 'administrative.land_parcel', 
     elementType: 'all', 
     stylers: [ 
     { visibility: 'off' } 
     ] 
    }, 
    { 
     featureType: 'poi', 
     elementType: 'all', 
     stylers: [ 
     { visibility: 'off' } 
     ] 
    }, 
    { 
     featureType: 'transit', 
     elementType: 'all', 
     stylers: [ 
     { visibility: 'off' } 
     ] 
    } 
    ]; 
    var styledMapType = new google.maps.StyledMapType(style, { 
    map: map, 
    name: 'Styled Map' 
    }); 

    var map = new google.maps.Map(document.getElementById('map-canvas'), { 
     center: new google.maps.LatLng(52.04843154112624, 5.33935546875), 
     zoom: 7, 
     mapTypeControl: false, 
     streetViewControl: false, 
     zoomControl: true, 
     panControl: true, 
     draggable: true, 
     zoomControlOptions: { 
     style: google.maps.ZoomControlStyle.SMALL 
     }, 
     mapTypeId: google.maps.MapTypeId.ROADMAP 
    }); 

    map.mapTypes.set('map-style', styledMapType); 
    map.setMapTypeId('map-style'); 
    layerl0 = new google.maps.FusionTablesLayer({ 
    query: { 
     select: "'Latitude'", 
     from: '1nQx1w96dl8YNE_LMnA4Npyrapeo6fErmRXRmB9w' 
    }, 
    heatmap: {enabled: true}, 
    map: map 
    }); 

    } 

    google.maps.event.addDomListener(window, 'load', initialize); 

現在我想自定義熱圖的半徑和顏色。 Here's some explanation on the API,但我無法弄清楚它應該如何在代碼中實現。誰能幫助我?

回答

1

您的鏈接指向文檔的錯誤部分,指向可視化庫(呈現在客戶端)的heatMap,但是您使用僅有1個選項的FusionTableHeatMap(在服務器端呈現)(您可以選擇顯示或不顯示)。

你可以做什麼:從FusionTable請求熱圖的數據,並創建一個可視化 - HeatMap。當然這取決於數據量,如果這是一個可行的方法。

+0

數據量不應該是一個問題,我猜。但是,您如何定製可視化? –

+0

看看這個:https://developers.google.com/maps/documentation/javascript/layers#JSHeatMaps –