[OpenLayers-Users] FeatureVector and atPoint() function way off. Why??

Tim Schaub tschaub at opengeo.org
Tue Oct 14 15:03:22 EDT 2008


Hey-

Eric Lemoine wrote:
> Hi. atPoint() is an approximation based on the bounds of the geometry.
> Instead you can use poly.containsPoint(point), where point is a
> Geometry.Point object derived from the LonLat object. Eric

Or, sticking with the API:

poly.intersects(point)

which is equivalent to

point.intersects(poly)

Tim

> 
> 2008/10/14, plen <peteralen at earthlink.net>:
>> Hello,
>>
>> I have created some polygons through the DrawFeature and saw that there is
>> an atPoint() for both the OpenLayers.Feature.Vector and the feature vectors
>> geometry property.  When I register a click event for the map, I get the
>> lat/long for the point clicked via:
>>
>> map.events.register("click", map, function(e) {
>>    var lonlat = map.getLonLatFromViewPortPx(e.xy);
>>    ....
>> }
>>
>> When I use that lonlat to see if the click was on one of my features, I do
>> the following for each of my features:
>>
>> if (feature.atPoint(lonlat)) {
>>   ......
>> }
>>
>> The problem is that the statement is true even when I click well outside of
>> any of the features.  It typically is "true" whenever I click inside the
>> features, but it also is true in alot of areas outside as well.
>>
>> Does anyone know why this is?  I see that there is some optional tolerance
>> parameters for the atPoint() function, but I dont know what those values
>> would be.  Is there some trick to getting this function to work properly or
>> is a crap shoot.
>>
>> Thanks for any insight - Peter
>> --
>> View this message in context:
>> http://www.nabble.com/FeatureVector-and-atPoint%28%29-function-way-off.-Why---tp19966398p19966398.html
>> Sent from the OpenLayers Users mailing list archive at Nabble.com.
>>
>> _______________________________________________
>> Users mailing list
>> Users at openlayers.org
>> http://openlayers.org/mailman/listinfo/users
>>
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users


-- 
Tim Schaub
OpenGeo - http://opengeo.org
Expert service straight from the developers.



More information about the Users mailing list