根據實際JPG圖片進行配准後,發布的地圖,利用ArcGIS API for Silverlight在網頁上顯示的時候,原先的文字總有傾斜的現象,如何解決?
圖一、配准後有文字傾斜現象的地圖
解決方案如下:
<esri:Map x:Name="myMap" IsLogoVisible="False" ZoomDuration="0:00:01" Extent="117.347734033208,30.5097885829245,117.611946391321,30.6766087944341" PanDuration="0:00:01" ExtentChanged="myMap_ExtentChanged"> <i:Interaction.Behaviors> <esri:MaintainExtentBehavior /> </i:Interaction.Behaviors> <esri:Map.Layers> <esri:ArcGISTiledMapServiceLayer ID="dLayer" Url="http://XXX.XXX.XX.XXX/ArcGIS/rest/services/XXX/MapServer/"/> </esri:Map.Layers> </esri:Map>
myMap.Rotation = -8; //設定地圖的旋轉角度
Map控制項的Rotation屬性,可以設定整個地圖的旋轉角度,設定這個就可以了
但是問題來了,在使用TextSymbol向地圖上添加文字標準資訊的時候,向上面這樣的方式調整後,文字也發生傾斜了,怎麼辦?
解決辦法:利用TextSymbol的ControlTemplate來搞定
<!--TextSymbol控制項範本之文字旋轉角度--> <esri:TextSymbol x:Name="RotateLabelTextSymbol"> <esri:TextSymbol.ControlTemplate> <ControlTemplate> <TextBlock Text="{Binding Symbol.Text}" FontFamily="{Binding Symbol.FontFamily}" FontSize="{Binding Symbol.FontSize}" Foreground="{Binding Symbol.Foreground}"> <TextBlock.RenderTransform> <CompositeTransform Rotation="8"/> </TextBlock.RenderTransform> </TextBlock> </ControlTemplate> </esri:TextSymbol.ControlTemplate> </esri:TextSymbol>
//動態添加文本 TextSymbol textSymbol = new TextSymbol() { FontFamily = new System.Windows.Media.FontFamily("Microsoft YaHei"), Foreground = new System.Windows.Media.SolidColorBrush(ColorRevert.ToColor(tip_Base.JTT_COLOR)), FontSize = 16, Text = item.ZDMC, OffsetX = 15, OffsetY = -15, ControlTemplate = (LayoutRoot.Resources["RotateLabelTextSymbol"] as TextSymbol).ControlTemplate };
圖二、經程式調整後文字無傾斜的地圖