私はOpenlayers 3を使用しており、選択したオブジェクトに含まれる情報からグラフをリアルタイムで作成したいと考えています。私はプロパティにアクセスする必要がありますが、get( 'myfield')は動作しません。私の特徴はGeoJSONベクトルレイヤーにあります。選択肢から機能情報を取得するol3
var selectSingleClick = new ol.interaction.Select();
map.addInteraction(selectSingleClick);
map.on('singleclick', function(event){
mylayer.once('precompose',function(event){
var selectedFeatures = selectSingleClick.getFeatures();
readFeature(selectedFeatures);
});
});
function readFeature(features){
consoleText = document.getElementById('console');
// When selected, getLength() returns 1, so selection is working.
// consoleText.innerHTML = features.getLength();
var myfeature = features[0];
consoleText.innerHTML += myfeature.get('objectId');
}
誰かが間違っていることを理解するのを助けることができますか?私はJavascriptで多くの経験がありません。