ThinkGeo.com    |     Documentation    |     Premium Support

Migrating from 4.5 to 12 Adornment Overlay

We are thinking about buying new version of ThinkGeo. Our projects were developed on the version 4.5

And we try to translate them to new version before buy new product.

We have couple of global troubles with it and wast time because don’t understand why most of our things do not work in new version
I made all the changes to compile and run my project, but no one Adornment Layer not displayed on the map
Custom Adornment layers in our projects have DrawCore overrides. Debuger don’t enter in DrawCore
Custom scale bar, custom graticule custom Logo and other specific adornment layers inherited from AdornmentLayer I can not display them on the Map.
What reason can be?

Also in 12 version absent Get Bitamp from Google map api (googleMapsLayer.GetGoogleMapsImage)
Any suggestions?

Slava

Thanks Andras,
There are some breaking changes from 4.5 to 12.x. You may need adjust some of your code base on the new how do I sample

You can also find some thing here. But it compares between 9,10 and 12.
https://docs.thinkgeo.com/products/desktop-maps/v12.0/upgrade-guide/

I believe there will be some issue after upgrade from 4.5 to 12. We may need solve the issue case by case. You can create a sample project to isolate issue and attach to here we could could look into.

For the google map layer. because some license issues. We have to use the google map static api to get the image. To get some google map image you could try with

        GeoImage bitmap = new GeoImage(1024, 512);
            GoogleMapsLayer layer = new GoogleMapsLayer("apikey", "singingSecret");
            layer.Open();
            RectangleShape extent = layer.GetBoundingBox();

            GeoCanvas canvas = GeoCanvas.CreateDefaultGeoCanvas();
            canvas.BeginDrawing(bitmap, extent, GeographyUnit.Meter);
            layer.Draw(canvas, new Collection<SimpleCandidate>());
            canvas.EndDrawing();
            var executingFolderPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            bitmap.Save($@"{executingFolderPath}\test.png");  

Thanks

Frank

Frank
Thanks you for answer. I am very apreciate your help.
I saw all issues with changes and it help me compile and run project under new version ThinkGeo
HowdoI is for WPF. Could you provide simple example of code for WinForms, where
simple custom AdornmenLayer with overriding DrawCore works with V12. It is very hard to make sample project to isolite issue from very big project, I thinking how I can do this

About GoogleMapLayer. All worked fine with
googleMapsLayer.SendingWebRequest += GoogleMapsLayer_SendingWebRequest;
to avoid issues with license.
If it possible could you provide code for googleMapsLayer.GetGoogleMapsImage function from old 4.5 source. It will be more easy for me, because of some logic we used for getting googlemap image in needed scale and by tiles

Thanks

Thanks Adnras,
You can find the winform sample here.

For the AdornmentLayer I created a demo with custom AdornmentLayer for you. You can set the break point for the drawcore.
WindowsFormsApp18.zip (20.6 KB)

For the google map image. Google not allow us cache the their images in the mapsuite product. You could write a GetGoogleMapsImage method out of the mapsuite. You need use the parameter for GetGoogleMapsImage to calculate the BoundingBox you want. Then draw the image.

Thanks

Frank

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