[OpenLayers-Users] Problems to obtain feature value
fsalas
fsalas at geocuba.cu
Wed Sep 23 13:04:38 EDT 2009
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?
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20090923/d50718da/attachment.html
More information about the Users
mailing list