Can you give me a sample code to show how to use a ScaleBarAdornmentLayer?
ScaleBarAdornmentLayer : Sample code
Le Sommer,
Here is a sample how to use it.
winformsMap1.MapUnit = GeographyUnit.DecimalDegree
winformsMap1.CurrentExtent = New RectangleShape(-90, 45R, 90, -45R)
winformsMap1.MapBackground.BackgroundBrush = New GeoSolidBrush(GeoColor.GeographicColors.ShallowOcean)
Dim worldLayer As New ShapeFileFeatureLayer("…\SampleData\Data\Countries02.shp")
worldLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.Country1
worldLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20
winformsMap1.StaticOverlay.Layers.Add(“WorldLayer”, worldLayer)
’ Here also shows how to add a ScaleLineAdormentLayer.
'ScaleLineAdornmentLayer scaleLineAdornmentLayer = new ScaleLineAdornmentLayer();
'winformsMap1.AdornmentOverlay.Layers.Add(“ScaleLineAdornmentLayer”, scaleLineAdornmentLayer);
'Add a ScaleBarAdormentLayer.
Dim scaleBarAdornmentLayer As New ScaleBarAdornmentLayer()
winformsMap1.AdornmentOverlay.Layers.Add(“scaleBarAdornmentLayer”, scaleBarAdornmentLayer)
winformsMap1.Refresh()
Thanks,
Ben
Thanks for this sample, it was what i have tried the first time.
This sample gives me an exception :
InvalidOperationException
The GeoCanvas is currently not drawing. Please call the BeginDraw method before calling this method.
à ThinkGeo.MapSuite.Core.x6d719af406ea4c2c.xbc32d22242378f5c(Boolean x1c27a8ea53684488)
à ThinkGeo.MapSuite.Core.GeoCanvas.get_CurrentWorldExtent()
à ThinkGeo.MapSuite.DesktopEdition.Overlay.Draw(GeoCanvas canvas)
à ThinkGeo.MapSuite.DesktopEdition.xf0380b1a0bc40ca6.StartDraw()
à ThinkGeo.MapSuite.DesktopEdition.x601a5561df898600.x7510a5c148e0acfd(Object x19b0b2213afc2289)
à System.Threading._ThreadPoolWaitCallback.WaitCallback_Context(Object state)
à System.Threading.ExecutionContext.runTryCode(Object userData)
à System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
à System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
à System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
à System.Threading._ThreadPoolWaitCallback.PerformWaitCallbackInternal(_ThreadPoolWaitCallback tpWaitCallBack)
à System.Threading._ThreadPoolWaitCallback.PerformWaitCallback(Object state)
Le Sommer,
I think you are not using the latest version. One of our previous versions has cross threading issue which might lead to some strange problem. Please try the attached demo which works fine on my machine.
Thanks,
Ben
429-UseScaleBar.zip (15.2 KB)
My version is "MapSuiteCore:3.1.4;DesktopEdition:3.0.184"
It will download the lasted version and retry
OK, let me know if you find anything.
With the last version "MapSuiteCore:3.1.19;DesktopEdition:3.0.199", my ScaleBarAdornmentLayer works perfectly
Thanks
That’s great, let me know if you have any issues.
Ben