Method for getting both feature id and data.

Having to call two methods to get complete feature information (id and data) is cumbersome.  The `getFeatureInfo` method returns an object with both feature id and data.
This commit is contained in:
Tim Schaub
2012-02-28 05:37:28 -07:00
parent 19a11561e8
commit 4d31a3ed3a
6 changed files with 75 additions and 54 deletions

View File

@@ -8,8 +8,8 @@
<link rel="stylesheet" href="style.css" type="text/css">
<script src="../lib/OpenLayers.js"></script>
<style>
#attrsdiv {
float: right;
#attrs {
height: 1.5em;
}
#controlToggle li { list-style: none; }
</style>
@@ -21,11 +21,11 @@
<div id="shortdesc">
This page demonstrates the use of the OpenLayers UTFGrid Controls.
</div>
<div id="attrsdiv"></div>
<div id="themap" class="smallmap"></div>
<p>
When the selected event is triggered, the underlying feature attributes are shown below.
</p>
<div id="attrs">&nbsp;</div>
<ul id="controlToggle">
<li>
<input type="radio" name="type" value="move" id="moveHandler"
@@ -71,20 +71,21 @@
/*
* Controls
*/
var callback = function(dataLookup) {
var callback = function(infoLookup) {
var msg = "";
if (dataLookup) {
var data;
for (var idx in dataLookup) {
if (infoLookup) {
var info;
for (var idx in infoLookup) {
// idx can be used to retrieve layer from map.layers[idx]
data = dataLookup[idx];
if (data) {
msg += "<strong>In 2005, " + data.NAME + " had a population of " +
data.POP2005 + " people.</strong> ";
info = infoLookup[idx];
if (info && info.data) {
msg += "[" + info.id + "] <strong>In 2005, " +
info.data.NAME + " had a population of " +
info.data.POP2005 + " people.</strong> ";
}
}
}
document.getElementById("attrsdiv").innerHTML = msg;
document.getElementById("attrs").innerHTML = msg;
};
var controls = {