[OpenLayers-Users] Selecting polygon error.

samd sdoyle_2 at yahoo.com
Fri Jan 18 19:12:29 EST 2008


Oops sorry, I mean removing the callbacks onSelect and onUnselect still
results in the same error.

S.D.


samd wrote:
> 
> Using the callbacks encounter the same problem.
> 
> There is a difference between yours and mine though in terms of the
> polygons are created as a result of an AJAX callback.
> 
> S.D.
> 
> 
> Eric Lemoine-3 wrote:
>> 
>> On Jan 18, 2008 9:50 AM, Pierre GIRAUD <bluecarto at gmail.com> wrote:
>>> Sorry, I have no clue.
>>>
>>> I tested the following code (adapted from yours) in the
>>> select-feature.html example [1] and it worked great :
>> 
>> That it exactly why I suggested to try with the onSelect and
>> onUnselect callbacks removed. I'm suspecting that there's something
>> that causes the issue in the callbacks.
>> 
>> 
>>> var polygonAreaPoints = [
>>>     new OpenLayers.Geometry.Point(0, 0),
>>>     new OpenLayers.Geometry.Point(10, 0),
>>>     new OpenLayers.Geometry.Point(10, 10),
>>>     new OpenLayers.Geometry.Point(0, 10)
>>> ];
>>> var pointArray = [];
>>> for ( var j = 0; j < polygonAreaPoints.length; j++ )
>>> {
>>>    var x = polygonAreaPoints[j].x;
>>>    var y = polygonAreaPoints[j].y;
>>>
>>>    pointArray.push( new OpenLayers.Geometry.Point( x, y ) );
>>> }
>>>
>>> // Create the linear ring
>>> var ring = new OpenLayers.Geometry.LinearRing( pointArray );
>>>
>>> // Create the polygon
>>> var feature = new OpenLayers.Geometry.Polygon( ring );
>>>
>>> var f = new OpenLayers.Feature.Vector(feature);
>>> map.layers[1].addFeatures( f );
>>>
>>> var polySelected = function() {
>>>     console.log("selected");
>>> }
>>> var polyUnselected = function() {
>>>     console.log("unselected");
>>> }
>>>
>>> selectControl = new OpenLayers.Control.SelectFeature(map.layers[1],
>>>     {hover: true,
>>>     onSelect: polySelected,
>>>     onUnselect: polyUnselected});
>>> map.addControl( selectControl );
>>> selectControl.activate();
>>>
>>>
>>> [1] http://openlayers.org/dev/examples/select-feature.html
>> _______________________________________________
>> Users mailing list
>> Users at openlayers.org
>> http://openlayers.org/mailman/listinfo/users
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Selecting-polygon-error.-tp14946220p14963682.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.




More information about the Users mailing list