Select to view content in your preferred language

FeatureLayer graphics not zooming

673
1
03-07-2011 12:01 PM
RobertRoyall
Deactivated User
I'm having an intermittent issue with some FeatureLayer functionality and I'm wondering if this is an ESRI bug, and Flash bug, or something in between.

In my application I'm creating a FeatureLayer in code based on 9.3.1 MapServer url in a configuration file.  This layer is added to the map with visible=false.  After creating and adding the layer, I'm calling a method in an ASP.NET MVC project that has a list of project IDs corresponding to values in a certain field in the map service.  This MVC method returns a JSON object that gets decoded into an Actionscript object in the client side viewer and is used to create a UniqueValueRenderer that sorts out the features by the ID field.  (e.g. there are three categories, features with IDs 1-10 belong in the first category, 11-15 in the second, and 16-25 in the third.)  Each category sets the renderer to use a PictureMarkerSymbol that is a .png file in the project.  Once the renderer is created and assigned to the FeatureLayer, the layer is set visible=true.

At this point the symbols are displayed on the map, but very randomly and intermittently, when you zoom in or out on the map, the symbols on one or more layers get "stuck" and won't zoom to their correct spots on the map when the rest of the map repaints.  They move the correct distance when panning, but they never "snap back" to their correct locations.  The associated Graphic objects know their correct map locations because clicking on one of the features passes the associated MapPoint to a handler that pops up a custom InfoWindow.  The popup displays at the correct map location but the feature icon does not.  This issue affects all three major browser engines (Firefox 3.6, IE7/IE8, latest Chrome) on Flash Player 10.1 and 10.2.

According to the API docs, Layer (and any object inheriting from it) hooks four events published by Map - Extent Change, Zoom Start, Zoom Update, and Zoom End; these handlers are added when the layer is set to visible=true, and removed when the layer is set to visible=false.  It appears in our case that Extent Change is working correctly (panning the map) but some or all of the Zoom events are not being handled by the FeatureLayer.

The only workaround we've been able to come up with is, rather than creating the FeatureLayer in code with visible=false, we're creating it with alpha=0.  This allows the layer to hook the map events immediately when added to the map, rather than waiting until after the UniqueValueRenderer has been applied.

Has anyone ever run into this issue before?  Is there something wonky about adding a renderer to a FeatureLayer after adding the layer to the map?
Tags (2)
0 Kudos
1 Reply
AnthonyVandrunen
Emerging Contributor
I've had this same problem happen to me with GraphicsLayers. The solution seemed to be to add the layer to the map first, then set visible to false (instead of setting visible to false before adding, which produced the zooming issue).
0 Kudos