2016-03-08 68 views
0

如何從GeoJSON圖層訪問要素數據?如何通過Here-API V3使用geojson.Reader

如何使用點數據更改從GeoJSON創建的圖層上的標記顏色?

以下代碼段創建層:

var busReader = new H.data.geojson.Reader(busjson); 
busReader.parse(); 
var busLayer = busReader.getLayer(); 
map.addLayer(busLayer); 

回答

1

有能夠設置與讀取器(documentation

 var reader = new H.data.geojson.Reader(busjson, { 
     // This function is called each time parser detects a new map object 
     style: function (mapObject) { 
      if (mapObject instanceof H.map.Polygon) { 
      mapObject.setStyle({ 
       fillColor: 'rgba(153, 0, 153, 0.5)', 
       strokeColor: 'rgba(0, 0, 102, 0.5)', 
       lineWidth: 3 
      }); 
      } 
     } 
     }); 

     // Start parsing the file 
     reader.parse(); 

     // Add layer which shows GeoJSON data on the map 
     map.addLayer(reader.getLayer()); 
樣式選項