ThinkGeo.com    |     Documentation    |     Premium Support

Migrating from 4.5 to 12 Adornment Overlay

Frank
Thanks for example.
I can not it to run. Referens are missing (with yelow triangles). I do Restore NuGet Packages - ok, but reference are missing. Several hours i trying to solve this issue but no success.
I left it as it is and go to code. What I figured out.
All my adornment layers were added to Map.AdornmentOverlay and it not displaying anithing. I am a little angry ))) When I create new LayerOverlay and add it to Map.Overlays all became working.
If it not used, why this not removed. Ritorical question.

GoogleMap Image… I understand in which direction I need moving. Thanks you

Next things - sizes of font, offsets and sizes of images, displayed on the map
Fonts has become smoller than was in 4.5 version. Offsets and sizes of images lager in canvas.DrawScreenImage(). Is there some kind of relationship between new and previous sizes?

Thanks Andras,
I upload the full sample for you.

Also Here is the main code
private void Form1_Load_1(object sender, EventArgs e)
{
winformsMap1.MapUnit = GeographyUnit.Meter;

            OpenStreetMapOverlay osmOverlay = new OpenStreetMapOverlay();

            winformsMap1.Overlays.Add("Open Street Map", osmOverlay);


         
            GeoImage needleImage = new GeoImage(Application.StartupPath + "\\compass1_needle_letters_disc.png");
            //Gets the image for the frame of the compass that will stay fixed.

            GeoImage frameImage = new GeoImage(Application.StartupPath + "\\compass1_circle_digits.png");
            CompassAdornmentLayer compassAdornmentLayer = new CompassAdornmentLayer(needleImage, frameImage, Position.UpperLeft, 100);

            winformsMap1.AdornmentOverlay.Layers.Add(compassAdornmentLayer);

            // Refresh the map.
            winformsMap1.Refresh();
        }

For the font size. It is a breaking change. We use a different standard for the font size. You need need enlarge 20% the font size.

Thanks

Frank

Thanks Frank.
Now example project run normaly. Seems folder packagesby one level higher. Ok, it doesn’t matter
I try, all works fine when I emulate situation on base of you project.
By the method of elimination, I found out that my custom GraticuleLayer do these troubles.
When this layer initiated, there is bad extent which we get in args in DrawCore. When DrawCore trying draw layer there fantastic digits, but no any exceptions. as result adornment overlay not displayed at all.

I check extent before draw and it seems to avoid this troubles. In 4.5 all worked well

Next case with rotation map and center it on the vehicle position
On the map there is vehicle and many pointShapes in InMemoruFeatureLayer. They are must rotated on vehicle movement (vehicle always up)
We need to fast rotate Map on moving vehicle. In old version without background raster map, in new version with it. Rotation was changed in new version globally

How it was in our project
RotationProjection RotateProjection = new RotationProjection();
DetailPointsLayer = new PointsFeatureLayer(Doc, this);
DetailPointsLayer.FeatureSource.ProjectionConverter = RotateProjection;
DetailOverlay.Layers.Add(“DetailPointsLayer”, DetailPointsLayer);

RotateProjection.Angle = Doc.bNorthUpMode ? 0 : (float)Doc.MainVehicle.VehicleBearing;
// Center map at Main Vehicle position
PointShape CenterPointShape = Doc.bNorthUpMode ? Doc.MainVehicle.CurrentPosition.GetPointShape() :
(PointShape)RotateProjection.ConvertToExternalProjection(Doc.MainVehicle.CurrentPosition.GetPointShape());
RectangleShape NewExtent = (RectangleShape)Map2.CurrentExtent.Register(Map2.CurrentExtent.GetCenterPoint(), CenterPointShape, DistanceUnit.Meter, GeographyUnit.Meter);
Map2.CurrentExtent = RotateProjection.GetUpdatedExtent(NewExtent);
Map2RefreshDetailOverlay();

Thanks

Thanks Andras,
Could you provide more detail about the rotation issue. If you could provide a simple project that will be very helpful for us to look into the detail. Also for the image pixel. It looks like the image was enlarged. Anyway a small simple to isolated the issue would be very helpful for us. If you don’t want to post your code to the public discussion form you could send to support@thinkgeo.com

Thanks

Frank

Thanks you Frank
Could you explaine how to rotate inMemoryFeature layer.
In howdoI there is example rotation for MapView by RotateAngle.
It means I do not need more use RotationProjection and I need to set for mapView.RotatedAngle?
Is there an example how to rotate map that vehicle move always to up and center on moved vehicle for V12?

Next case. When I resize map, background in the empty spaces is lightblue. How can I set it to my own color?
Map1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(BackColor);
Does not affect of this

About different sizes of images in 4.5 and 12 version
In DrawCore for adornmentLayer I use DrawImage function

Two programs (based on ThinkGeo 4.5 and on V 12) at the same time runned on myPC. All images is 60 x 60 pixels
MouseDown event display rect 60 pixels under button, in both cases they are the same size, but in v12 all the images displayed large and with offset. Code the same
if (ZoomInImage != null)
canvas.DrawScreenImage(ZoomInImage, 0, 0, ZoomInImage.Width, ZoomInImage.Height,
DrawingLevel.LevelFour, 85, 155 - TopShift, 0);

