ThinkGeo.com    |     Documentation    |     Premium Support

V12 DrawCore for AdornmentLayer

ThinkGeo team,

I have adornmentLayer and override DrawCore
protected override void DrawCore(GeoCanvas canvas, Collection labelsInAllLayers)
Inside this function i used canvas.CurrentWorldExtent to calculate something
MapUnits for mapView set to DecimalDegree, but canvas.MapUnit = Meter, also canvas.CurrentWorldExtent in meters
and all my calculation fails because of it
Same situation with custom Style (class ExtPointStyle : PointStyle) with overrided DrawCore
What I should to set?

Thanks Slava,
Could you attach your adornmentLayer layer class or the sample project? we could look into more detail.

Thanks

Frank

Frank, here example. Please debug inside DrawCore
CustomAdornmentLayer.zip (22.3 KB)

Also you can add this code
private void Form1_Load_1(object sender, EventArgs e)
{
MapView1.MapUnit = GeographyUnit.DecimalDegree;
MapView1.CurrentExtent = new RectangleShape(-97.1, 36.1, -97, 36);
// Look at the CurentExtent
}

Thanks, Slava

Thanks Slava,
I think the sample come from

But I don’t see any issue as you mentioned.

I created video to show you how it work on my side.

Thanks

Frank

Thanks, Frank
I don’t know why. Such issue hapens second time and I can’t do anything.
May be after prog tried set not correct scale like
double Map1Scale = 300317958.61772;
Map1.CurrentExtent = MapUtil.ZoomToScale(Map1Scale, Map1.CurrentExtent, GeographyUnit.DecimalDegree, Map1.Width, Map1.Height);

The behavior became normal only after restarting the laptop
Slava

Thanks Slava,
I am going to close this one. Go ahead let us know if you have more question.

Thanks

Frank

Frank
Some time after I save Scale in registry and resume it when prog run,
I get such extent in DecimalGegree {-0.0550166662810793, 0.0843203522713151, 0.0752690027531751, -0.0323451676241947}
Try example where I set extent programmaticaly. In that case adornment layer not drawn more
DrawCore not flashing

And a situation with abnormal behavior,described higher, is provoked by this example

CustomAdornmentLayer.zip (22.8 KB)

Also, what is the right way save / restore map extent in V12?

Thanks, Slava

Thanks Slava,
You don’t need store the scale. You just need store the extent.

  1. I found you have “return” in the line 85 of CompassAdornmentLayer.cs. So the code after line 85 may never get hit.
  2. I would like store the last extent to the file system instead of the register. because write the register need administrator permission.
  3. I would recommend save extent after the current extent changed. This way if the application crashed you still have the correct last extent saved.
  4. I think I understand what you are trying to do. I adjusted your sample. You can take a look.
    CustomAdornmentLayer (4).zip (23.3 KB)

Thanks

Frank

Frank, thanks
It worked now. Issue was with ZoomToScale and GetScale
We must to do Save / Restore extent directly by saving RectangleShape
Slava

Thanks Slava,
Good to know it works. I am going to close this one. Go ahead let us know if you have any question.

Thanks

Frank