0

I need to create a mapping app with C# and stumbled upon MapWinGIS which looks like an appropriate tool. I have a minimal app working, pulling tiles from OpenStreetMap.

I want to plot a point on the map. I thought it would be as easy as calling DrawPoint(), but it's not working:

AxMap.DrawPoint(-100, 32, 10, Convert.ToUInt32(ColorTranslator.ToOle(Color.Red)));

Instead of drawing a point at map long (32, -100), the point appears to be at lat/lon of (0, 0).

Here's the full function:

public Form1()
        {
            InitializeComponent();

            AxMap.CursorMode = tkCursorMode.cmPan;
            AxMap.InertiaOnPanning = tkCustomState.csFalse;
            AxMap.Projection = tkMapProjection.PROJECTION_GOOGLE_MERCATOR;
            AxMap.TileProvider = tkTileProvider.OpenHumanitarianMap;
            AxMap.KnownExtents = tkKnownExtents.keUSA;

            int d = AxMap.NewDrawing(tkDrawReferenceList.dlSpatiallyReferencedList);
            AxMap.DrawPoint(-100, 32, 10, Convert.ToUInt32(ColorTranslator.ToOle(Color.Red)));

        }

What am I doing wrong?

1

I finally figured this out. I needed to call DegreesToProj before plotting the point:

double lat = 32;
double lon = -100;
double projX = -2; //dummy value
double projY = -3; //dummy values
bool bSuccess = AxMap.DegreesToProj(lon, lat, ref projX, ref projY);
if (bSuccess)
{
    AxMap.DrawPoint(projX, projY, pixels, color);
}

Hope this helps someone.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.