Custom rendering in Bing Silverlight Control

I am building up a Silverlight 2 project that uses a Bing Maps control. One thing that our UX guys are interested in is whether you can fully customize the look of the card. For example, draw countries as simple outlines with different color interiors. Or draw the ocean as white and the countries as black dotted shapes.

Does anyone know if this level of customization can be achieved? The class MapModelooked promising, but it doesn't seem to give me what I need.

Thanks Kent

+1
source share
1 answer

To answer my own question, yes, it is possible.

-, :

<m:Map>
    <m:Map.Mode>
        <mCore:MercatorMode/>
    </m:Map.Mode>
    <m:Map.Children>
        <m:MapTileLayer>
            <m:MapTileLayer.TileSources>
                <local:CustomTileSource/>
            </m:MapTileLayer.TileSources>
        </m:MapTileLayer>
    </m:Map.Children>
</m:Map>

CustomTileSource. :

public class CustomTileSource : TileSource
{
    public CustomTileSource()
        : base(GetAbsoluteUrl("/ClientBin/Resources/{0}.png"))
    {
    }

    public override Uri GetUri(int x, int y, int zoomLevel)
    {
        var quadKey = new QuadKey(x, y, zoomLevel);
        return new Uri(String.Format(this.UriFormat, quadKey.Key));
    }

    public static string GetAbsoluteUrl(string strRelativePath)
    {
        if (string.IsNullOrEmpty(strRelativePath))
            return strRelativePath;

        string strFullUrl;
        if (strRelativePath.StartsWith("http:", StringComparison.OrdinalIgnoreCase)
          || strRelativePath.StartsWith("https:", StringComparison.OrdinalIgnoreCase)
          || strRelativePath.StartsWith("file:", StringComparison.OrdinalIgnoreCase)
          )
        {
            //already absolute
            strFullUrl = strRelativePath;
        }
        else
        {
            //relative, need to convert to absolute
            strFullUrl = System.Windows.Application.Current.Host.Source.AbsoluteUri;
            if (strFullUrl.IndexOf("/ClientBin") > 0)
                strFullUrl = strFullUrl.Substring(0, strFullUrl.IndexOf("/ClientBin")) + strRelativePath;
        }

        return strFullUrl;
    }
}

, URL. , , MapCruncher, .

+1

Source: https://habr.com/ru/post/1767678/


All Articles