No display label from shapefiles

Hello everyone,

I need your experience, because I am in the process of developing an ATC (air traffic control) simulator in C # visualStudio 2017.

I am on the map display and I am using MapWinGis with different shapefiles.

The display works perfectly and the management following the zoom is very good.

My problem is that I cannot display the labels of the last shapefile corresponding to the names of the cities.

Do you have a lead for me on this problem?

Thank you for your help

Wsixpo

Welcome to our community.

Several ways to display labels are available. Have a look at these resources:

  1. MapWinGIS: Labels Class Reference
  2. MapWinGIS: GenerateLabelsManually.cs

And we have some examples about tracking vehicles:

  1. MapWinGIS: TrackCars.cs
  2. MapWinGIS: Tracking.cs

Hello PMEEMS,

Thank you very much for this information. I will look at your links.

Here is my code:

int numlayer = 0;
            // charge les layers
            string[] m_files = new string[4] {
                     "gadm36_2.shp" ,
                     "ne_10m_rivers_lake_centerlines_scale_rank.shp",
                     "ne_10m_lakes.shp",
                     "ne_10m_populated_places.shp"
                    };

            handelLayer = new int[m_files.Count()];
            Map.RemoveAllLayers();
            Map.LockWindow(tkLockMode.lmLock);
            foreach (string file in m_files)
            {
                if (file.ToLower().EndsWith(".shp"))
                {
                    Shapefile sf = new Shapefile();
                    sf.Labels.Visible = true;
                    if (sf.Open((m_mapspath+file).Replace("\\\\","\\"), null))
                    {
                            handelLayer[numlayer] = Map.AddLayer(sf, true);
                    }
                    else
                        MessageBox.Show(sf.ErrorMsg[sf.LastErrorCode]+" "+file);
                }
                if (handelLayer[numlayer] != -1)
                {
                    Map.set_LayerName(handelLayer[numlayer], file);
                }
                numlayer++;
            }
            Map.LockWindow(tkLockMode.lmUnlock);
            Map.set_LayerDynamicVisibility(3, true);
            Map.set_LayerMinVisibleZoom(3, 7);
            Map.Redraw();

Unless I am mistaken, in the last Shape file (ne_10m_populated_places.shp) there must be the names of the cities. is it necessary to process this information?

Thanks for your feedback.

Yes !!!

Thank you very much, with your examples I found what was missing.

→ sf.Labels.Generate("[Name]", tkLabelPositioning.lpLongestSegement, false);