Xamarin Forms Map UWP - MapIcon SizeRequest

Emixam23Emixam23 USMember ✭✭✭

Hi,

I searched so much and no one seems to have the answer..
How can I set the size of a pin? UWP part of PCL project

Thank in advance !

Best Answer

Answers

  • NMackayNMackay GBInsider, University ✭✭✭✭✭

    You can change the pin to your own image, you can't set the size as such.

    I do something like this in my custom renderer

                        var snPosition = new BasicGeoposition { Latitude = pin.Pin.Position.Latitude, Longitude = pin.Pin.Position.Longitude };
                        var snPoint = new Geopoint(snPosition);
    
                        var mapIcon = new MapIcon
                        {
                            Image =
                                RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///" + pin.Filename)),
                            CollisionBehaviorDesired = MapElementCollisionBehavior.RemainVisible,
                            Location = snPoint,                        
                            NormalizedAnchorPoint = new Windows.Foundation.Point(0.5, 1.0)
                        };
    
                        _nativeMap.MapElements.Add(mapIcon);
    
    

    I'd check out this guide, there's info in here on how to support custom pins in UWP

    https://developer.xamarin.com/guides/xamarin-forms/custom-renderer/map/

  • Emixam23Emixam23 USMember ✭✭✭

    Thank for your answer but I think that I got an idea to achieve it ;)

  • NMackayNMackay GBInsider, University ✭✭✭✭✭

    Cool, be sure to feedback your solution if your able to :smile:

  • Emixam23Emixam23 USMember ✭✭✭

    Of course ;) At the moment, I'm trying to resize the Image (Xamarin.Forms.Image) of the Pin and then, get a stream. From this stream, I can get the IRandomAccessStreamReference :)

  • Umar3xUmar3x FRMember ✭✭
    edited December 2016

    Hey,

    Nice to see a solution, but is it for windows phone only ? I'm trying to achieve the same customization on Android Google maps and iOS in the future ...

    Thanks.

  • Emixam23Emixam23 USMember ✭✭✭

    I found for android as well, but without Mac, iOS is complicated...

  • Gigex42Gigex42 USMember ✭✭✭

    @Emixam23 said:
    I found for android as well, but without Mac, iOS is complicated...

    So would you mind sharing the android part? :smile:

  • Emixam23Emixam23 USMember ✭✭✭

    Hey @Gigex42

    I'm a bit busy but you can find it in my public repo of Maps in the Pins section :)

    https://github.com/Emixam23/XamarinByEmixam23/tree/master/Detailed Part/Controls/Map

    hf & gl

Sign In or Register to comment.