Skip to main content

Creating a map view

A Trimble Maps map view can be created and used directly in xaml by retrieving the TrimbleMapsMap. Keep in mind that an account must be initialized before using the map view.

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="TrimbleMaps.MapSDK.Sample.BaseLayer"
             Title="BaseLayer" xmlns:TrimbleMaps="clr-namespace:TrimbleMaps.Controls.Forms;assembly=TrimbleMaps.MapsSDK" >
    <ContentPage.Content>
        <TrimbleMaps:MapView
            x:Name="Map"
            ShowUserLocation="true"
            UserLocationTracking="None"
            ZoomMaxLevel="21"
            CompassEnabled="True"
            CompassFadeFacingNorth="False"
            />
    </ContentPage.Content>
</ContentPage>

Adding xmlns:TrimbleMaps=“clr-namespace:TrimbleMaps.Controls.Forms;assembly=TrimbleMaps.MapsSDK to use TrimbleMaps.MapView namespace.

After retrieving the map view

using TrimbleMaps.Controls.Forms;

namespace TrimbleMaps.MapSDK.Sample
{
    public partial class BaseLayer : ContentPage
    {
        public BaseLayer()
        {
            InitializeComponent();
            Setup();
        }

        private void Setup()
        {
            Map.Center = new TrimbleMaps.MapsSDK.LatLng(40.7135, -74.0066);
            Map.ZoomMinLevel = 10;
            Map.MapStyle = MapStyle.MOBILE_DAY;
        }
    }
}
Last updated February 4, 2025.