Compartilhar via


Xamarin.Forms.Maps Namespace

Cross-Platform Library for Displaying and Annotating Maps.

Classes

Circle
Geocoder

Converts between string addresses and Positions.

GeographyUtils
Map

A View that shows a map provided by a platform-specific service.

MapClickedEventArgs

Event Args for Map's MapClicked event.

MapElement
MapSpan

A circular region on a Map.

Pin

A marker on a Map.

PinClickedEventArgs
Polygon
Polyline

Structs

Distance

Struct that encapsulates a distance (natively stored as a double of meters).

Position

A struct that has a latitude and longitude, stored as doubles.

Enums

MapType

Enumeration that specifies the display style of the map.

PinType

Enumeration specifying the various kinds of Pin.

Remarks

Xamarin.Forms.Maps provides a cross-platform abstraction for displaying maps. To use Xamarin.Forms.Maps, application developers must calls Xamarin.FormsMaps.Init() as part of platform initialization, as shown in the following example:

//Shared
public class App
{
	public static Page GetMainPage ()
	{	
		return new ContentPage { 
			Content = new Map (MapSpan.FromCenterAndRadius (new Position (37, -122), Distance.FromMiles (10)))
		};
	}
}
//iOS
[Register ("AppDelegate")]
public partial class AppDelegate : UIApplicationDelegate
{
	UIWindow window;

	public override bool FinishedLaunching (UIApplication app, NSDictionary options)
	{
		Forms.Init ();
		FormsMaps.Init ();

		window = new UIWindow (UIScreen.MainScreen.Bounds);

		window.RootViewController = App.GetMainPage ().CreateViewController ();
		window.MakeKeyAndVisible ();

		return true;
	}
}
//Android
namespace HelloMap.Android
{
	[Activity (Label = "HelloMap.Android.Android", MainLauncher = true)]
	public class MainActivity : AndroidActivity
	{
		protected override void OnCreate (Bundle bundle)
		{
			base.OnCreate (bundle);

			Xamarin.Forms.Forms.Init (this, bundle);
			FormsMaps.Init(this, bundle);

			SetPage (App.GetMainPage ());
		}
	}
}

See also