ThinkGeo.com    |     Documentation    |     Premium Support

How do I add a marker using a custom PNG?

This seems like it should be fairly simple. I have added a Drag_Drop handler to my map control and am able to figure out the lat/long of the drop point. Now I just want to show a icon (from a png) at that point. I thought this should work, but it doesn’t.

//Let's put an icon there
var viewLinkMarkerOverlay = new InMemoryMarkerOverlay() { Name = "view_" + tn.Text, MapControl = this };
viewLinkMarkerOverlay.ZoomLevelSet.ZoomLevel01.DefaultPointMarkerStyle.Image = Properties.Resources.ViewLink;
viewLinkMarkerOverlay.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
this.Overlays.Add(viewLinkMarkerOverlay.Name, viewLinkMarkerOverlay);

Feature vlFeature = new Feature(new PointShape(fc.Longitude, fc.Latitude));
viewLinkMarkerOverlay.FeatureSource.BeginTransaction();
viewLinkMarkerOverlay.FeatureSource.AddFeature(vlFeature);
viewLinkMarkerOverlay.FeatureSource.CommitTransaction();
this.Overlays.MoveToTop(viewLinkMarkerOverlay.Name);
this.Refresh();

Help?

Hi David,

I don’t think the problem is in this part code.

Please see my test code and test result.

winformsMap1.MapUnit = GeographyUnit.DecimalDegree;
winformsMap1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.GeographicColors.ShallowOcean);
winformsMap1.CurrentExtent = new RectangleShape(-139.2, 92.4, 120.9, -93.2);

        InMemoryMarkerOverlay viewLinkMarkerOverlay = new InMemoryMarkerOverlay() { Name = "test", MapControl = winformsMap1 };
        viewLinkMarkerOverlay.ZoomLevelSet.ZoomLevel01.DefaultPointMarkerStyle.Image = Properties.Resources.Circle;
        viewLinkMarkerOverlay.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
        winformsMap1.Overlays.Add(viewLinkMarkerOverlay.Name, viewLinkMarkerOverlay);

        Feature vlFeature = new Feature(new PointShape(10, 10));
        viewLinkMarkerOverlay.FeatureSource.BeginTransaction();
        viewLinkMarkerOverlay.FeatureSource.AddFeature(vlFeature);
        viewLinkMarkerOverlay.FeatureSource.CommitTransaction();
        winformsMap1.Overlays.MoveToTop(viewLinkMarkerOverlay.Name);
        winformsMap1.Refresh();

Regards,

Don

Thanks for looking at my code Don…

I was just sure I had messed it up somehow. With your assurance that it was Ok, I started looking at the data and discovered that my lat/long values should have been northing/easting values. When I used the correct UTM values it worked fine.

Dave

Hi Dave,

I am glad to hear you find the reason and solved that.

Any question please let us know.

Regards,

Don

“Any question please let us know.”

Funny you should say that… :smile:

Dave

Hi Dave,

We will reply you in the other topic.

Regards,

Don