Creating a clickable map
- Insert a PictureBox when using Win Forms or an <asp:ImageButton> for ASP.NET web forms.
- Set the image to your map-instance. Ex.: myImage.Image = myMap.GetMap();
- Set up a click-event for your PictureBox/ImageButton.
- Create a click-event handler, similar to the one below.
protected void imgMap_Click(object sender, ImageClickEventArgs e)
{ //Center the map on the click-point
myMap.Center = myMap.ImageToWorld(new System.Drawing.PointF(e.X, e.Y), myMap);
//Zoom in 2x
myMap.Zoom *= 0.5;
//Call function that renders the map and returns it to the client
myImage.Image = myMap.GetMap(); }
Note: When using ASP.NET, you need to store the zoom and center values between requests. This can be done using either ViewState or Session variables. These should be restored on a postback, and stored when they are changed.