2017-08-30 1 views
1

私は5つのgeojsonレイヤーを持っています - 各レイヤーには1行あります。私は、map.getSourceまたはmap.getLayerを使って線の座標を取得したいと思いますが、幾何形状のプロパティは表示されません。 私はこれで座標を取得することができます。mapboxのgetSourceまたはgetLayerでジオ​​メトリ(coord)を取得します。gl

var features = map.queryRenderedFeatures({layers:[layerName]}); 
console.log(features[0].geometry); 

私にGeoJSONは次のとおりです。

var layer = map.addLayer({ 
     "id": layerName, 
     "type": "line", 
     "source": { 
      "type": "geojson", 
      "data": { 
       "type": "Feature", 
       "properties": {}, 
       "geometry": { 
        "type": "LineString", 
        "coordinates": line 
       } 
      } 
     }, 
     "layout": { 
      "line-join": "round", 
      "line-cap": "round" 
     }, 
     "paint": { 
      "line-color": "red", 
      "line-width": 13 
     } 
    }); 

答えて

1

getSourcegetLayerは、ソースデータを取得するために使用されることを意味しません。ソースデータにアクセスする唯一の方法は、queryRenderedFeaturesまたはquerySourceFeatures

です。
関連する問題