0
GeoJsonに描画して保存する機能を果たしました。 result from saveロード後のOpenLayersは描画できません
次は、描画をしたいときに機能をロードするときにエラーが表示されます。「layer.getSource()。getFeaturesCollection()」== nullしかし、featureCollection型のフェッチを保存しました。私はgetFeaturesを(使用する場合)には、機能
の配列を返す負荷層から開始します:
if(map_info != "") {
var layer_area = new ol.layer.Vector({
source: new ol.source.Vector({
features: (new ol.format.GeoJSON()).readFeatures(map_info['layers'][0])
}),
});
var layer_branch = new ol.layer.Vector({
source: new ol.source.Vector({ features: (new ol.format.GeoJSON()).readFeatures(map_info['layers'][1]) })
});
var layer_region = new ol.layer.Vector({
source: new ol.source.Vector({ features: (new ol.format.GeoJSON()).readFeatures(map_info['layers'][2]) })
});
var layer_ambon = new ol.layer.Vector({
source: new ol.source.Vector({ features: (new ol.format.GeoJSON()).readFeatures(map_info['layers'][3]) })
});
var view=new ol.View({
center: [{{map.pos_x}}, {{map.pos_y}}],
zoom: {{map.zoom}}
});
}else {
var layer_area = new ol.layer.Vector({
source: new ol.source.Vector({ features: new ol.Collection() })
});
var layer_branch = new ol.layer.Vector({
source: new ol.source.Vector({ features: new ol.Collection() })
});
var layer_region = new ol.layer.Vector({
source: new ol.source.Vector({ features: new ol.Collection() })
});
var layer_ambon = new ol.layer.Vector({
source: new ol.source.Vector({ features: new ol.Collection() })
});
var view=new ol.View({
center: [2097096.387839827, 6887410.172738342],
zoom: 5
});
}
ドロー機能:
$("#draw_ambon").on("click", function(){
var layer=manager["ambon"];
map.removeInteraction(draw);
select !== null ? map.removeInteraction(select) : 0;
setInteraction(layer.getSource().getFeaturesCollection(), "Point");
layer.setStyle(pointStyleFunction);
layer.setMap(map);
draw.on("drawend", function(e){
layer.getSource().addFeatures(e.feature);
e.feature.setProperties({
'id': layer.getSource().getFeaturesCollection().getLength(),
'type': "ambona",
'name': ''
})
})
});