<DIV>Dear List!<BR> </DIV>
<DIV>I have got a problem about 'SelectFeature' control.</DIV>
<DIV>There are two gml layers.I want to use two 'SelectFeature' to select them.</DIV>
<DIV>But I found only the SelectFeature control which's gml layer is added last </DIV>
<DIV>will work.</DIV>
<DIV> </DIV>
<DIV>In the code,if I use myMap.addLayers([gmlLayer1,gmlLayer2]),the gml2Control will </DIV>
<DIV>work well,but gml1Control will not work. If I use myMap.addLayers([gmlLayer2,gmlLayer1]), the gml1Control will work well,but gml2 not.</DIV>
<DIV> </DIV>
<DIV>It looks like which gml layer is added last , the select control to it will work.</DIV>
<DIV>Can I use more then one 'SelectFeature' controls to more then one gml layers?</DIV>
<DIV> </DIV>
<DIV>Thank you !</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV><STRONG>My code is:</STRONG><BR></DIV>
<DIV> function init()<BR> { <BR> myMap = new OpenLayers.Map('map3d'); <BR> var opt= {numZoomLevels:1}; <BR> var graphic = new OpenLayers.Layer.Image(<BR> 'name',<BR> '/Images/Maps/chunxi.jpg',<BR> //new OpenLayers.Bounds(-450, -289, 450, 289),<BR> new OpenLayers.Bounds(-320, -240, 320, 240),<BR> new OpenLayers.Size(1600, 1200),<BR> opt); </DIV>
<DIV> <BR> var userstyle = OpenLayers.Util.extend({}, OpenLayers.Feature.Vector.style['userselect']);</DIV>
<DIV><BR> </DIV>
<DIV> //add an image layer<BR> myMap.addLayers([graphic]);</DIV>
<DIV> </DIV>
<DIV> //<STRONG>one gml layer</STRONG></DIV>
<DIV> var gmlOption = {<BR> style:userstyle <BR> }; </DIV>
<DIV> var gmlLayer1= new OpenLayers.Layer.GML("GML1", "url",gmlOption);<BR> <BR> <BR> //<STRONG>another gml layer</STRONG></DIV>
<DIV> var toolTipsOption = {<BR> //style:userstyle<BR> };<BR> var gmlLayer2 = new OpenLayers.Layer.GML("GML2","url",toolTipsOption); </DIV>
<DIV> <BR><FONT color="#f00000"> myMap.addLayers([gmlLayer2,gmlLayer1]);<BR> // myMap.addLayers([gmlLayer1,gmlLayer2]);</FONT><BR> </DIV>
<DIV> </DIV>
<DIV> //<STRONG>one SelectFeature control:gml1Control<BR></STRONG> gml1Control = new OpenLayers.Control.SelectFeature(gmlLayer1,<BR> {onSelect: onFeatureSelect,<BR> onUnselect:onFeatureUnselect,<BR> hover:false<BR> }); <BR> myMap.addControl(gml1Control);<BR> gml1Control.activate(); </DIV>
<DIV> </DIV>
<DIV> //<STRONG>another SelectFeature control:gml2Control<BR></STRONG> gml2Control = new OpenLayers.Control.SelectFeature(gmlLayer2,<BR> {<BR> onSelect:onToolTipsFeatureSelect,<BR> onUnselect:onToolTipsFeatureUnselect,<BR> hover:false<BR> }<BR> );<BR> myMap.addControl(gml2Control );<BR> gml2Control.activate(); </DIV>
<DIV><BR> myMap.setCenter(new OpenLayers.LonLat(0, 0), 1);<BR> myMap.zoomToMaxExtent();<BR> <BR> <BR> } <BR> <BR> function onToolTipsFeatureSelect(feature)<BR> {<BR> alert("onToolTipsFeatureSelect");<BR> }<BR> <BR> function onToolTipsFeatureUnselect(feature)<BR> {<BR> alert("onToolTipsFeatureUnselect");<BR> }<BR> <BR> function onFeatureSelect(feature)<BR> {<BR> alert("onFeatureSelect");<BR> }</DIV><br><!-- footer --><br>
<hr>
<table width="100%%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="50" height="50"><img src="http://proimg.163.com/channel01/4251_10050_0409.jpg" alt="LOGO" width="100" height="50"></td>
<td style="padding:5px;"><a style="font-size:12px;line-height:15px; color:black; text-decoration:none;" href="http://popme.163.com/link/004251_0410_829.html">快来用音乐为奥运加油</a><br /><font style="font-size:12px;line-height:20px;"></font><a style="font-size:12px;line-height:15px; color:blue; text-decoration:underline;" href="http://popme.163.com/link/004251_0410_829.html">得奥运会、演唱会门票</a>
</tr>
</table>