用于 OpenStreetMap 的 Xamarin SDK

Hen*_*ous 5 gis openstreetmap xamarin

我试图让概念(C#)为基本图形的地图的证明,作为一种替代谷歌地图的AndriodiOS版设备的- 因为谷歌开始对其 API 收费(据我了解,目前仅影响网络)。

我不需要特别高级,只需一个显示基本地图的 GUI,您可以在其中绘制:

  • 标记
  • 线
  • 多边形

我唯一的要求是它应该是开源的,或者成本尽可能低

到目前为止,我所做的是使用来自http://openstreetmap.org 的数据- 并在单独的 linux 机器上设置一个 tile-server https://switch2osm.org/serving-tiles/

此外,使用 OpenLayers.js 和 Leaflet.js 连接到自定义 tile-server 并满足要求,创建一个简单的 Web 应用程序相当快。

我现在需要做的是为 Xamarin for Android 和 iOS 找到一个免费或便宜的移动 SDK。我设法从我自己的 tile-server 渲染了一张地图,并通过从 2014 年的这个 zip 中引用 .dll 来添加标记(仅针对 Andriod 进行了测试):https : //github.com/OsmSharp/ui/releases/tag/v4.2.0 .723

 using OsmSharp.Android.UI;
 using OsmSharp.Android.UI.Data.SQLite;
 using OsmSharp.Math.Geo;
 using OsmSharp.UI.Map;
 using OsmSharp.UI.Map.Layers;

 [Activity(Label = "@string/app_name", MainLauncher = true)]
 public class MainActivity : AppCompatActivity 
 {

     private MapView _mapView { get; set; }
     private Layer _mapLayer { get; set; }  

     protected override void OnCreate(Bundle savedInstanceState)
     {
         base.OnCreate(savedInstanceState);

         try
         {
            Native.Initialize();

            _mapView = new MapView(this, new MapViewSurface(this))
            {
                MapTilt = 0,
                MapCenter = new GeoCoordinate(lat, long),
                MapZoom = 16,
                Map = new Map()
            };

            // create a marker under Resources/drawable/pin.png
            using (var bitmap = BitmapFactory.DecodeResource(Resources, Resource.Drawable.pin))
            {
                var marker = new MapMarker(this, new GeoCoordinate(lat, long), MapMarkerAlignmentType.CenterBottom, bitmap);
                _mapView.AddMarker(marker);        
            }

            _mapLayer = _mapView.Map.AddLayerTile("http://*.*.*.*/{0}/{1}/{2}.png");
            SetContentView(_mapView);
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex);
        }
    }        
}
Run Code Online (Sandbox Code Playgroud)

然而,这些 .dll 似乎缺乏对线条和多边形的支持。我试图获得与 OsmSharp 最新的 NuGet 包(2018-06-04)类似的东西,但我的新手 Xamarin 经验只能让我到目前为止。

有没有人有任何关于如何使用我自己的瓷砖服务器并在AndroidiOS设备上渲染本机地图的提示?

附注。OsmSharp 并不严格需要是 OpenStreetMap 连接到自定义磁贴服务器,这只是我现在倾向于的东西。同样,需求是开源的低成本的,可以灵活地添加标记、线和多边形。