amay077 / Xamarin.Forms.GoogleMaps

Map library for Xamarin.Forms using Google maps API
https://www.nuget.org/packages/Xamarin.Forms.GoogleMaps/
MIT License
546 stars 349 forks source link

Binding pin from view is positioning wrong on zoom in and out #598

Open fazil1979 opened 5 years ago

fazil1979 commented 5 years ago

VERSIONS

PLATFORMS

ACTUAL BEHAVIOR

When I zoom in, the pin is perfectly positioned, but when I zoom out, the pin is not positioning right, the more I zoom out, the more it is getting away from that coordinates

ACTUAL SCREENSHOTS

pinviewissue

EXPECTED BEHAVIOR

The pin should keep its coordenate if the user zooms out, otherwise it is not showing the location that it should represent

HOW TO REPRODUCE

  1. add a pin from view
  2. zoom out

var pin = new Pin() { Type = PinType.Place, Label = "Tokyo SKYTREE", Address = "Sumida-ku, Tokyo, Japan", Position = new Position(35.71d, 139.81d), Icon = BitmapDescriptorFactory.FromView(new BindingPinView(pinDisplay.Text)) }; map.Pins.Add(pin);

Sonnenspeer commented 5 years ago

Probably the anchor is not correct. Looks like the anchor is off the mid.

amay077 commented 5 years ago

I suspects this is related https://github.com/amay077/Xamarin.Forms.GoogleMaps/releases/tag/v3.0.6 . Please try Xamarin.Forms.GoogleMaps v3.0.6+, probably fixed it.

jbravobr commented 5 years ago

Hi @amay077, do you know if it's fixed? I'm using 3.20 and I'm thinking it's not working wet … Let me know if I can help

amay077 commented 5 years ago

Hi @jbravobr ,

I think it is fixed.

Untitled7

This gif is latest sample app's behavior, looks like works fine.

Is there any difference in your code?

jbravobr commented 5 years ago

hi @amay077 ! Yes, still heappens with me. This is my code

foreach (var item in context.MapQueryResponse)
                {
                    var pin = new Pin
                    {
                        Type = PinType.Place,
                        Label = string.Empty,
                        Address = string.Empty,
                        Position = new Position((double)item.Latitude, (double)item.Longitude),
                        Tag = item.Id,
                        Icon = BitmapDescriptorFactory.FromView(new BindingPinView(item.BestPrice, item.HasQualityDefault, Convert.ToDouble(item.DefaultPrice)))
                    };
                    map.Pins.Add(pin);

This is my code from the BindingPinView

`<StackLayout xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:converters="clr-namespace:quip.Converters" x:Class="quip.Controls.BindingPinView" WidthRequest="200" HeightRequest="200">

`
jbravobr commented 5 years ago

@amay077 let me share something with you. That behaviour was happening when I was using Styles to my map, when I pass to used the default map style it worked ok.

amay077 commented 5 years ago

Maybe cause is WidthRequest=200 and HeightRequest=200. I setted backgroud color to StackLayout then you can see below image.

image

This means, Binding Pin is very large and anchor is center of Yellow Rectangle.