【问题标题】:how to set xaml mapcontrol mapicon always visible如何设置xaml mapcontrol mapicon 始终可见
【发布时间】:2015-02-22 15:50:17
【问题描述】:

我是 XAML 编程的新手,我正在使用 MapControl 在 windows phone 8.1 模拟器上制作一个测试应用程序。

我想在我的地图中添加一个 MapIcon,但是当地图缩小时该图标没有出现。我已经搜索了互联网,但找不到任何关于我的问题的信息。

我想要我的缩放级别 12 并在该缩放级别上显示地图图标。

namespace TEST.APPLICATION
{
public partial class MapView : Page
{
    Geolocator geo = null;
    public MapView()
    {
        this.InitializeComponent();
        this.NavigationCacheMode = NavigationCacheMode.Required;
        HardwareButtons.BackPressed += HardwareButtons_BackPressed;
    }
    void HardwareButtons_BackPressed(object sender, BackPressedEventArgs e)
    {
        if (Frame.CanGoBack)
        {
            e.Handled = true;
            Frame.GoBack();
        }
    }

    protected override void OnNavigatedTo(NavigationEventArgs e)
    {
        map.Center = new Geopoint(new BasicGeoposition()
           {
              Latitude = 51.5856935784736,
              Longitude = 4.79448171225132
           });
        map.ZoomLevel = 12;

        displaySightings();
    }

    private void displaySightings()
    {
        MapIcon sighting1 = new MapIcon();
        sighting1.Location = new Geopoint(new BasicGeoposition()
        {
            Latitude = 51.5940,
            Longitude = 4.7795
        });
        //sighting1.NormalizedAnchorPoint = new Point(0.5, 1.0);
        sighting1.Title = "VVV";
        map.MapElements.Add(sighting1);
    }
}

有什么方法可以让 MapIcon 始终可见?

【问题讨论】:

    标签: xaml windows-phone-8.1


    【解决方案1】:

    The MapIcon is not guaranteed to be shown. It may be hidden when it obscures other elements or labels on the map.

    出于某种愚蠢的原因,Microsoft 认为标签和其他地图元素在呈现显示时应该优于地图图标。因此,根据他们的说法,如果您正在制作一个显示附近所有星巴克位置的应用程序,那么 星巴克对面的高中 的名称比图钉更重要。 p>

    您需要改为使用 XAML 呈现图钉。

    【讨论】:

    • “您需要使用 XAML 来呈现图钉”是什么意思?
    • 上面链接的页面的后半部分,特别是“在地图上显示 XAML 形状(在此示例中为椭圆)”,如果您想在代码中执行此操作。
    • 添加栅栏似乎对我不起作用。我试图将椭圆添加到我的地图中。示例的椭圆部分,但它给出了错误:“Windows.UI.Xaml.Controls.Maps.MapControl.SetLocation(Windows.UI.Xaml.DependencyObject, Windows.Devices.Geolocation.Geopoint)”无法使用实例参考;改为使用类型名称来限定它
    猜你喜欢
    • 1970-01-01
    • 2023-03-23
    • 1970-01-01
    • 1970-01-01
    • 2021-09-08
    • 2015-09-12
    • 1970-01-01
    • 2022-06-13
    • 2022-01-10
    相关资源
    最近更新 更多