【问题标题】:Xamarin Forms Maps - Custom Pin Images local:CustomMap ErrorXamarin Forms Maps - 本地自定义 Pin 图像:CustomMap 错误
【发布时间】:2021-01-29 14:02:12
【问题描述】:

为什么我的本地:CustomMap 错误 对不起,我是英语初学者, https://docs.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/custom-renderer/map-pin 我的项目名称 PTSSRU

    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>
    
    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)));
            }
        }
    }

【问题讨论】:

  • 错误是什么?是编译错误还是运行时异常?请提供具体错误或异常消息
  • 你好,你可以分享一下项目结构的截图,然后我会检查CustomMap的路径。

标签: xamarin.forms


【解决方案1】:
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.
my git hub
https://github.com/s58122519013/Xamarin.Map.git

【讨论】:

  • 您好,从共享代码来看,您的解决方案中没有CustomMap类文件,您需要在您的项目中创建它。
猜你喜欢
  • 1970-01-01
  • 2016-08-21
  • 1970-01-01
  • 1970-01-01
  • 2018-07-29
  • 2021-10-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多