# No display label from shapefiles

**URL:** <https://mapwindow.discourse.group/t/no-display-label-from-shapefiles/1202>\
**Category:** MapWinGIS\
**Created:** [January 10, 2022, 12:11pm UTC](https://mapwindow.discourse.group/t/no-display-label-from-shapefiles/1202 "2022-01-10T12:11:27Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Wsixpo](https://yyz2.discourse-cdn.com/free1/user_avatar/mapwindow.discourse.group/wsixpo/32/604_2.png) [@Wsixpo](https://mapwindow.discourse.group/u/Wsixpo)\
**Post date:** [January 10, 2022, 12:11pm UTC](https://mapwindow.discourse.group/t/no-display-label-from-shapefiles/1202/1 "2022-01-10T12:11:27Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![pmeems](https://yyz2.discourse-cdn.com/free1/user_avatar/mapwindow.discourse.group/pmeems/32/9_2.png) [@pmeems](https://mapwindow.discourse.group/u/pmeems)\
**Post date:** [January 10, 2022, 12:40pm UTC](https://mapwindow.discourse.group/t/no-display-label-from-shapefiles/1202/2 "2022-01-10T12:40:07Z")

</div>

Welcome to our community.

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

1. [MapWinGIS: Labels Class Reference](https://mapwindow.org/documentation/mapwingis4.9/class_labels.html)
2. [MapWinGIS: GenerateLabelsManually.cs](https://mapwindow.org/documentation/mapwingis4.9/_generate_labels_manually_8cs-example.html)

And we have some examples about tracking vehicles:

1. [MapWinGIS: TrackCars.cs](https://mapwindow.org/documentation/mapwingis4.9/_track_cars_8cs-example.html)
2. [MapWinGIS: Tracking.cs](https://mapwindow.org/documentation/mapwingis4.9/_tracking_8cs-example.html)

---

<div class="post-metadata">

**Author:** ![Wsixpo](https://yyz2.discourse-cdn.com/free1/user_avatar/mapwindow.discourse.group/wsixpo/32/604_2.png) [@Wsixpo](https://mapwindow.discourse.group/u/Wsixpo)\
**Post date:** [January 10, 2022, 5:09pm UTC](https://mapwindow.discourse.group/t/no-display-label-from-shapefiles/1202/3 "2022-01-10T17:09:38Z")

</div>

Hello PMEEMS,

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

Here is my code:

```auto
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.

---

<div class="post-metadata">

**Author:** ![Wsixpo](https://yyz2.discourse-cdn.com/free1/user_avatar/mapwindow.discourse.group/wsixpo/32/604_2.png) [@Wsixpo](https://mapwindow.discourse.group/u/Wsixpo)\
**Post date:** [January 10, 2022, 5:28pm UTC](https://mapwindow.discourse.group/t/no-display-label-from-shapefiles/1202/4 "2022-01-10T17:28:58Z")

</div>

Yes !!!

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

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

---

<div class="post-metadata">

**Author:** ![pmeems](https://yyz2.discourse-cdn.com/free1/user_avatar/mapwindow.discourse.group/pmeems/32/9_2.png) [@pmeems](https://mapwindow.discourse.group/u/pmeems)\
**Post date:** [January 12, 2022, 10:35am UTC](https://mapwindow.discourse.group/t/no-display-label-from-shapefiles/1202/5 "2022-01-12T10:35:50Z")

</div>