PS I found out reason of different sizes of images. Big font in the system settings caused this issue! Is this a bug?

Next case
I need label in two lines
In 4.5 i do that so
public string GetLabel() { return string.Format("{0} \r\n{1}", Line1, Line2); }
In V12 after first line appears square simbol. How I need to do that?

Thanks Andras,

  1. To rotate the imMemoryFeature layer you need use the RotationProjection。
  2. Here is the sample to show you how to center the vehicle on the map. You need get the direction of the vehicle and calculate the correct angle for the mapView.RotatedAngle.
  3. For the image size I may need you provide me a sample project. I can look into it.
  4. For the square symbol. Please use “{0} \n{1}”
    Multiline Label shows a character at the end of each line

Thanks

Frank

Frank thanks
About image sizes.
1.Set sysem font to medium
2. Run project you provided to me, in attachment
3. Look at the button size. It is 98 x 98. And Compare it with size of image ( 98 x 98)

CustomAdornmentLayer.zip (21.4 KB)

Frank
About rotation.
Right I understand that for rotation raster layer I need set
double Angle = 30;
MapView.RotatedAngle = Angle;
and for inMemoryFeature layers which added to this mapView I need set
RotationProjection RotateProjection = new RotateProjection();
inMemoryFeatureLayer.FeatureSource.ProjectionConverter = RotateProjection;
RotateProjection.Angle = Angle;
Thanks

Thank Andras,
Yes. For your case you may not need use the rotation projection. only need rotate the map view. Then it should work like the navigation app.

For the image thing.

  1. The system font size changes. I tested it. Looks like there is no changes after the system font size changed.


    vs default setting

  2. For the offset and image size to compare with V4.5. There may some breaking changes. You may need adjust the offset/image size to get a perfect looking.

Thanks

Frank

Medium Font. you should restart system after changing font size settings
For windows 8.1 result is

Normal Font size

Thanks Andras,
I rebooted the windows 10 machine. and load the project again. It still looks good.

I will put this one our back log. I would recommend use the default font size on windows 8.x. Even on windows 10 I found if the font size changed. a lot of applications looks mess up.

Thanks

Frank

Frank
With image sizes Very strange. DrawImage on a panel give normal size of image


CustomAdornmentLayer.zip (21.7 KB)
Also keyDown events for the mainForm not fired.
All issues you can try with example
Thanks

Thanks Andras,
The image size issue related with the system font settings on the windows 8.x. You may need adjust the code for DrawCore method in the CompassAdornmentLayer.cs. Also check the needleImage’s height and width. It supposed to be 98. The font system size change should not change the geoimage’s height and width. On windows 10 PC it looks good.

For the key event. Looks like the map capture the key event when the focus is on the map. You need hook the event on the map too. So here is the code.

 private void Form1_KeyDown(object sender, KeyEventArgs e)
        {
            switch (e.KeyCode)
            {
                case Keys.F3:
                    MapView1.ZoomToScale(MapView1.CurrentScale / 2);
                    MapView1.Refresh(); 
                    break;
                case Keys.F4: 
                    MapView1.ZoomToScale(MapView1.CurrentScale * 2); 
                    MapView1.Refresh(); 
                    break;
                default:
                    break;
            }
        }
        

        private void MapView1_MapKeyDown(object sender, System.Windows.Input.KeyEventArgs e)
        {
            switch (e.Key)
            {

                case System.Windows.Input.Key.F3:
                    MapView1.ZoomToScale(MapView1.CurrentScale / 2);
                    MapView1.Refresh();
                    break;
                case System.Windows.Input.Key.F4:
                    MapView1.ZoomToScale(MapView1.CurrentScale * 2);
                    MapView1.Refresh();
                    break;
                default:
                    break;
            }
        }

Thanks

Frank

Frank, my evaluation period is left
I need more time for a evaluating.
My project is very big and not enough time to check all. There are several global tasks I need check with new version. My Shape editor, shape layers conversion, projecting and so on
How it can be done?
Thanks

Hi Andras,

I couldn’t find an evaluation under your email. Which account you are using for evaluation?

Ben

Ben
Sorry, I used slava37mail@gmail.com account for evaluation.
ThunkGeo products we bought under Andras account

Hi Andras, we have it extended. Enjoy developing!

Frank
I try on Windows 10 our project. Things with sizes and offset the same as on Win 8.1
All the images on adornment layer bigger and shifted when scale in system set to 125
What we can to do to avoid this issue?
Thanks

Ben, thanks
After trying to run project on the my computer it forward me to [https://thinkgeo.com/pricing]
After trying to run project on the another computer it forward me to helpdesk.thinkgeo.com/register.
ProductCenter is runned and I login to it. There I see 23 days left. But I can not run project in Visual Studio. What I missing and what I should to do?
If I run without debuging

Frank,
The project crashes after a while. I am trying to understand the reason
I need to init map to stored extent and center on stored center point
I trying emulate it at the project. Please look on this. Is it correct way?
CustomAdornmentLayer.zip (22.3 KB)