Displaying an image on the the map

Mar 26, 2010 at 8:04 AM

Hello All

I am trying to work on display of postgis data ... On the map i hv to show the movement of ship ... i hv lat long .. now i hv to image based on the lat long ...

ut the issue is that when i hv drawn a symbol its not on the map... I tried to the coordinates using other software ... but still the image drawn is not on the map ...Other layers are displayed using postgis.. while this new point to be displayed is based on gps feed...


Any ideas how to go about doing this ??

Here is the part of code ...


        SharpMap.Map mymap = new SharpMap.Map();    

          //other layers are also defined here...

              VectorLayer customLayer = new VectorLayer("custom");
            List<SharpMap.Geometries.Geometry> GeomColl = new List<SharpMap.Geometries.Geometry>();
            //Add a single Point
            //insert world-coordinate ... lat n long
            Point pt = new Point(-95.57, 28.96);

            customLayer.DataSource= new SharpMap.Data.Providers.GeometryProvider(GeomColl);
            customLayer.Style.Fill = new SolidBrush(Color.White);
            customLayer.Style.Outline = System.Drawing.Pens.Black;
            customLayer.Style.EnableOutline = true;
            customLayer.Style.SymbolScale = 0.5f;
            customLayer.SRID= 4326;
            customLayer.Style.Symbol = new Bitmap(@"D:\Images\OwnShip.bmp");
            //customLayer.MaxVisible = 0.50;
            //customLayer.MinVisible = 0;



            mymap.ZoomToBox(new SharpMap.Geometries.BoundingBox(-95.56, 28.81, -95.17, 29.06));

            return mymap;



May 4, 2010 at 9:49 AM


Have you manage to do this?

If yes can you tell me how cause i am looking for something similar.



May 6, 2010 at 4:41 PM
Edited May 6, 2010 at 4:43 PM

Are you drawing only one ship? If so, it might be easier to use Map.WorldToImage() to get the pixel coordinates where the ship should be drawn, and then use GDI+ to draw the ship image on top of the map image (Map.GetMap())

Jun 2, 2010 at 6:20 AM


In code in 1st post - There is only one image on one layer.

How can I put more then 1 image (images are equal by size, but there are different images) on one layer?
When I debugged my app I saw sharpmapImages.MaxLayerCount = 128, but now in my map about 90 layers, and I need to draw some count (1-50) images on my map - is there any ability to do this?



Jun 2, 2010 at 7:57 AM

Hi Lavina,

you can use a CustomTheme to replace the default symbol.

You can do so either by storing the symbol in the datasource and get it from FeatureDataRow, or pick the symbol from your symbolstore in dependance of some other value in the FeatureDataRow.

Here is an example for theming.

Hth FObermaier

Jun 2, 2010 at 2:41 PM
Edited Jun 2, 2010 at 2:43 PM
FObermaier wrote:

You can do so either by storing the symbol in the datasource and get it from FeatureDataRow.

The changing of CustomTheme is too hard for me ((.

How can I use FeatureDataRow for putting images on map?

I used it for put text labels on map:


FeatureDataTable layerTable = new FeatureDataTable();
layerTable.Columns.Add("label", Type.GetType("System.String"));

qdatareader = Text.ExecuteReader();
while (qdatareader.Read())
   FeatureDataRow fdrRow = layerTable.NewRow();
   fdrRow.Geometry = new GeoPoint(X, Y);
   fdrRow["label"] = qdatareader["Text"].ToString();;
   fdrRow["rotate"] = angle;                     

LabelLayer lblLayer = new LabelLayer(sLayerName);
lblLayer.DataSource = new GeometryFeatureProvider(layerTable); 
lblLayer.Enabled = true;
lblLayer.LabelColumn = "label";
lblLayer.RotationColumn = "rotate";
lblLayer.Style = new LabelStyle();
lblLayer.Style.ForeColor = color;
lblLayer.Style.Font = new Font("%Arial", 11, FontStyle.Bold, lblLayer.Style.Font.Unit);
lblLayer.Style.HorizontalAlignment = HorizontalAlignmentEnum.Left;             


How can I use FeatureDataRow for put image and text on map, I don't see ImageColumn in LabelLayer properties.


Jun 2, 2010 at 4:16 PM
Edited Jun 2, 2010 at 4:20 PM


to display symbols from FeatureDataRow, you must use CustomTheme to retrieve and set the Symbol.

That is not a difficult task, I just added an example.

If you want to have labeling, too, you have to set up a seperate LabelLayer. I think it it mandatory to provide a new DataProvider.

Hth FObermaier

Jun 2, 2010 at 6:41 PM

Thank, Hth FObermaier

I will try to do it this way.