ThinkGeo.com    |     Documentation    |     Premium Support

Incorporating Locus Map with box showing viewable extent

I am able to create a box represent my viewable extent correctly, but I was curious if there was a way to disable zooming and panning by any chance?


Edit: Also, when incorporating the following code, I find sometime I end up with remnants of the feature left on the Locus but the performance of using .Refresh instead of .RefreshDynamic is very bad:


    Private Sub mapViewer_CurrentExtentChanged(ByVal sender As Object, ByVal e As ThinkGeo.MapSuite.DesktopEdition.CurrentExtentChangedEventArgs) Handles mapViewer.CurrentExtentChanged
        Dim rectEnvelope As RectangleShape = mapViewer.CurrentExtent.GetBoundingBox
        Dim layerViewPort As New InMemoryFeatureLayer
        If mapLocus.DynamicOverlay.Layers.Count = 0 Then
            layerViewPort.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.CreateSimpleAreaStyle(GeoColor.SimpleColors.Transparent, GeoColor.SimpleColors.Red, 2)
            layerViewPort.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20
            mapLocus.DynamicOverlay.Layers.Add("ViewPort", layerViewPort)

            With mapLocus
                .ShowLogo = False
                .MapUnit = GeographyUnit.Meter
                .Refresh()
            End With
        Else
            layerViewPort = DirectCast(mapLocus.DynamicOverlay.Layers("ViewPort"), InMemoryFeatureLayer)
        End If

        layerViewPort.InternalFeatures.Clear()

        Dim fView As New Feature(rectEnvelope)

        layerViewPort.InternalFeatures.Add(fView)

        mapLocus.RefreshDynamic()
    End Sub



Also, I thought it was strange that the CurrentExtentChanged event fires off before Form_Load. Is this intentional?



Nelson, 


You cannot disable the mouse zooming/panning with the current version (3.0.184). It’s on our radar and we will come up with good solutions to enable/disable/customize mouse operations in the future release.
 
About your 2nd question, do you mean if using .RefreshDynamic(), remnants of features will left on the Locus while using .Refresh() everything is fine? Could you let me know what does the “remnants of feature” mean? Can you provide some snapshots like what it is and what it suppose to be? Also did you turn on the cache? Method Refresh() sure takes more time, I’m wondering how many layers you have in the StaticOverlay(and any other overlays like AdornmentOverlay) and how much more time it takes. By commenting out adding static layers you can figure out which layer contribute most, what kind of that layer is and what the size of its data is?
 
Also in your code, I see if mapLocus.DynamicOverlay.Layers.Count equals to 0, mapLocus.Refresh() is called and later mapLocus.RefreshDynamic() is called. I think here we can do some optimization to make sure the refresh method (either Refresh() or RefreshDynamic()) will be called only once.  
 
CurrentExtentChanged event will not be raised before Form_Load unless the winformMap1.CurrentExtent property is set before the Form1_Load method, for example, within InitializeComponent() method. Here is a simple sample you can see when the event CurrentExtentChanged will be raised.
 
Thanks,
 
Ben

371-ExtentChangedEvents.zip (14.1 KB)

CurrentExtentChanged was fired off because I was using a map.refresh on load. I corrected the behavior on my end, thank you for the insight on that. It seems I will need to use the EditOverlay instead of the DynamicOverlay as I wish to add 'draginess' to the bounding box in my locus map the represents my viewable extent.


Also, yes you are correct the code I provided has nothing to do with efficiency what-so-ever. :) The very essence of work-in-progress.


I have set up the code in a way that the new extent box is not drawn on the locus map until the MouseUp and MouseWheel event. This resolved a lot of the performance issues and is acceptable for our application anyways. I was just trying to push it a little.


By remnants, I meant that while the bounding box rectange was always drawn, sometimes the previous box wasn't entirely cleared from the canvas so without an entire refresh instead of a dynamic refresh (at the time when it was in the DynamicLayer) you would see at least one whole rectangle and then part of the other. As mentioned above, it was much better performance wise not to force the locus to redraw on each instance of the extent changing in our main map.


I do have one minor issue, though. It was recommended to use the EditOverlay for the dragging ability that is built into it, but even when using the below line on FormLoad, when clicking the locus map I still pan, not drag.


mapLocus.EditOverlay.EditSettings.IsDraggable = True


Thank you.



Nelson, 


That’s great your performance issue is gone. :)
 
About the EditSettings, the “IsDraggable" just means whether the EditOverLay can be dragged or not, if you want to drag it, you need to highlight one of the feature and then drag it. In fact, this property (as well as some other properties like IsReshapable, IsResizable and IsRotatable) by default is true, set it to false and you can see even you have highlighted one feature, you can resize it, rotate it but cannot drag it.
 
Hope that make sense.
 
Ben

By highlight, do you mean by adding the feature to the DynamicOverlay? This has been the only way I have highlighted in the past and wasn’t sure if there was a more direct way for this given circumstance where I could highlight a feature or features in the EditOverlay directly? Thanks again.

Nelson,  
  
 The "HighLight" in my last message I was meaning clicking one shape, making the control points available to be the “Modify Ready” status, it’s not like rendering with a different color to “highlight” it, sorry for the misunderstanding. 
  
 So if you want to make one shape to be “Modify Ready”, the only way now is clicking it. In the coming release we may have some other ways to implement it programmatically. If you want to render it with a different color to “highlight” it, as you tried, you need to add it to DynamicOverlay and there is no shortcut for this now. 
  
 Thanks, 
  
 Ben 
  


Do you mean to literally click it? I tried this first and only the map panning action takes place.

Nelson,


Yes, I mean that. Maybe you forgot to set EditOverlay.TrackMode to Edit and that's why you cannot click and highlight it. Here is a sample you can see after adding features to EditOverlay, click the feature will make it highlight to "Modified Ready".


Thanks,


Ben.



404-AddEditing.zip (12.9 KB)