Can't draw a circle with radius in meters anymore in v5.2

Hello! I’m developing in VB6, and I have code that draws a circle with a certain radius in meters, using ConvertDistance to make the conversion. Howerver, my code stopped working when I updated the ocx from 5.1.1.0 to 5.2

Here is the relevant part of the code, can anyone figure out why it doesn’t work anymore and what would be a workaround? Thanks!

*** On form load: ***
 
Map1.Projection = tkMapProjection.PROJECTION_GOOGLE_MERCATOR
myId = tkTileProvider.ProviderCustom + 2
 
'Local server with openstreetmap tiles:
ans = Map1.Tiles.Providers.Add(myId, "Localhost Provider", "http://localhost/hot/{zoom}/{x}/{y}.png", tkTileProjection.SphericalMercator, 0, 16)
 
Map1.Tiles.ProviderId = myId
 
 
*** On the draw function ***
 
Dim m_Utils As New Utils
Dim valDist As Double, visDist As Double
               
Map1.ClearDrawings
Handle = Map1.NewDrawing(tkDrawReferenceList.dlSpatiallyReferencedList)
 
Map1.DegreesToProj sourceLon, sourceLat, X, Y
 
visDist = 3000
valDist = 200
 
ans = m_Utils.ConvertDistance(tkUnitsOfMeasure.umMeters, Map1.GeoProjection.LinearUnits, valDist)
valDist = valDist / Cos(sourceLat * PI / 180)
Map1.DrawWideCircle X, Y, valDist, RGB(120, 0, 0), False, 4, 255 'had to add alpha value 255 on v5.2, not optional
 
ans = m_Utils.ConvertDistance(tkUnitsOfMeasure.umMeters, Map1.GeoProjection.LinearUnits, visDist)
visDist= visDist/ Cos(sourceLat * PI / 180)
Map1.DrawWideCircle X, Y, visDist, RGB(0, 120, 0), False, 4, 255

Edit: To be more specific, the problem is that the circles don’t change their apparent radius when I change zoom levels in the map, they mantain ther size in pixels. Which shouldn’t happen, as I set dlSpatiallyReferencedList on the drawing layer.

Edit 2: I went back to v5.1.1 for now, and the same code is back to working as intended. I can stay with v5.1.1 for now, so this isn’t an urgent problem for me, but it’d be nice if it could be fixed (and then I can use the new alpha setting when drawing circles!)

Hello @pablodaniel

I have not tried running this yet, but at first glance, I can see that you’re calling DrawWideCircle rather than DrawWideCircleEx (in which you pass the Drawing Handle you got back from the NewDrawing call).

It’s a little obscure (I don’t know the history if the OCX development), but if you don’t specify a Handle, it will drawing using an internal default Handle, which may or may not be the same as the Handle you got back from NewDrawing. A discrepancy might only expose itself if you do multiple NewDrawing calls. If you have only done one, then your handle, as well as the internal handle, are likely both = 0 (zero).

Of course, none of this explains why the same code behaves differently from 5.1 to 5.2. I will paste this into a demo program and debug the issue. It may take a day or two to get to it, but it is important to get bugs resolved, so I will get to it.

Kind Regards,
Jerry.

Hi @jerryfaust, thanks for looking into my problem.

I tried replacing the DrawWideCircle with DrawWideCircleEx calls, using the Handle value returned by NewDrawing, (registered the v5.2 ocx for the test) but there was no change in behavior, the circles still had a fixed radius in pixels at all zoom levels.

Another thing I noticed when using the 5.2 version of the ocx is that the scale bar and the zoom bar both dissapear, even when set as visible in the control properties.

This will be fixed in the next release
(see commit Fix for drawing spatially referenced circles: diameter was still in p… · MapWindow/MapWinGIS@607234b · GitHub)

A new release is available Releases · MapWindow/MapWinGIS · GitHub.
I’m closing this issue.