ArcGIS API for Silverlight之配准JPG圖片地圖文字傾斜解決方案

來源:互聯網
上載者:User

根據實際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                            };

 

圖二、經程式調整後文字無傾斜的地圖

 

 

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.