<blockquote>
<span class="hps">Good morning.</span><p style="margin: 0px; padding: 0px;" mce_style="margin: 0px; padding: 0px;"><span id="result_box" class="" lang="en"> <span class="hps">I have a</span> <span class="hps">problem</span> <span class="hps">with the controls and</span> <span class="hps">SelectFeature</span> <span class="hps">ModifyFeature</span>.<br> <span class="hps">If I edit</span> <span class="hps">a feature</span> <span class="hps">and I click</span> <span class="hps">outside</span> <span class="hps">of the same feature</span>, the <span class="hps">selection control</span> <span class="hps">does not trigger</span> <span class="hps">more</span> <span class="hps">events</span>.<br> <span class="hps">I</span> <span class="hps">tried to update</span> <span class="hps">to</span> <span class="hps">new</span> <span class="hps">version of</span> <span class="hps">OpenLayers</span> <span class="hps">2.12,</span> <span class="hps">but this</span> <span class="hps">does not work</span> <span class="hps">no more. </span></span></p><p style="margin: 0px; padding: 0px;" mce_style="margin: 0px; padding: 0px;"><span class="" lang="en"><span class="hps">This is my code:</span></span></p><p style="margin: 0px; padding: 0px;" mce_style="margin: 0px; padding: 0px;"><span class="" lang="en"><span class="hps"><span style="font-size: small;" mce_style="font-size: small;"> <span style="font-family: courier new,courier;" mce_style="font-family: courier new,courier;">var map_overlays = [];<br>var map, vectorLayer;<br><br>var out_options = {<br> 'internalProjection': new OpenLayers.Projection("EPSG:900913"),<br> 'externalProjection': new OpenLayers.Projection("EPSG:4326")<br> };<br>var format = new OpenLayers.Format.WKT(out_options);<br><br>var lat=41.932<br>var lon=12.420<br>var zoom=6<br><br>function onPopupClose(evt) {<br> selectControl.unselect(selectedFeature);<br>}<br>function onFeatureSelect(feature) {<br> selectedFeature = feature;<br> popup = new OpenLayers.Popup.FramedCloud("chicken",<br> feature.geometry.getBounds().getCenterLonLat(),<br> null,<br> 'Nome oggetto: <input id=\'name_polygon\' value="'+nome_poligono+'">',<br> null, true, onPopupClose);<br> feature.popup = popup;<br> map.addPopup(popup);<br>}<br>function onFeatureUnselect(feature) {<br> map.removePopup(feature.popup);<br> feature.popup.destroy();<br> feature.popup = null;<br>} <br><br>var DeleteFeature = OpenLayers.Class(OpenLayers.Control, {<br> initialize: function(layer, options) {<br> OpenLayers.Control.prototype.initialize.apply(this, [options]);<br> this.layer = layer;<br> this.handler = new OpenLayers.Handler.Feature(<br> this, layer, {click: this.clickFeature}<br> );<br> },<br> clickFeature: function(feature) {<br> // if feature doesn't have a fid, destroy it<br> if(feature.id == undefined) {<br> this.layer.destroyFeatures([feature]);<br> } else {<br> feature.state = OpenLayers.State.DELETE;<br> this.layer.events.triggerEvent("afterfeaturemodified", <br> {feature: feature});<br> feature.renderIntent = "select";<br> this.layer.drawFeature(feature);<br> }<br> },<br> setMap: function(map) {<br> this.handler.setMap(map);<br> OpenLayers.Control.prototype.setMap.apply(this, arguments);<br> },<br> CLASS_NAME: "OpenLayers.Control.DeleteFeature"<br>});<br><br>var SaveFeature = OpenLayers.Class(OpenLayers.Control, {<br> initialize: function(layer, options) {<br> OpenLayers.Control.prototype.initialize.apply(this, [options]);<br> this.layer = layer;<br> this.handler = new OpenLayers.Handler.Feature(<br> this, layer, {click: this.clickFeature}<br> );<br> },<br> clickFeature: function(feature){<br> serialize(feature);<br> if(feature.inserted == OpenLayers.State.INSERT){<br> if (!feature.style) {<br> feature.style = OpenLayers.Util.extend({}, <br> OpenLayers.Feature.Vector.style["default"]);<br> }<br> feature.style.fillColor = "#FF0000";<br> this.layer.redraw();<br> }<br> },<br> setMap: function(map) {<br> this.handler.setMap(map);<br> OpenLayers.Control.prototype.setMap.apply(this, arguments);<br> },<br> CLASS_NAME: "OpenLayers.Control.SaveFeature"<br>});<br><br><br>var size = new OpenLayers.Size(21,25);<br>var offset = new OpenLayers.Pixel(-(size.w/2), -size.h);<br>var icon = new OpenLayers.Icon('<a href="http://www.openlayers.org/dev/img/marker-blue.png" mce_href="http://www.openlayers.org/dev/img/marker-blue.png">http://www.openlayers.org/dev/img/marker-blue.png</a>', size, offset);<br>var markers;<br><br> <br>// ***<br>// *** Map<br>// ***<br>function map_init() {<br> map = new OpenLayers.Map ("map", {<br> controls:[ <br> new OpenLayers.Control.Navigation(),<br> new OpenLayers.Control.PanZoomBar(),<br> new OpenLayers.Control.ScaleLine(),<br> new OpenLayers.Control.Permalink('permalink'),<br> new OpenLayers.Control.MousePosition(), <br> new OpenLayers.Control.Attribution()<br> ],<br> maxExtent: new OpenLayers.Bounds(-20037508.34,-20037508.34,20037508.34,20037508.34),<br> maxResolution: 156543.0399,<br> numZoomLevels: 19,<br> units: 'm',<br> projection: new OpenLayers.Projection("EPSG:900913"),<br> displayProjection: new OpenLayers.Projection("EPSG:4326")<br> } );<br> <br> var wmsLayer = new OpenLayers.Layer.WMS("OpenLayers WMS", "<a href="http://vmap0.tiles.osgeo.org/wms/vmap0" mce_href="http://vmap0.tiles.osgeo.org/wms/vmap0">http://vmap0.tiles.osgeo.org/wms/vmap0</a>", {layers:"basic"});<br> <br> // Google Layers <br> var gmap = new OpenLayers.Layer.Google("Google Map", {sphericalMercator:true, numZoomLevels: 21});<br>
var gphy = new OpenLayers.Layer.Google("Google Physical", {type:
google.maps.MapTypeId.TERRAIN,sphericalMercator:true, numZoomLevels: 16}
);<br> var gsat = new OpenLayers.Layer.Google("Google
Satellite", {type: google.maps.MapTypeId.SATELLITE,
sphericalMercator:true,numZoomLevels: 21} );<br> <br> // Bing Maps layers<br>
var aerial = new OpenLayers.Layer.VirtualEarth("Bing
Satellite", {type: VEMapStyle.Aerial, sphericalMercator:true,
numZoomLevels: 19});<br> var shaded = new
OpenLayers.Layer.VirtualEarth("Bing Map", {type: VEMapStyle.Shaded,
sphericalMercator:true, numZoomLevels: 21});<br> <br> // Yahoo layers<br>
var yahoosat = new OpenLayers.Layer.Yahoo("Yahoo
Satellite",{'type': YAHOO_MAP_SAT, 'sphericalMercator': true,
numZoomLevels:18 });<br> var yahoostreet = new OpenLayers.Layer.Yahoo( "Yahoo Street", { 'sphericalMercator': true, numZoomLevels:18 } );<br> <br> vectorLayer = new OpenLayers.Layer.Vector("Poligoni", {sphericalMercator:true});<br> <br> markers = new OpenLayers.Layer.Markers( "Markers" , {sphericalMercator:true});<br><br> <br> map.addLayers([ gmap,gphy,gsat,yahoosat,yahoostreet,aerial,shaded,wmsLayer,markers,vectorLayer ] );<br> <br> <br> selectControl = new OpenLayers.Control.SelectFeature(vectorLayer,<br> {onSelect: onFeatureSelect, onUnselect: onFeatureUnselect, clickout: true});<br> map.addControl(selectControl);<br> selectControl.activate();<br> <br> vectorLayer.events.on({<br> 'beforefeaturemodified': function(evt) {<br> console.log("Selected " + evt.feature.id + " for modification");<br> },<br> 'afterfeaturemodified': function(evt) {<br> if(is_int(evt.feature.id)){<br> if(evt.feature.state == OpenLayers.State.DELETE){<br> delete_stored_feature_polygon(evt.feature.id);<br> } <br> else {<br> var str = format.write(evt.feature);<br> modify_stored_feature_polygon(str, evt.feature.id);<br> }<br> }<br> }<br> });<br> <br> var panel = new OpenLayers.Control.Panel({<br> displayClass: 'customEditingToolbar',<br> allowDepress: true<br> });<br> <br> var draw = new OpenLayers.Control.DrawFeature(<br> vectorLayer, OpenLayers.Handler.Polygon,<br> {<br> title: "Draw Feature",<br> displayClass: "olControlDrawFeaturePolygon",<br> }<br> );<br> <br> var edit = new OpenLayers.Control.ModifyFeature(vectorLayer, {<br> title: "Modify Feature",<br> displayClass: "olControlModifyFeature",<br> stopSingle: false<br> });<br><br> var del = new DeleteFeature(vectorLayer, {<br> title: "Delete Feature",<br> displayClass: "olControlDeleteFeature"<br> });<br> <br> var save = new SaveFeature(vectorLayer, {<br> title: "Save Feature",<br> displayClass: "olControlSaveFeature"<br> });<br> <br> var navControl = new OpenLayers.Control.Navigation({title: 'Pan/Zoom'});<br><br> panel.addControls([del, save, draw, edit, navControl]);<br> panel.defaultControl = navControl;<br> map.addControl(panel);<br> <br> <br> map.addControl(new OpenLayers.Control.LayerSwitcher());<br><br><br> <br> var lonLat = new OpenLayers.LonLat( lon ,lat )<br> .transform(<br> new OpenLayers.Projection("EPSG:4326"), // transform from WGS 1984<br> map.getProjectionObject() // to Spherical Mercator Projection<br> );<br> <br> <br> map.setCenter (lonLat, zoom); <br>}</span></span></span></span></p><p style="margin: 0px; padding: 0px;" mce_style="margin: 0px; padding: 0px;"><br></p><p style="margin: 0px; padding: 0px;" mce_style="margin: 0px; padding: 0px;">Where is the problem?</p><p>Thanks in advance</p><div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow: hidden;" id="_mcePaste"> </div><br>
</blockquote><p><br></p>