我正在为wpf c#项目使用c#。我添加了地图,我可以用鼠标轮缩放。这些是我加载的设置
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;但我不能缩放到光标点双左键就像谷歌地图样式。有什么简单的方法吗?
发布于 2018-04-18 09:10:19
您可以处理Map MouseDoubleClick事件并捕获单击的点坐标,并将Map位置设置为该点。
如果MouseDoubleClick事件不能工作,那么请尝试处理MouseClick事件,如果它等于2,则检查Click属性,以地图为中心并进行缩放。
我增加了一个额外的选项,当你用右边的MouseButton双击地图,将缩放值减去1。
放大-= 1
下面是解决方案的一个示例:(GMap.Net WinForms)
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;
}
}
}https://stackoverflow.com/questions/49872941
复制相似问题