[OpenLayers-Users] possible issue in wfs markers...
Cicconetti, Bob
BCicconetti at dnr.state.md.us
Wed Apr 11 10:05:15 EDT 2007
It appears that yesterday the vector callbacks in SVN head stopped
passing geometries, but instead sent features.
Before I'd get, say, OpenLayers.Geometry.Polygon passed in; after
yesterday I'd get OpenLayers.Feature.Vector.
If you need to get at the geometry, use feature.geometry. This isn't on
a public facing server, unfortunately, but I can give some snippets.
For ex:
var vlayer = new OpenLayers.Layer.Vector("Editable");
map.addLayer(vlayer);
// Extend the edit tool bar to allow deleting features, and gather
// info about them.
var selectTool = new OpenLayers.Control.SelectFeature(vlayer,
{
onSelect:feature_info,
onUnselect:clear_feature_info
});
[...]
function feature_info(feature) {
//Extend to allow string length as well.
if (feature.geometry.CLASS_NAME == "OpenLayers.Geometry.Polygon")
{
var str = feature.geometry.getArea();
// Assume units are meters, for now.
// Magic numbers are evil, but ah well.
var sqft = str / 0.09290304;
var acres = str / 4046.856422;
// FIXME: Round and truncate. 8 sig figs?
if (sqft < 4000)
str = "Area: (sq ft.) " + sqft;
else
str = "Area: (acres) " + acres;
document.getElementById('area').innerHTML = str;
}
else if (feature.geometry.CLASS_NAME ==
"OpenLayers.Geometry.LineString")
{
var str = feature.geometry.getLength();
var feet = str / 0.3048;
var miles = str / 1609.344;
if (feet < 2000)
str = "Length: (feet) " + feet;
else
str = "Length: (miles) " + miles;
document.getElementById('area').innerHTML = str;
}
}
[...]
function deleteFeature(feature) {
this.unselect(feature);
// this.layer.removeFeatures(geometry.feature);
this.layer.removeFeatures(feature);
}
-----Original Message-----
From: users-bounces at openlayers.org [mailto:users-bounces at openlayers.org]
On Behalf Of Christopher Schmidt
Sent: Tuesday, April 10, 2007 7:29 PM
To: Stephen Woodbridge
Cc: openlayers
Subject: Re: [OpenLayers-Users] possible issue in wfs markers...
On Tue, Apr 10, 2007 at 06:59:20PM -0400, Stephen Woodbridge wrote:
> Erik,
>
> I just updated my copy of trunk, but I seem to have another problem
> unrelated to John's where the hover over the features is no longer
> displaying the feature.attributes. I don't know when this broke, but
it
> was working after the 2.4 merge was integrated into the trunk.
>
> http://imaptools.com/ld-testv.html
> click the link for Algers, DZ and hovering over any of the orange
> feature circles should display the attributes on the left side of the
page.
geometry no longer has a feature property. openmnnd demo has been
updated. You probably need something like:
function feature_info_hover(feature) {
if (displayedFeature != feature &&
(!feature.layer.selectedFeatures.length ||
(feature.layer.selectedFeatures[0] == feature))) {
feature_info(feature);
displayedFeature = feature;
}
}
function feature_info(feature) {
var html = "<ul>";
for(var i in feature.attributes)
html += "<li><b>" + i + "</b>: "+ feature.attributes[i]
+ "</li>";
html += "</ul>";
$('feature_info').innerHTML = html;
}
To do what you were doing before.
-- Chris
_______________________________________________
Users mailing list
Users at openlayers.org
http://openlayers.org/mailman/listinfo/users
More information about the Users
mailing list