Issue
i just downloaded the naxam mapbox and am completely lost the github page isn't much of help and there seems to be nothing else can anyone give anything usefull on how to implement the map view in the xamarin.forms app and thanks.
Solution
Short Anwser:
The Naxam.Mapbox for Xamarin.Forms Nuget Package, and all the associated Forms ones, have not been update since Sep 12, 2018, and the Mapbox SDK's for Android/iOS have changed since then, i tried this package and it's a bit clunky, i have manage to display the map, but inserting Geojson Sources/ Markers is not a pleasant experience.
EDIT 2019/10/13
Last month, Naxam updated their nuggets to the latest Mapbox version for .Forms, Android and iOS
Long Anwser:
If you really want to use Mapbox in your Xamarin Projects, the Naxam Binding Libraries for Android and iOS are still working today (18/06/2019), So one way to have it working for a Xamarin Forms Project is to implement both sdk's in their respective project, and use them in a Custom View Renderer (and be carefull, because those projects still need other Nuget Packages to work, and they don't warn you when you install them, be sure see the dependecies in the links i gave above).
Other way to have a map in your project is by using MapsUi (Remember that MapsUi is TileBased and Mapbox is VectorBased, so you might see less fluidity while using MapsUi). i will leave here some relevant code for the custom render in iOS for the implementation of MapsUi to get started:
MapViewRenderer.cs
public class MapViewRenderer : ViewRenderer<MapsUIView, Mapsui.UI.iOS.MapControl>
{
Mapsui.UI.iOS.MapControl mapNativeControl;
MapsUIView mapViewControl;
protected override void OnElementChanged(ElementChangedEventArgs<MapsUIView> e)
{
base.OnElementChanged(e);
if (mapViewControl == null && e.NewElement != null)
mapViewControl = e.NewElement;
if (mapNativeControl == null && mapViewControl != null)
{
var rectangle = mapViewControl.Bounds;
var rect = new CGRect(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height);
mapNativeControl = new Mapsui.UI.iOS.MapControl(rect)
{
Map = mapViewControl.NativeMap,
Frame = rect
};
SetNativeControl(mapNativeControl);
}
}
}
This is the base on how to implement the MapView in a Custom View Render in iOS, similiar code is needed for Android, and of course, the Custom Renderer itself, wich there is tons of tutorials on how to do it, like this ones: Source 1 Source 2
Answered By - Ricardo Dias Morais
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.