0
votes

I need to add a button on the map when I've clicked the pin. I use xamarin forms and googlemaps for iOS and Android.

This is my XAML:

<AbsoluteLayout HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
         <ContentView Content="{Binding Map}" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand" AbsoluteLayout.LayoutBounds = "1, 1, 1, 1" AbsoluteLayout.LayoutFlags = "All"/>

            <Button BackgroundColor="White" IsVisible="{Binding IsPinVisible}" Text="{Binding NewAddress}" TextColor="Blue" AbsoluteLayout.LayoutBounds = "1, 0, 1, 0.15" AbsoluteLayout.LayoutFlags = "All"/>

        </AbsoluteLayout>

My ViewModel with the bool and string:

private bool _isPinVisible;
    public bool IsPinVisible 
    {
        get
        {
            return _isPinVisible;
        }
        set
        {
            _isPinVisible = value;
            RaisePropertyChanged(nameof(IsPinVisible));
        }
    }

    private string _newaddress;
    public string NewAddress
    {
        get
        {
            return _newaddress;
        }
        set
        {
            _newaddress = value;
            RaisePropertyChanged(nameof(NewAddress));
        }
    }

My Viewmodel where I have the Map.PinClicked event:

Map.PinClicked += (sender, args) =>
            {
                IsPinVisible = true;
                _newaddress = Address;
            };

Once i click the pin as of right now there is a white blank area that shows but there is no text. When I update LiveXaml to change the textcolor the text is showing.

1

1 Answers

1
votes

I had to use NewAddress

 Map.PinClicked += (sender, args) =>
            {
                IsPinVisible = true;
                NewAddress = Address;
            };