Entradas

Mostrando entradas de julio, 2015

Map Center Position Xamarin.Forms

Imagen
Map Center Position Xamarin.Forms Hey all after long time without publish here a new post hope it help you.


As you know in nowadays is common that the apps like Uber get the center position of the map view but the Xamarin.Forms standard map don't have a way to get this, so in this case I'll show a good way to get the map center position using a map renderer
ExtendedMap.cs Code
using System; using Xamarin.Forms.Maps; namespace MapTest.Controls { public class ExtendedMap:Map { public ExtendedMap () { } internal Func<Position> NativeGetMapCenterLocation{ get; set; } public Position GetMapCenterLocation() { if (NativeGetMapCenterLocation != null) { return NativeGetMapCenterLocation (); } else { return new Position(0,0); } } } }
Android ExtendedMapRenderer.cs

using System; using Xamarin.Forms.Maps.Android; using Xamarin.Forms.Platform.Android; using Xamarin.Forms; using Xamarin.Forms.Maps; using MapTest; using MapTest.Droid.Renderers; …