Select to view content in your preferred language

Adding Mapservice Programatically

1339
11
11-18-2013 12:18 AM
praveennarayandas
Deactivated User
Hi,

I am trying to add mapservice programatically.but it is not displaying map.
kindly letme know where i am doing wrong?

i have taken simple map application

My xaml code:
<esri:Map x:Name="MyMap" Background="White"  WrapAround="True" >
            <esri:ArcGISTiledMapServiceLayer x:Name="BaseMap" ID="BaseMap" Opacity="50"
                Initialized="MapServiceLayer_Initialized" InitializationFailed="Layer_InitializationFailed" />                    
        </esri:Map>

cs code:

            ArcGISTiledMapServiceLayer baseMap = new ArcGISTiledMapServiceLayer();
            String BaseMapResturl = "http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer";
            baseMap.Url = App._compentDict["BaseMapRestUrl"];
            baseMap.ID = "BaseMap";
            baseMap.Opacity = 50;
            baseMap.Initialized +=MapServiceLayer_Initialized;
            baseMap.InitializationFailed += MapServiceLayer_InitializationFailed;
            MyMap.Layers.Add(baseMap);

kindly let me where i am doing wrong.

thanks in advance.

praveen
0 Kudos
11 Replies
DenisT
by
Deactivated User
it is a static variable using to store url

It doesn't store anything useful. Also it`s not a "dict". Also use naming conventions:
http://msdn.microsoft.com/en-us/library/d53b55ey(v=vs.71).aspx

Replace
String BaseMapResturl = "http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer";
baseMap.Url = App._compentDict["BaseMapRestUrl"];

with
baseMap.Url = "http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer";
0 Kudos
praveennarayandas
Deactivated User
As per your suggestion i have modified code and it is working fine.

thanks a lot for support.
0 Kudos