Hi Robert,<br><br>Thank you for your reply! I have a very similar way to load the geoJSON file and handle the controls outside map div. Except that I put part of code for loading geoJSON in a function: I want only one GeoJSON layer in which I load/switch an indeterminate number of GeoJSON files. This part is working well.<br>
<br>
In this project I have actually two vector layers: One which is used just for drawing things on map (temporarily) and the other one which is the GeoJSON layer. For both vector layers I've declared distinct SelectFeature controls with intention of calling a "featureinfo" function. Beside this I include a draw polygon and delete feature control (the last one is again a SelectFeature control actually). It seems that functionality was affected by the way I have declared the controls, and one of the controls "did not like" going with the others.<br>
<br>In the end I found a "solution" and the thing is working now. I currently have no idea why it did not work and why is now working. But I am happy with the result.<br>See below two code versions of how I declare controls:<br>
<br>example 1 :<br>controls = {<br> polygon: new OpenLayers.Control.DrawFeature(vectors,OpenLayers.Handler.Polygon),<br> polygoninfo: new OpenLayers.Control.SelectFeature(vectors, {hover: true, onSelect: serialize}),<br>
<span style="color: rgb(0, 102, 0);">deletepolygon: new OpenLayers.Control.SelectFeature(vectors, {callbacks: {'click': deleteFeature}}),</span><br> regioninfo: new OpenLayers.Control.SelectFeature(regions, {callbacks: {'click': serialize}})<br>
};<br><br>example 1 is not working: delete and select functions do not work for both vector layers (vectors and regions). only draw polygon works corectly.<br><br>example 2:<br>controls = {<br>
polygon: new OpenLayers.Control.DrawFeature(vectors,OpenLayers.Handler.Polygon),<br>
};<br><br>var polygoninfo = new OpenLayers.Control.SelectFeature(vectors, {hover: true, onSelect: serialize});<br>
<span style="color: rgb(0, 102, 0);">var deletepolygon = new OpenLayers.Control.SelectFeature(vectors, {callbacks: {'click': deleteFeature}});</span><br>
var regioninfo = new OpenLayers.Control.SelectFeature(regions, {callbacks: {'click': serialize}});<br><br>map.addControl(polygoninfo);<br>polygoninfo.activate();<br><span style="color: rgb(0, 102, 0);">map.addControl(deletepolygon);</span><br style="color: rgb(0, 102, 0);">
<span style="color: rgb(0, 102, 0);">deletepolygon.activate();</span><br>map.addControl(regioninfo);<br>
regioninfo.activate();<br><br>example 2 is working only partially. All controls work except regioninfo.<br><br>example 3:<br>controls = {<br>
polygon: new OpenLayers.Control.DrawFeature(vectors,OpenLayers.Handler.Polygon),<br>
polygoninfo: new OpenLayers.Control.SelectFeature(vectors, {hover: true, onSelect: serialize}),<span style="color: rgb(0, 102, 0);"></span><br>
regioninfo: new OpenLayers.Control.SelectFeature(regions, {callbacks: {'click': serialize}})<br>
};<br><br><span style="color: rgb(0, 102, 0);">var deletepolygon = new OpenLayers.Control.SelectFeature(vectors, {callbacks: {'click': deleteFeature}});</span><br><span style="color: rgb(0, 102, 0);">map.addControl(deletepolygon);</span><br style="color: rgb(0, 102, 0);">
<span style="color: rgb(0, 102, 0);">deletepolygon.activate();<br><br><span style="color: rgb(0, 0, 0);">example 3 is working well. all functions are doing what they are supposed to do. Personally I would prefer version 1 of code. However, since version 3 does the job I am glad that I could pass this point. It must be something I do wrong when I declare callbacks or...I don't know....<br>
<br>Thank you again for your input,<br>Adorian<br></span></span><br>-- <br>Dr. Adorian Ardelean<br>coordinator of myNature Project<br><br><a href="http://mybiosis.info/nature/portal.php?pagename=firstpage">http://mybiosis.info/nature/portal.php?pagename=firstpage</a> [a Romanian biodiversity-database]<br>
<a href="http://mybiosis.info/nature/portal.php?pagename=adorian">http://mybiosis.info/nature/portal.php?pagename=adorian</a> [CV]<br>