首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >GMap.net启用双击缩放

GMap.net启用双击缩放
EN

Stack Overflow用户
提问于 2018-04-17 08:11:12
回答 1查看 2.4K关注 0票数 1

我正在为wpf c#项目使用c#。我添加了地图,我可以用鼠标轮缩放。这些是我加载的设置

代码语言:javascript
复制
GMap.NET.GMaps.Instance.Mode = GMap.NET.AccessMode.ServerAndCache;

mapView.MapProvider = GMap.NET.MapProviders.GoogleSatelliteMapProvider.Instance;                   // choose your provider here

mapView.ShowCenter = false;
mapView.MinZoom = 4;                                                                            // whole world zoom
mapView.MaxZoom = 20;  
mapView.Zoom = 1;      
mapView.MouseWheelZoomType = GMap.NET.MouseWheelZoomType.MousePositionWithoutCenter;                // lets the map use the mousewheel to zoom
mapView.CanDragMap = true;                                                                      // lets the user drag the map       
mapView.DragButton = MouseButton.Left;                                                          // lets the user drag the map with the left mouse button
mapView.IgnoreMarkerOnMouseWheel = true;

但我不能缩放到光标点双左键就像谷歌地图样式。有什么简单的方法吗?

EN

回答 1

Stack Overflow用户

发布于 2018-04-18 09:10:19

您可以处理Map MouseDoubleClick事件并捕获单击的点坐标,并将Map位置设置为该点。

如果MouseDoubleClick事件不能工作,那么请尝试处理MouseClick事件,如果它等于2,则检查Click属性,以地图为中心并进行缩放。

我增加了一个额外的选项,当你用右边的MouseButton双击地图,将缩放值减去1。

放大-= 1

下面是解决方案的一个示例:(GMap.Net WinForms)

代码语言:javascript
复制
    Private void GMapControl1_MouseClick(Object sender, MouseEventArgs e)
{
    //   Capture the Double Click event when 2 clicks occured
    If (e.Clicks.Equals(2))
    {
        PointLatLng pt = GMapControl1.FromLocalToLatLng(e.X, e.Y);

        GMapControl1.Position = pt;

        If (e.Button.Equals(MouseButtons.Left))
        {
            // Zoom in with left mouse button
            GMapControl1.Zoom += 1;
        }
        ElseIf (e.Button.Equals(MouseButtons.Right))
        {
            // Zoom out with right mouse button
            GMapControl1.Zoom -= 1;
        }
    }
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49872941

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档