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.
本文介绍如何在WinForms或ASP.NET WebForms中创建一个可点击的地图。通过使用PictureBox或ImageButton控件,并设置点击事件,可以实现地图上的交互操作,如放大、缩小等功能。文章还提供了示例代码并解释了如何在ASP.NET环境中保存地图的状态。
1556

被折叠的 条评论
为什么被折叠?



