Disabling labels in Windows Phone 8 Map Control

2019-08-28 00:16发布

问题:

Is there any way to disable place names, road names, etc. from showing on the Microsoft.Phone.Maps.Controls.Map control?

I'm showing a custom TileSource over the top of the Bing basemap but the labels are still showing through on top of the custom tile source.

Ideally I'd like to turn the Bing base map off and replace it with my own but am under the impression that's not possible with this control. So I'm using the next best approach.

Thanks in advance for any ideas!

回答1:

Even though it's marked as depreciated, I've gone with the WP7 Microsoft.Phone.Controls.Maps.Map as it has the functionality I require. I've encapsulated the control and functionality within a UserControl so it's easy to swap out once the new Microsoft.Phone.Maps.Controls.Map control has caught up functionality wise.

/// <summary>
/// Sets TileSource as the exclusive MapTileLayer
/// </summary>
private void RefreshTileSource()
{
    for (var i = Map.Children.Count - 1; i >= 0; i--)
    {
        MapTileLayer tileLayer = Map.Children[i] as MapTileLayer;
        if (tileLayer != null)
        {
            Map.Children.RemoveAt(i);
        }
    }

    // Tiles
    MapTileLayer layer = new MapTileLayer();
    layer.TileSources.Add(ViewModel.TileSource);
    Map.Children.Add(layer);

    // Constrain map to area with custom tiles
    MapMode mode = new MapMode();
    mode.SetZoomRange(ViewModel.TileSource.ZoomRange);
    if (ViewModel.MapBounds.North > ViewModel.MapBounds.South)
        mode.LatitudeRange = new Range<double>(ViewModel.MapBounds.South, ViewModel.MapBounds.North);
    else
        mode.LatitudeRange = new Range<double>(ViewModel.MapBounds.North, ViewModel.MapBounds.South);
    if (ViewModel.MapBounds.West > ViewModel.MapBounds.East)
        mode.LongitudeRange = new Range<double>(ViewModel.MapBounds.East, ViewModel.MapBounds.West);
    else
        mode.LongitudeRange = new Range<double>(ViewModel.MapBounds.West, ViewModel.MapBounds.East);
    Map.Mode = mode;
}