Customizing a Map Pin local:CustomMap Error

CHATCHAI 21 Reputation points
2021-01-27T21:14:53.533+00:00

why my local:CustomMap Error sorry
I dollow https://learn.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/custom-renderer/map-pin
my project name PTSSRU
i'm beginner in english,

my xaml code

   <ContentPage xmlns="http://xamarin.com/schemas/2014/forms"  
                    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"  
                    x:Class="PTSSRU.Views.MapPage"              
                    xmlns:local="clr-namespace:PTSSRU;assembly=PTSSRU"               
             
           <local:CustomMap x:Name="customMap"  
                            MapType="Street" />  
       </ContentPage>  
         
     
   my cs code  
       using PTSSRU.Custom;  
       using System.Collections.Generic;  
       using Xamarin.Forms;  
       using Xamarin.Forms.Maps;  
         
       namespace PTSSRU.Views  
       {  
           public partial class MapPage : ContentPage  
           {         
               public MapPage()  
               {  
                   InitializeComponent();  
         
                   CustomPin pin = new CustomPin  
                   {  
                       Type = PinType.Place,  
                       Position = new Position(37.79752, -122.40183),  
                       Label = "Xamarin San Francisco Office",  
                       Address = "394 Pacific Ave, San Francisco CA",  
                       Name = "Xamarin",  
                       Url = "http://xamarin.com/about/"  
                   };  
                   customMap.CustomPins = new List<CustomPin> { pin };  
                   customMap.Pins.Add(pin);  
                   customMap.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(37.79752, -122.40183),   
                   Distance.FromMiles(1.0)));  
               }  
           }  
       }  
Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,301 questions
{count} votes

Accepted answer
  1. Leon Lu (Shanghai Wicresoft Co,.Ltd.) 69,386 Reputation points Microsoft Vendor
    2021-01-29T02:39:01.787+00:00

    Hello,​

    Welcome to our Microsoft Q&A platform!

    Agree with jcmanke, your MapPage.xaml lack of >

    61625-image.png

    And I notice your demo, lack of CustomMap.cs, I cannot found PTSSRU.Custom;, If you have it in your project?

    I am not sure xmlns:local="clr-namespace:PTSSRU;assembly=PTSSRU" it Correct.

    If you put CustomMap.cs to Custom folder like following structure, xmlns:local="clr-namespace:PTSSRU.Custom" is correct.

    61662-image.png

    Best Regards,

    Leon Lu


    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Best Regards,

    Leon Lu


    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. CHATCHAI 21 Reputation points
    2021-01-28T15:17:01.337+00:00

    @Leon Lu (Shanghai Wicresoft Co,.Ltd.)
    I have finished the map

    But I want to change the pin icon.
    Error Name cannot begin with the '<' character, hexadecimal value 0x3C. Line 7, position 5. PTSSRU C:\Users\MrC4\source\repos\PTSSRU\PTSSRU\PTSSRU\Views\MapPage.xaml 7
    incode
    <local:CustomMap x:Name="customMap"
    MapType="Street" />
    im not sure xmlns:local="clr-namespace:PTSSRU;assembly=PTSSRU" it Correct.


  2. CHATCHAI 21 Reputation points
    2021-01-28T16:14:00.297+00:00
    0 comments No comments