ThinkGeo.com    |     Documentation    |     Premium Support

ExtentChanged Event - Slow And Breaks Zoom

I've added the following code to allow for different features to be highlighted as a person zooms in/out.



Protected Sub Map1_ExtentChanged(ByVal sender As Object, ByVal e As ThinkGeo.MapSuite.WebEdition.ExtentChangedEventArgs) Handles Map1.ExtentChanged
    Dim tmpOverlay As LayerOverlay
    If Map1.CurrentScale > 300000 Then
      tmpOverlay = Map1.CustomOverlays("Township")
      SetHighlights(0, tmpOverlay.Layers("Township"))
    Else
      tmpOverlay = Map1.CustomOverlays("Quarter")
      SetHighlights(1, tmpOverlay.Layers("Quarter"))
    End If
  End Sub


 Now, when I zoom out, everything goes white first, then it redraws. Unless I'm trying to zoom in, in which case it zooms out.

VERY annoying.


If I comment out the code and just leave the empty event handler, it stills does the same thing.

Is there a Parent handler I need to call or something?



When you change the style of the LayerOverlay, the following code should call to redraw the LayerOverlay. 
 Map1.CustomOverlays("Quarter").Redraw() 
  
 For your case, it’s better to set different styles in different zoom levels on the layers, in this way, you can get better performance and don’t need post back anymore. 


That's a lovely idea except I'm not doing anything with styles at all. 

I'm clearing the Map1.HighlightOverlay.Features and adding new ones for greater detail. 

But even if I remove THAT code too, if ALL I do is add a Map1.ExtentChanged event handler, the same problem occurs. 

Now I did notice that if I drop the Google map layer, the zoom isn't a problem, but the redraw still is.


P.S. I could not get Visual Studio to recognize the Redraw function. Says it doesn't exist.



There is a performance consideration when using HighlightOverlay - The HighlightOverlay will serialize all its features to the client for drawing. This might cost much time if the features have much vertices.  
 I think use the DynamicOverlay for highlighting might be better.

Ray, 
  
   I completely agree with you.  The HighlightOverlay is just intended for highlights while you move your mouse over the feature on the client.  For static highlights the server side rendering is the way to go. 
  
 David