This project is read-only.

Problem setting custom marker icon

Jan 7, 2012 at 11:46 PM

If i use the code below a default marker correctly appears on the map. However when I try and set the Icon property to specify an image nothing appears. I also tried adding a shadow image but neither combination worked. Any help or suggestions appreciated. I'm using version 6.



Marker marker = new Artem.Google.UI.Marker();    

marker.Position.Latitude = 59.329444;

marker.Position.Longitude = 18.068611;

marker.Visible =


marker.Animation = Artem.Google.UI.


// When code below is added, nothing appears

MarkerImage mi = new MarkerImage();

mi.Url = @"~\icon.jpg";

mi.Size = new Size(40,35);

mi.Origin = new Point(0, 0);

mi.Anchor = new Point(20, 35);

marker.Icon = mi;

// End of Icon code




Jan 8, 2012 at 8:29 AM

The Url property of MarkerImage is of type string and any special URL mapping is not performed on it.
You can try:

mi.Url = @"~/icon.jpg";

 but the proper ways should be:

mi.Url = "/icon.jpg"; // if the icon image is in the webapp root
mi.Url = "./icon.jpg"; // if the icon image is in the same folder as page
mi.Url = "/images/icon.jpg"; // if the icon image is in the webapp images folder

Hope this helps



Jan 10, 2012 at 10:40 PM

Thanks so much for your help.

It was the url string. The image was at root and the page one directory down. "/icon.jpg" didn't work but "../icon.jpg" did.



Feb 5, 2012 at 12:45 AM

Just working on similar issue myself. Challenge was on localhost the application runs in a directory below the root (and could in production too).

mi.Url = "/images/icon.jpg"; //This was not working to correctly resolve http://localhost:1234/myweb/images/icon.jpg

So I used:

mi.Url = Request.ApplicationPath + "/images/icon.jpg";

I think that should make the path correct regardless of the web applications deployment location.

(Great tool- thanks! Figured the least I could do was contribute to the forums to help other searchers)