Use olx.format.ReadOptions in ol.interaction.DragAndDrop
Don't reproject the geometries in ol.interaction.DragAndDrop; use the `featureProjection` option in `format.readFeatures`
This commit is contained in:
@@ -106,19 +106,11 @@ ol.interaction.DragAndDrop.prototype.handleResult_ = function(file, event) {
|
|||||||
for (i = 0, ii = formatConstructors.length; i < ii; ++i) {
|
for (i = 0, ii = formatConstructors.length; i < ii; ++i) {
|
||||||
var formatConstructor = formatConstructors[i];
|
var formatConstructor = formatConstructors[i];
|
||||||
var format = new formatConstructor();
|
var format = new formatConstructor();
|
||||||
var readFeatures = this.tryReadFeatures_(format, result);
|
features = this.tryReadFeatures_(format, result, {
|
||||||
if (readFeatures) {
|
featureProjection: projection
|
||||||
var featureProjection = format.readProjection(result);
|
});
|
||||||
var transform = ol.proj.getTransform(featureProjection, projection);
|
if (features && features.length > 0) {
|
||||||
var j, jj;
|
break;
|
||||||
for (j = 0, jj = readFeatures.length; j < jj; ++j) {
|
|
||||||
var feature = readFeatures[j];
|
|
||||||
var geometry = feature.getGeometry();
|
|
||||||
if (geometry) {
|
|
||||||
geometry.applyTransform(transform);
|
|
||||||
}
|
|
||||||
features.push(feature);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.dispatchEvent(
|
this.dispatchEvent(
|
||||||
@@ -167,12 +159,13 @@ ol.interaction.DragAndDrop.prototype.setMap = function(map) {
|
|||||||
/**
|
/**
|
||||||
* @param {ol.format.Feature} format Format.
|
* @param {ol.format.Feature} format Format.
|
||||||
* @param {string} text Text.
|
* @param {string} text Text.
|
||||||
|
* @param {olx.format.ReadOptions} options Read options.
|
||||||
* @private
|
* @private
|
||||||
* @return {Array.<ol.Feature>} Features.
|
* @return {Array.<ol.Feature>} Features.
|
||||||
*/
|
*/
|
||||||
ol.interaction.DragAndDrop.prototype.tryReadFeatures_ = function(format, text) {
|
ol.interaction.DragAndDrop.prototype.tryReadFeatures_ = function(format, text, options) {
|
||||||
try {
|
try {
|
||||||
return format.readFeatures(text);
|
return format.readFeatures(text, options);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user