Simplify dragAndDropInteraction in examples
This commit is contained in:
@@ -114,17 +114,15 @@ var map = new ol.Map({
|
|||||||
|
|
||||||
dragAndDropInteraction.on('addfeatures', function(event) {
|
dragAndDropInteraction.on('addfeatures', function(event) {
|
||||||
var vectorSource = new ol.source.Vector({
|
var vectorSource = new ol.source.Vector({
|
||||||
features: event.features,
|
features: event.features
|
||||||
projection: event.projection
|
|
||||||
});
|
});
|
||||||
map.getLayers().push(new ol.layer.Image({
|
map.addLayer(new ol.layer.Image({
|
||||||
source: new ol.source.ImageVector({
|
source: new ol.source.ImageVector({
|
||||||
source: vectorSource,
|
source: vectorSource,
|
||||||
style: styleFunction
|
style: styleFunction
|
||||||
})
|
})
|
||||||
}));
|
}));
|
||||||
var view = map.getView();
|
map.getView().fitExtent(
|
||||||
view.fitExtent(
|
|
||||||
vectorSource.getExtent(), /** @type {ol.Size} */ (map.getSize()));
|
vectorSource.getExtent(), /** @type {ol.Size} */ (map.getSize()));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -112,15 +112,13 @@ var map = new ol.Map({
|
|||||||
|
|
||||||
dragAndDropInteraction.on('addfeatures', function(event) {
|
dragAndDropInteraction.on('addfeatures', function(event) {
|
||||||
var vectorSource = new ol.source.Vector({
|
var vectorSource = new ol.source.Vector({
|
||||||
features: event.features,
|
features: event.features
|
||||||
projection: event.projection
|
|
||||||
});
|
});
|
||||||
map.getLayers().push(new ol.layer.Vector({
|
map.addLayer(new ol.layer.Vector({
|
||||||
source: vectorSource,
|
source: vectorSource,
|
||||||
style: styleFunction
|
style: styleFunction
|
||||||
}));
|
}));
|
||||||
var view = map.getView();
|
map.getView().fitExtent(
|
||||||
view.fitExtent(
|
|
||||||
vectorSource.getExtent(), /** @type {ol.Size} */ (map.getSize()));
|
vectorSource.getExtent(), /** @type {ol.Size} */ (map.getSize()));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user