I have just got a problem displaying extended data from a KML file in OpenLayers 2. I hope you can help me with this issue. I have already searched for a solution, but I do not find a real solution for it. I have to mention that I am not a programmer and just modify free available scripts and codes.

I have a standard KML file like:

<?xml version="1.0" encoding="utf-8" ?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document id="root_doc">
<Style id="style1">
<Schema name="pr14" id="pr14">
    <SimpleField name="Description" type="string"></SimpleField>
    <SimpleField name="Nr." type="int"></SimpleField>
    <SimpleField name="Landkreis" type="string"></SimpleField>
    <SimpleField name="Lage (Koordinate X)" type="float"></SimpleField>
    <SimpleField name="Lage (Koordinate Y)" type="float"></SimpleField>
    <SimpleField name="Kapazität" type="string"></SimpleField>
<Folder><name>P+R pr14</name>
    <name>P+R Altenbach</name>
    <ExtendedData><SchemaData schemaUrl="#pr14">
        <SimpleData name="Nr.">1</SimpleData>
        <SimpleData name="Landkreis">LL</SimpleData>
        <SimpleData name="Lage (Koordinate X)">51.356068</SimpleData>
        <SimpleData name="Lage (Koordinate Y)">12.681333</SimpleData>
        <SimpleData name="Kapazität">0</SimpleData>


Now, I would like to display beside of the "name" and "description" field which work fine also the attributes from Extended Data fields.

 var kmllayer2 = new OpenLayers.Layer.Vector("P+R Pl&auml;tze", {
                maxResolution: map.getResolutionForZoom(9),
            strategies: [new OpenLayers.Strategy.Fixed()],
            protocol: new OpenLayers.Protocol.HTTP({
                url: "pr14_1.kml",
                format: new OpenLayers.Format.KML({
                    extractStyles: true,
                    extractAttributes: true,
                    maxDepth: 2

To display the name in my popup I use '+feature.attributes.name+', but I cannot sort out how to modify this to get also the extended data values like 'Kapazität" for example. enter image description here

var controls2 = {
          selector2: new OpenLayers.Control.SelectFeature(kmllayer2, { onSelect: createPopup2, onUnselect: destroyPopup2 })

        function createPopup2(feature) {
          feature.popup = new OpenLayers.Popup.FramedCloud("pop",
              '<div class="markerContent"><h3><font color="004A84">'+feature.attributes.name+'</font></h3></div>',
              function() { controls2['selector2'].unselectAll(); }

          //feature.popup.closeOnMove = true;

        function destroyPopup2(feature) {
          feature.popup = null;

         map.addControl(new OpenLayers.Control.LayerSwitcher({'ascending':false}));


Could you give me a hint?

1 Answer 1


The solution for it is:

+feature.attributes."SimpleData name".value+



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.