I am trying to add layers by using drag and drop interaction. Here is jsfiddle.http://jsfiddle.net/anuket/umdwzn10/ It almost works, I mean new layer is added, but for Geometry it gives "NaN". Geojson I used for testing is this one:


Does this interaction support custom projections? and second question is, does this support polygons, because seems like it does not, at least in my tests.

1 Answer 1


This interaction does not support custom projections. In the code, the private ol.interaction.DragAndDrop.prototype.handleResult_ calls the code below:

var readFeatures = this.tryReadFeatures_(format, result);

This code itself return format.readFeatures(text) (where format is ol.format.GeoJSON). If custom projections were supported, it would be format.readFeatures(text, options) where options would take {dataProjection: 'EPSG:3301'}.

Anyways, you can always overload the ol.format.GeoJSON using OpenLayers 3. You can also make your custom component for Drag and Drop without OpenLayers and call OpenLayers functions only to parse dragged GeoJSON with the "right" projection. For example, you can use http://www.dropzonejs.com or http://filedropjs.org

For polygons, using a polygon created with http://geojson.io and then add it to http://openlayers.org/en/master/examples/drag-and-drop.html works on my side.

  • Sorry, could you specify what do you mean by "...you can always overload the ol.format.GeoJSON using OpenLayers 3..."
    – Anuket
    Commented Oct 20, 2014 at 8:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.