Creating a clickable map

Creating a clickable map


  1. Insert a PictureBox when using Win Forms or an <asp:ImageButton> for ASP.NET web forms.
  2. Set the image to your map-instance. Ex.: myImage.Image = myMap.GetMap();
  3. Set up a click-event for your PictureBox/ImageButton.
  4. 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.
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值