Place points on map, add labels and save them to shapefile.

Feb 17, 2013 at 10:23 PM

I try do in C# to load raster. After this I want to place on raster objects points and add labels to this points. Code for mouse event is below.

void axMapMouseDownEvent(object sender, _DMapEvents_MouseDownEvent mB)
                    axMap.PixelToProj((double)mB.x, (double)mB.y, ref x, ref y);
                    pixX1 = (double)mB.x;
                    pixY1 = (double)mB.y;
                    layerHandle = axMap.NewDrawing(MapWinGIS.tkDrawReferenceList.dlScreenReferencedList);

                    axMap.DrawPoint(pixX1, pixY1, width, (UInt32)(System.Drawing.ColorTranslator.ToOle(Color.Red)));  

                    descriptionHandle = axMap.NewDrawing(MapWinGIS.tkDrawReferenceList.dlScreenReferencedList);

                    axMap.AddLabel(descriptionHandle , "description point number" + number, (UInt32)(System.Drawing.ColorTranslator.ToOle(Color.Red)), pixX1, pixY1, tkHJustification.hjCenter);

I place points on map on objects but they are not scalable that means if I change zoom raster I change view all map, objects on rasters chage position but drawn points stay at their position, so they don't show rasters objects.

Another problem is adding labels for this points. If I use this upper AddLabel method I can't see this description. I tried many file examples but it doesn't work.

And the last problem is how to save this points to shapefile? How to add to shapefile field "name" and add this to this field information from label.

Please help me with my great problem. Thank You very much.
Feb 18, 2013 at 12:17 PM
Instead of using tkDrawReferenceList.dlScreenReferencedList you should use tkDrawReferenceList.dlSpatiallyReferencedList (doc.)

If you want to label, it might be easier to create a shapefile and add the points to it.
First you create a shapefile of type point: Shapefile.CreateNewWithShapeID
For each point you want to add you create a shape of type point: Shape.Create
Now you create a new point and add your coordinates.
Here's a complete sample: CreatePointShapefile.cs

To create labels based an a field you use Shapefile.Labels.Generate

I hope it helps.

Feb 18, 2013 at 6:38 PM
Ok, thank you. I will try your advices. I will about results.

Marked as answer by pmeems on 9/27/2016 at 6:41 AM
Sep 27, 2016 at 7:55 AM
Hi All,
I'm creating an application using MapWinGIS-v4.9.3.6-Win32 by using visual studio 2005
this is my first time to use axMapWinGIS in
I dragged the tool into my form and opened a map shapefile

I want a sample code to how to Place a point on map, save it to the shapefile. I saw subject like this through the discussions here but using c# and i didn't know any about c#. So Could you show me the sample code using, please?

many thanks
Sep 27, 2016 at 1:41 PM
Hi Zhoor,

Please don't hijack somebody else's thread.
If you have a question post a new question and we will try to help you.
This resource might help you with your question:
Sep 28, 2016 at 6:17 AM
Hi Pmeems,

i'm very sorry for asking my question here , but I didn't know where can I ask a new question
could you show me the way to ask a new question ,please? that all I can find is reply for old questions

many thanks