[OpenLayers-Users] Point in polygon

helmi helmi03 at gmail.com
Wed Nov 4 01:55:53 EST 2009


>>The error returned is *polygonFeature.intersects* is not a function
have you tried polygonFeature.geometry.intersects() instead?

On Wed, Nov 4, 2009 at 1:45 PM, Brad Spencer <brad at cubewerx.com.au> wrote:

>  Guys, I have created a vector polygon as follows:
>
>
>
> var parcel01 = new OpenLayers.Geometry.LinearRing(pointList);
>
> polygonFeature = new OpenLayers.Feature.Vector( new
> OpenLayers.Geometry.Polygon([parcel01]));
>
> vectorLayer.addFeatures([polygonFeature]);
>
>
>
> I then am parsing a list of external points to include only those that are
> inside the polygon on the map as vector markers.
>
>
>
> I have tried the following with no success:
>
>
>
> If (polygonFeature.intersects(new OpenLayers.Geometry.Point(p[0], p[1])))
> {// include code…}
>
> and
>
> If (polygonFeature.containsPoint(new OpenLayers.Geometry.Point(p[0],
> p[1]))) {// include code…}
>
>
>
> Where p[0] = x-coords in Sphericalmercator
>
> And p[1] = y-coord in SphericalMercator.
>
>
>
> The error returned is *polygonFeature.intersects* is not a function. I can
> verify that the polygon is being created.
>
>
>
> Is there something I am missing here? I am using OL version 2.8.
>
>
>
> Does anyone have a simple example of point-in-polygon working?
>
>
>
> Cheers,
>
>
>
>
>
> *Brad Spencer*
>
> General Manager
>
> NuMaps
>
> tel: 02 9481 7024
>
> mob: 0404 841 131
>
> www.numaps.com.au
>
> brad at numaps.com.au
>
>
>
>
>
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20091104/8f04c406/attachment.html


More information about the Users mailing list