Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to do the following: add

metadata: "this is the layer metadata" my openlayers layer config.

This should then be presented in an extjs grid. I can use


to display the string inside the config member so I know it works.

To display this in the extjs grid I have used the following code

var myData = [];
for (var i=0; i<x.length; i++) {
  // alert([i].metadata);

var store = new{
        fields: [
           {name: 'metadata'}


var myStore = new{
    map: map,
    layers: mapPanel.layers

var grid = new Ext.grid.GridPanel({
        title: "Available Map Layers",
        region: "center",
        height: 300,
        viewConfig: {forceFit: true},
        store: store,
        columns: [
                header: "metadata",
                dataIndex: "metadata",
                sortable: true

var metadataWin = new Ext.Window({
                title: "Map layers",
                layout: 'fit',
                width: '600',
                height: 'auto',
                border: false,
                closable: true,
                collapsible: true,
                x: 450,
                y: 100,
                resizable: true,
                closeAction: 'hide',
                plain: true,
                items: [grid]

the grid show the correct amount of rows, but only the first letter is shown....this is probably a newbie javascript error.

Can anyone see where i´m going wrong?



share|improve this question
up vote 2 down vote accepted

i have done adding this metadata with this following code:

var vectorLayer = new OpenLayers.Layer.Vector("Building", {
    stylemap: styles,
    visibility: false,
    rangeOfZoom: '9-12',
    metadata: 'write What you Want'


and you can reach all layer's metadata as ...:

var layers = map.layers;
for(var a = 0; a < layers.length; a++){

i hope it helps you

share|improve this answer
Thanks for the tip. I have basically come up with the same thing but instead of displaying the metadata in an alert I would like to build an array and display them using an ext.grid – Robert Buckley Mar 27 '12 at 10:04

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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