Xamarin. Forms 地图Xamarin.Forms Map

初始化和配置Initialization and Configuration

若要在应用程序中使用地图功能,需要使用Xamarin NuGet NuGet 包。The Xamarin.Forms.Maps NuGet package is required to use maps functionality in an application. 此外,访问用户的位置时,需要向应用程序授予 location 权限。In addition, accessing the user's location requires location permissions to have been granted to the application.

Map ControlMap Control

Map控件是一个跨平台视图,用于显示和批注地图。The Map control is a cross-platform view for displaying and annotating maps. 它使用每个平台的本机地图控件,为用户提供快速且熟悉的地图体验。It uses the native map control for each platform, providing a fast and familiar maps experience for users.

位置和距离Position and Distance

Position结构通常在定位地图及其引脚时使用,而在定位地图时可以选择使用Distance结构。The Position struct is typically used when positioning a map and its pins, and the Distance struct that can optionally be used when positioning a map.


Map控件允许将位置标记Pin对象。The Map control allows locations to be marked with Pin objects. Pin 是在点击时打开信息窗口的地图标记。A Pin is a map marker that opens an information window when tapped.

多边形和折线Polygons and Polylines

PolygonPolyline 元素使您能够突出显示地图上的特定区域。Polygon and Polyline elements allow you to highlight specific areas on a map. Polygon 是一种包含笔划和填充颜色的完全封闭的形状。A Polygon is a fully enclosed shape that can have a stroke and fill color. Polyline 是不完全包围某个区域的行。A Polyline is a line that does not fully enclose an area.


Geocoder类在Position对象中存储的字符串地址和纬度和经度坐标之间进行转换。The Geocoder class converts between string addresses and latitude and longitude coordinates that are stored in Position objects.

启动本机映射应用Launch the Native Map App

可以通过 Xamarin Launcher 类从 Xamarin 应用程序中启动每个平台上的本机映射应用。The native map app on each platform can be launched from a Xamarin.Forms application by the Xamarin.Essentials Launcher class.