如何在WPF中集成GMap.NET?如何在WPF中使用GMap.NET Winforms控件?

编程入门 行业动态 更新时间:2024-10-21 03:58:54
本文介绍了如何在WPF中集成GMap.NET?如何在WPF中使用GMap.NET Winforms控件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我不明白如何在WPF中集成GMap.NET.我正在尝试使用XAML进行操作,并且没有任何想法.我正在尝试类似的方法: msdn.microsoft/zh-CN/library/ms742875(v=vs.110).aspx .但这对我不起作用.那么,该怎么做呢?

I can not understand how to integrate GMap.NET in WPF. I am trying to do it using XAML and have no ideas. I am trying smth like that: msdn.microsoft/en-us/library/ms742875(v=vs.110).aspx. But it doesn't work for me. So, how to do it?

我有WPF应用程序,想在WPF窗口中使用GMap.NET lib winforms控件.有点像,但是在WPF中:

I have WPF application and want to use GMap.NET lib winforms controls inside WPF window. Smth like that but in WPF:

此外,通常,如何在WPF中使用WinForms控件参数?例如,如何更改地图提供者?在Winforms中,它非常简单,但是如何在WPF中实现呢?我被卡住了,所以.更改mapprovider的示例:

Also, in general, how to work with WinForms controls parameters in WPF? How to change Map Provider, for example? In winforms its quite simple, but how to do it in WPF? I got stucked, so. Sample for changing mapprovider:

gmap.MapProvider = GMap.NET.MapProviders.ArcGIS_World_Street_MapProvider.Instance;

或者,也许我只是走错了路?我对WPF完全陌生.

Or, maybe, I am just on the wrong way? I am completely new in WPF.

推荐答案

  • 将GMap NET参考添加到您的项目中,以使参考列表中包含"GMap.NET.Core"和"GMap.NET.WindowsPresentation"
  • 在您的XAML文件中,使用其他命名空间(xmlns)声明,添加

  • add the GMap NET reference to your project so you have "GMap.NET.Core" and "GMap.NET.WindowsPresentation" in your reference list
  • In your XAML file, with the other namespace (xmlns) declarations, add, xmlns:gmaps="clr-namespace:GMap.NET.WindowsPresentation;assembly=GMap.NET.WindowsPresentation"

  • 将GMap NET对象添加到您要运行的XAML正文中,例如

  • Add the GMap NET object in to the XAML body where you want it to go, e.g.

    <Grid> <gmaps:GMapControl x:Name="mapView" Loaded="mapView_Loaded" /> </Grid>

  • 在代码的mapView_Loaded函数中,设置地图对象
  • private void mapView_Loaded(object sender, RoutedEventArgs e) { GMap.NET.GMaps.Instance.Mode = GMap.NET.AccessMode.ServerAndCache; // choose your provider here mapView.MapProvider = GMap.NET.MapProviders.OpenStreetMapProvider.Instance; mapView.MinZoom = 2; mapView.MaxZoom = 17; // whole world zoom mapView.Zoom = 2; // lets the map use the mousewheel to zoom mapView.MouseWheelZoomType = GMap.NET.MouseWheelZoomType.MousePositionAndCenter; // lets the user drag the map mapView.CanDragMap = true; // lets the user drag the map with the left mouse button mapView.DragButton = MouseButton.Left; }

    更多推荐

    如何在WPF中集成GMap.NET?如何在WPF中使用GMap.NET Winforms控件?

    本文发布于:2023-11-11 07:38:43,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1577777.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:如何在   控件   WPF   GMap   NET

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!