Bing Maps Silverlight 응용 프로그램이 있고지도에 교통 정보를 표시하려고합니다. AJAX 버전에서는 구현되었지만 Silverlight 버전에서는 구현되지 않은 것으로 보입니다.Silverlight의 Bing Maps 트래픽 레이어
그래서 Silverlight에서 작동하는 트래픽 레이어를 구현할 수 있습니까? 이 솔루션에 관심이 모두 들어
Bing Maps Silverlight 응용 프로그램이 있고지도에 교통 정보를 표시하려고합니다. AJAX 버전에서는 구현되었지만 Silverlight 버전에서는 구현되지 않은 것으로 보입니다.Silverlight의 Bing Maps 트래픽 레이어
그래서 Silverlight에서 작동하는 트래픽 레이어를 구현할 수 있습니까? 이 솔루션에 관심이 모두 들어
는 : Custom Rendering in Bing Silverlight Control
public class TrafficTileSource : TileSource
{
public TrafficTileSource()
: base(GetAbsoluteUrl("http://t0.tiles.virtualearth.net/tiles/t{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;
}
}
그리고이지도에 레이어를 추가합니다 :
검색 및 I 시도의 시간 후여기에 해결책을 발견
<m:MapTileLayer Visibility="{Binding Path=TrafficVisibility,Converter={StaticResource BoolToVisibilityConverter},Mode=OneWay,UpdateSourceTrigger=PropertyChanged}">
<m:MapTileLayer.TileSources>
<utils:TrafficTileSource />
</m:MapTileLayer.TileSources>
</m:MapTileLayer>
Silverlight 응용 프로그램에 트래픽 계층을 추가하려는 모든 사용자에게 도움이되기를 바랍니다.
인사말.
그냥 물건을 조금 청소 :
public class TrafficTileSource : TileSource
{
public TrafficTileSource() : base("http://t0.tiles.virtualearth.net/tiles/t{0}.png") { }
public override Uri GetUri(int x, int y, int zoomLevel)
{
QuadKey quadKey = new QuadKey(x, y, zoomLevel);
return new Uri(String.Format(UriFormat, quadKey.Key));
}
}
그리고지도 층 :
<maps:MapTileLayer>
<maps:MapTileLayer.TileSources>
<utils:TrafficTileSource />
</maps:MapTileLayer.TileSources>
</maps:MapTileLayer>
이 절대적으로 요하네스 응답과 동일하지