[OpenLayers-Users] Problems to obtain feature value

Christopher Schmidt crschmidt at metacarta.com
Wed Sep 23 12:15:56 EDT 2009


On Wed, Sep 23, 2009 at 12:04:38PM -0500, fsalas wrote:
> Hi, all
> 
> I have following problem:
> 
> I am trying to obtain the value of a field, but is null
> 
> is The variable features.length is zero, how can I resolv this problem?

My guess is that your'e not returning GML from your GetFeatureInfo.
Did you check what youer' returning via console.log or some such?

-- Chris

> 
> function setHTML(response) {
>         var format = new OpenLayers.Format.GML();
>         var features = format.read(response.responseXML || response.responseText);
>          for (var i=0, len=features.length; i<len; i++) {
>                 var feature = features[i];
>                 for (attribute in feature.attributes) {
>                     var value = feature.attributes[attribute];
>                     console.log(attribute + ": " + value);
>                 }
>           }
> }
> 
> 
>    tiled = new OpenLayers.Layer.WMS(
>                 "topp:cuba - Tiled", "http://deltha:8080/geoserver/wms",
>                 {
>                     width: '800',
>                     srs: 'EPSG:4267',
>                     layers: 'topp:cuba',
>                     height: '300',
>                     styles: '',
>                     format: 'image/png',
>                     tiled: 'true',
>                     tilesOrigin : "-86.09241054242432,19.388371083287836"
>                 },
>                 {buffer: 0} 
>             );
> 
> 
>       // support GetFeatureInfo
>             map.events.register('click', map, function (e) {
>                 document.getElementById('nodelist').innerHTML = "Loading... please wait...";
>                 var url =  map.layers[0].getFullRequestString(
>                     {
>                         REQUEST: "GetFeatureInfo",
>                         EXCEPTIONS: "application/vnd.ogc.se_xml",
>                         BBOX: map.getExtent().toBBOX(),
>                         X: e.xy.x,
>                         Y: e.xy.y,
>                         INFO_FORMAT: 'application/vnd.ogc.se_xml',
>                         QUERY_LAYERS: map.layers[0].params.LAYERS,
>                         FEATURE_COUNT: 50,
>                         WIDTH: map.size.w,
>                         HEIGHT: map.size.h
>                     },
>                     "http://deltha:8080/geoserver/wms"
>                 );
>                 OpenLayers.loadURL(url, '', this, setHTML, setHTML);
>                 OpenLayers.Event.stop(e);
>             });
> 
> ___________________________________
> Dirección de Comunicaciones
> Grupo Empresarial GEOCUBA
> Este mensaje esta libre de virus. 
> Revisado por Kaspersky Antivirus
> ----------------------------------------------------------------------
> Definition count:  2618974
> Definition date:  9/23/2009
> SecurityPlus version: 3.0.5
> 

> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users


-- 
Christopher Schmidt
MetaCarta



More information about the Users mailing list