I'm using OpenLayers 2.12.

I try to load a GeoJSON-response from server and (nearly) everything works fine: but the properties contained in the GeoJSON-response ("nummer" and "befund" below) were put in a data-attribute of the feature-objects, not in their attributes-property, which I would expect. As observed in firebug, in the attributes-property I only find the names of my properties and empty strings as values.

Did I miss something, some parameters when creating the formatter or something like that? It's ugly to copy the values in every feature back to attributes...

My parsing function:

function parseGeoJson(featuresText) {                   
    var formatter = new OpenLayers.Format.GeoJSON();
    var features = formatter.read(featuresText);                
    if (features.length > 0) {

My GeoJson:


1 Answer 1


Personnally, I need more input.

I maybe misunderstand but it seems to works: I mean I see your geoJSON properties within the data and attributes keys with the values in the debugger complete.

I use below code in Firebug at http://dev.openlayers.org/releases/OpenLayers-2.12/examples/draw-feature.html

var featuresText = '{"type":"FeatureCollection","features":[{"type":"Feature", "properties":{"nummer":"1","befund":"1.1.1"}, "geometry":{"type":"Polygon","coordinates":[[[15.37109375,81.11328125],[65.29296875,86.38671875],[36.11328125,58.7890625],[15.37109375,81.11328125]]]}}]}';
var formatter = new OpenLayers.Format.GeoJSON();
var features = formatter.read(featuresText);

To confirm I (do not) understand your viewpoint, you will also see a screenshot of the object OpenLayers.Feature.vector content

  • As ThomasG77 says, I can't see any issue. Your geojson is valid and the properties appear as attributes. Oct 18, 2014 at 23:28

Your Answer

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

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