[OpenLayers-Users] containsPoint() Help por favor
Marc Jansen
jansen at terrestris.de
Sat Oct 10 07:45:41 EDT 2009
Hi Jesse,
containsPoint is a method of (polygon-)geometries, not of features that
have this geometry. Something like this should work
// you can test this in Firebug when
// you're on the page
// http://openlayers.org/dev/examples/editingtoolbar.html
// the point-geometry to check
// in my case the feature 1 was the point I digitized
var p = map.layers[1].features[1].geometry;
for(var i = 0; i < map.layers[1].features.length; i++) {
// check if method containsPoint exists, and if so, check f point
is in the geometry
if(map.layers[1].features[i].geometry.containsPoint &&
map.layers[1].features[i].geometry.containsPoint(p)) {
alert('yes, point contained');
} else {
alert('no, point not contained or containsPoint-method not
defined');
}
}
Regards,
Marc
Jesse Bushkar schrieb:
> I need some help with containsPoint(). I have a variable (myLoc) that
> represents a given point on the map on one layer. Tthe features I'm
> trying to monitor are polygons, so I think I could just use the
> containsPoint function mixed with a for loop for each feature. Does
> that make sense? Also, would it matter that my starting point and the
> other polygons are on different layers?
>
> Something like:
>
>
> var isHere;
>
> for (var i = 0; i < layer.features; i++) {
> isHere = layer.feature[i].
> containsPoint(myLoc);
> if (isHere = TRUE) {
> alert('true');
> }
> }
>
> am I way off?
>
>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>
More information about the Users
mailing list