how to show selectors on Xamarin.Forms.maps.map

352 Views Asked by At

My app has a map component that I create within a Stacklayout in the XAML like this:

    <maps:Map x:Name="amap">
        <x:Arguments>
            <maps:MapSpan>
                <x:Arguments>
                    <maps:Position>
                        <x:Arguments>
                            <x:Double x:Name="Lat">48.2</x:Double>
                            <x:Double x:Name="Long">-106.6501939</x:Double>
                        </x:Arguments>
                    </maps:Position>
                    <x:Double>0.01</x:Double>
                    <x:Double>0.01</x:Double>
                </x:Arguments>
            </maps:MapSpan>
        </x:Arguments>
    </maps:Map>

I then get a location from a db search, drop a pin at that location and pan to it:

    private void MoveMap(Quarter location)
    {
        var pin = new Pin();
        pin.Position = new Position(location.Lat, location.Lon);
        pin.Label = locationEntry.Text;
        MoveMap(pin);
    }
    private void MoveMap(Pin pin)
    {
        amap.Pins.Add(pin);
        amap.MoveToRegion(new MapSpan(pin.Position, 0.1, 0.1));
    }

google map in app

So far so good, but if I click on the pin it gets better...

better google map

I'm looking for a way to get the links to Google maps on the bottom to appear right off the bat. I would also like to make the label show on the pin. I've tried calling amap.SendMapClicked(pin.Position) right after the call to MoveToRegion, but nothing happens.

And finally I would like to display the "mode selector" from Google maps, which switches between satellite and default.

Is any of this possible? Lots of googling doesn't give me much hope.

1

There are 1 best solutions below

3
On

Try this it's working for me

    private void MoveMap(Quarter location)
    {
        var pin = new Pin
        {
            Type = PinType.Place,
            Position = new Position(location.Lat, location.Lon),
            Label = locationEntry.Text
        };
        amap.Pins.Add(item.Pins);
        amap.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(pin.Position.Latitude, pin.Position.Longitude),
Distance.FromMiles(50)));

    }