A Custom Map Control Renderer with Xamarin.Forms

Xamarin.Forms.Maps provides a cross-platform abstraction for displaying maps that use the native map APIs on each platform, in order to provide a fast and familiar map experience for users. This article demonstrates how to create a custom renderer for the Map control, enabling developers to override the default native rendering with their own platform-specific customization.

Every Xamarin.Forms view has an accompanying renderer for each platform that creates an instance of a native control. When a Map is rendered by a Xamarin.Forms application in iOS, the MapRenderer class is instantiated, which in turn instantiates a native MKMapView control. On the Android platform, the MapRenderer class instantiates a native MapView control. On the Universal Windows Platform (UWP), the MapRenderer class instantiates a native MapControl. For more information about the renderer and native control classes that Xamarin.Forms controls map to.

The following diagram illustrates the relationship between the Map and the corresponding native controls that implement it:

The rendering process can be used to implement platform-specific customizations by creating a custom renderer for a Mapon each platform. The process for doing this is as follows:

No Comments

Add a Comment

As it will appear on the website

Not displayed

Your website