ReVo
ReVo

Reputation: 11

How to set up in Custom Map (xaml, xamarin forms) your own position?

How to set up in Custom Map (xaml) your own position? e.g. Warsaw

 <local:CustomMap x:Name="customMap" Margin="2" IsShowingUser="true" MapClicked="OnMapClicked">

        </local:CustomMap>

Upvotes: 1

Views: 121

Answers (1)

Mihail Duchev
Mihail Duchev

Reputation: 4821

Assuming that your CustomMap is inheriting from Xamarin.Forms.Maps class, then you need to set a MapSpan property. Here how it is in xaml (I have added the coordinates for Warsaw):

<local:CustomMap>
    <x:Arguments>
        <maps:MapSpan>
            <x:Arguments>
                <maps:Position>
                    <x:Arguments>
                        <x:Double>52.2297</x:Double>
                        <x:Double>21.0122</x:Double>
                    </x:Arguments>
                </maps:Position>
                <x:Double>0.01</x:Double>
                <x:Double>0.01</x:Double>
            </x:Arguments>
        </maps:MapSpan>
    </x:Arguments>
</local:CustomMap>

Note: You can adjust the second & third parameter, which currently are set to 0.01 degrees, to better scale the span (they are the latitudeDegrees & longitudeDegrees).

Official docs: https://learn.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/map/map#display-a-specific-location-on-a-map

Upvotes: 1

Related Questions