ThinkGeo.com    |     Documentation    |     Premium Support

Issue printing labels

Hi


I need to have a bitmap that contains the map and I do not want to use the drawtobitmap method.


I take this code in the pdfextention sample and I get a very nice bitmap of my map.

The issue is that feature labels are missing (they are on the map and not on the bitmap);


what am I doing wrong ?


using (Bitmap b2 = new Bitmap(sr.Width, sr.Height))

{

  Collection<SimpleCandidate> labelsInLayers = new Collection<SimpleCandidate>();

  GdiPlusGeoCanvas c = new GdiPlusGeoCanvas();

  foreach (Layer l in myLayers)

  {

    c.BeginDrawing(b2, _FullExtent(), theMap.MapUnit);

    l.Open()

    l.Draw(c, labelsInLayers);

    l.Close();

    c.EndDrawing();

  }

}


Patrick.



Patrick,


Thanks for your post!
 
I doubt the problem is hidden in that myLayers did not contain all the layers, probably it missed the LabelLayers as you said.
 
I added a button in the HowDoISample\Labeling\ChangeTheLabelPlacementForPoints sample as following code and it works:
 

  private void button1_Click(object sender, EventArgs e)
        {
            LayerOverlay layerOverlay = (LayerOverlay)winformsMap1.Overlays["StatesOverlay"];
            Bitmap b2 = new Bitmap(winformsMap1.Width, winformsMap1.Height);
            {
                Collection<SimpleCandidate> labelsInLayers = new Collection<SimpleCandidate>();
                GdiPlusGeoCanvas c = new GdiPlusGeoCanvas();
                c.BeginDrawing(b2, winformsMap1.CurrentExtent, winformsMap1.MapUnit);
                foreach (Layer l in layerOverlay.Layers)
                {
                    l.Open();
                    l.Draw(c, labelsInLayers);
                    l.Close();
                    c.Flush();
                }
                c.EndDrawing();
            }

            b2.Save(@"C:\temp\test.bmp");
        }

 

There is minor difference between your codes and the codes above, but I think both of them are correct except some performance enhancement.
 
If you still have problems, please let me know your version.
 
Let me know any problems.
 
Thanks.
 
Yale

Right Yale, this works. 
  
 Regards, 
 Patrick.

Patrick, 
  
 Thanks for letting me know. 
  
 Any more questions just let me know. 
  
 Yale