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 346 forks source link

Map pins incorrect size, sometimes not rendered, or rendered in wrong place on UWP #648

Open AlexKven opened 5 years ago

AlexKven commented 5 years ago

VERSIONS

PLATFORMS

ACTUAL BEHAVIOR

I have a test for my app on Android and UWP where I am loading different size images into SkiaSharp, and put them on the map as pins. Starting on the right, there is a 20x20 icon, then moving to the left, a 40x40 icon, then 60x60 etc. until 300x300 (15 icons total).

It works on Android, but not on UWP. It looks like this: image

Right when I start dragging, the icons all move to the bottom: image

When I zoom out, all 15 icons are there, but they are all the same size (the far right should be 20x20, far left should be 300x300): image

This is particularly confusing having had used the Bing Maps API before and not having an issue with pins not rendering, under reasonable load. Also of note, you can tell the image on the right has a lower resolution, but is rendered at the same size on the map for some reason, so that rules out accidentally sending the same image to each pin.

EXPECTED BEHAVIOR

It works on Android as expected:

image

HOW TO REPRODUCE

There are some dependency injected services for loading the actual image. The actual code to place the pins is below:

            for (int i = 0; i < 15; i++)
            {
                var length = 20 * (i + 1);

                SkiaSharp.SKBitmap skb = await BitmapProvider.LoadBitmapAsync("BusBaseIcon", length, length);

                var surface = SkiaSharp.SKSurface.Create(new SkiaSharp.SKImageInfo(length, length));
                var skc = surface.Canvas;
                skc.DrawBitmap(skb, new SkiaSharp.SKRect(0, 0, length, length));
                var data = surface.Snapshot().Encode(SkiaSharp.SKEncodedImageFormat.Png, 80);
                MemoryStream ms = new MemoryStream();
                data.SaveTo(ms);
                ms.Position = 0;

                var pin = new Pin();
                //var button = new Button() { WidthRequest = 80, HeightRequest = 30, Text = "Test" };
                pin.Icon = BitmapDescriptorFactory.FromStream(ms);
                pin.Label = "Button";
                var center = ViewModel.Center.ToXFGMPosition();
                pin.Position = new Position(center.Latitude, center.Longitude - .005 * i);

                MainMapControl.Pins.Add(pin);
            }