Ticket #2281 (new bug)

Opened 4 years ago

Last modified 3 years ago

Vector style disapearing on zoom

Reported by: Andre Steenveld Owned by: crschmidt
Priority: minor Milestone: 2.13 Release
Component: Layer.Vector Version: 2.8
Keywords: Vector zoom Cc: ivan.grcic@…
State: Awaiting User Feedback

Description

When clicking on a feature it is possible to select it using the penLayers.Control.SelectFeature control. This also changes the style of the vector (in my test case makes it blue instead of orange). But when a vector is selected and you zoom OL the selected style is replaced by the default style again, although it is still selected.

Test case:  http://bonsai.nmpo.nl/experiments/mapclick.html

Tested in IE8, IE7 (emulation), Opera 10, FF 3.5

Attachments

openlayers-2281.patch Download (1.6 KB) - added by ahocevar 4 years ago.
store original styles

Change History

Changed 4 years ago by ahocevar

  • state set to Awaiting User Feedback

Not sure if this should be classified a bug. Using feature styles is discuouraged in favor of layer level style maps. You can make your application work by making the following changes:

Replace lines 39-41 with

					vectors   = new OpenLayers.Layer.Vector( "Lijntjes", { 
						styleMap: new OpenLayers.StyleMap({
                                                    "default": unselectedStyle,
                                                    "select": selectedStyle
                                                }
					});

Replace lines 285-302 with:

				setTimeout( function( ){
					var bounds     = new OpenLayers.Bounds( );
					
					dojo.forEach( features, function( feature ){
						bounds.extend( feature.geometry.getBounds( ) );
						
						// Is selected stuffs
						feature.fid in selection
							& feature.renderIntent = "select";
					});
					 		
					map.zoomToExtent( bounds );
					vectors.addFeatures( features );
				}, 1 );

Please close this ticket if the proposed solution works for you, otherwise report.

Changed 4 years ago by ahocevar

You can also try the attached patch. In case we agree that the reported behavior is a bug (well, at least Control.SelectFeature.selectStyle does not work as advertised), that patch could be a starting point for a fix.

Changed 4 years ago by ahocevar

store original styles

Changed 4 years ago by Andre Steenveld

Thanks for the quick reply I will try your patch and suggested changes over the weekend. If it turns out being a bug or undesired behavior i can also try to write up a bug fix using your patch as a starting point.

Changed 3 years ago by igrcic

Hi Andrea,

patch patch doesnt resolve problem when selectStyle is being used. Upon selection feature is rendered with desired selectStyle style, but upon zoom change (redrawing) feature is reneder back again to its style. I have similar problem, will report more when i find out...cheers

Changed 3 years ago by igrcic

  • cc ivan.grcic@… added
  • summary changed from Vector style disapearing on zoom to Vector selected style lost on zoom

May I propose to change the title to something like : Vector select style lost on zoom

Changed 3 years ago by igrcic

  • summary changed from Vector selected style lost on zoom to Vector style disapearing on zoom
Note: See TracTickets for help on using tickets.