Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

[GoogleMap] Keep map centered on same position when zooming

$
0
0

Hi,

I'm trying to replicate the functionality of the built-in google map zoom control; when you click on the "+" or "-" buttons to zoom, it keeps the current center of the map intact. This isn't the case when you pinch or double tap and hold the map; these both move the current center of the map.

Can anyone guide me on the best direction to implement this? Initially, I have tried to handle the pinchgesture but it doesn't seem to work for the map control, besides this isn't even considering how to handle the double tap and hold case. Following is an excerpt from my code:

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns:maps="clr-namespace:Xamarin.Forms.GoogleMaps;assembly=Xamarin.Forms.GoogleMaps">
     <AbsoluteLayout>
        <Grid RowSpacing="5" AbsoluteLayout.LayoutBounds="0,0,1,1" AbsoluteLayout.LayoutFlags="All">
            <Grid.RowDefinitions>
                <RowDefinition Height="50" />
                <RowDefinition Height="50" />
                <RowDefinition Height="50" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="50" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="50" />
                <RowDefinition Height="50" />
                <RowDefinition Height="50" />
                <RowDefinition Height="50" />
                <RowDefinition Height="50" />
                <RowDefinition Height="*" />
            </Grid.RowDefinitions>
            <maps:Map MyLocationEnabled="True" CameraIdled="LocationsMap_CameraIdled" x:Name="locationsMap" Grid.RowSpan="12" >
                <maps:Map.GestureRecognizers>
                    <PinchGestureRecognizer PinchUpdated="PinchGestureRecognizer_PinchUpdated" />
                </maps:Map.GestureRecognizers>
            </maps:Map>
    </Grid>
    </AbsoluteLayout>
</ContentPage>

I put a breakpoint in the code-behind "PinchGestureRecognizer_PinchUpdated" method and it's never reached:

private void PinchGestureRecognizer_PinchUpdated(object sender, PinchGestureUpdatedEventArgs e)
{
    //breakpoint
}

Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>