且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

ArcGIS API for Silverlight之配准JPG图片地图文字倾斜解决方案

更新时间:2022-10-03 19:11:02

原文:ArcGIS API for Silverlight之配准JPG图片地图文字倾斜解决方案

根据实际JPG图片进行配准后,发布的地图,利用ArcGIS API for Silverlight在网页上显示的时候,原先的文字总有倾斜的现象,如何解决?

 

ArcGIS API for Silverlight之配准JPG图片地图文字倾斜解决方案

图一、配准后有文字倾斜现象的地图

解决方案如下:

    

 <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
                            };



 

ArcGIS API for Silverlight之配准JPG图片地图文字倾斜解决方案

图二、经程序调整后文字无倾斜的地图