Skip to content

feature23/mapbox-xamarin-forms

 
 

Repository files navigation

Mapbox for Xamarin.Forms

Mapbox for Xamarin.Forms

This library provides the controls/renderers for using Mapbox SDKs inside your Xamarin.Forms app.

About

This project is maintained by Naxam Co.,Ltd.
We specialize in developing mobile applications using Xamarin and native technology stack.

Looking for developers for your project?


Usage

Install Nuget package

Install-Package Naxam.Mapbox.Forms -pre

Add the Mapbox Service to your Manifest

<service android:name="com.mapbox.mapboxsdk.telemetry.TelemetryService" />

Your XAML

<local:MapView 
    x:Name="map" 
    VerticalOptions="FillAndExpand" 
    MapStyle="{Binding CurrentMapStyle}" 
    ZoomLevel="{Binding ZoomLevel}"
/>

Your code behind

map.DidTapOnMapCommand = new Command<Tuple<Position, Point>>((Tuple<Position, Point> obj) =>
{
    var features = map.GetFeaturesAroundPoint.Invoke(obj.Item2, 6, null);
    var filtered = features.Where((arg) => arg.Attributes != null);
    foreach (IFeature feat in filtered) {
        var str = JsonConvert.SerializeObject(feat);
        System.Diagnostics.Debug.WriteLine(str);
    }

});
map.DidFinishLoadingStyleCommand = new Command<MapStyle>((obj) =>
{
    map.ResetPositionFunc.Execute(null);
    foreach (Layer layer in obj.OriginalLayers)
    {
        System.Diagnostics.Debug.WriteLine(layer.Id);
    }

});
map.ZoomLevel = Device.RuntimePlatform == Device.Android ? 4 : 10;

Detail documentation is coming soon.

License

Mapbox for Xamarin.Forms is released under the Apache License license. See LICENSE for details.

Packages

No packages published

Languages

  • C# 100.0%