Select to view content in your preferred language

Trouble adding a LocalDynamicMapServiceLayer to an empty map

2410
2
03-18-2013 01:11 PM
Labels (1)
GeorgeFaraj
Frequent Contributor
Using the example found here:
http://www.arcgis.com/home/item.html?id=953a530ada30477d95cc69e788268bc9

I am able to add a shapefile via a LocalDynamicMapServiceLayer. The map in the example is defined as follows:

<esri:Map x:Name="_map" UseAcceleratedDisplay="False">
            <!-- ArcGIS Online Tiled Basemap Layer -->
            <esri:ArcGISTiledMapServiceLayer ID="World Topographic Basemap (3857)" x:Name="_worldTopographicBasemap" 
                       Url="http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer"/>  
        </esri:Map>


If I remove the ArcGISTiledMapServiceLayer above the sample no longer works. I am not able to see the LocalDynamicMapServiceLayer that I add when starting with an empty map. Why is this?

Note: If I create a FeatureLayer from my LocalDynamicMapServiceLayer and add that to the map prior to adding my LocalDynamicMapServiceLayer then the LocalDynamicMapServiceLayer seems to show up. Very strange.
0 Kudos
2 Replies
MichaelBranscomb
Esri Frequent Contributor
Hi,

I can't immediately account for the difference between the dynamic map service layer and feature layer but it's basically down to the spatial reference not being set on the map.

Better to define the spatial reference explicitly on the Map probably:

 <esri:Map x:Name="MyMap" Background="#FFE3E3E3" >
            <esri:Map.Extent>
                <esri:Envelope XMin="-15000000" YMin="2000000" XMax="-7000000" YMax="8000000">
                    <esri:Envelope.SpatialReference>
                        <esri:SpatialReference WKID="102100"/>
                    </esri:Envelope.SpatialReference>
                </esri:Envelope>
            </esri:Map.Extent>
            <esri:ArcGISLocalDynamicMapServiceLayer ID="DynamicLayer"
                      Path="..\\Data\\MPKS\\USCitiesStates_Lambert_Conformal_Conic.mpk"/>
        </esri:Map>


Cheers

Mike
0 Kudos
GeorgeFaraj
Frequent Contributor
Hi,

I can't immediately account for the difference between the dynamic map service layer and feature layer but it's basically down to the spatial reference not being set on the map.

Better to define the spatial reference explicitly on the Map probably:

 <esri:Map x:Name="MyMap" Background="#FFE3E3E3" >
            <esri:Map.Extent>
                <esri:Envelope XMin="-15000000" YMin="2000000" XMax="-7000000" YMax="8000000">
                    <esri:Envelope.SpatialReference>
                        <esri:SpatialReference WKID="102100"/>
                    </esri:Envelope.SpatialReference>
                </esri:Envelope>
            </esri:Map.Extent>
            <esri:ArcGISLocalDynamicMapServiceLayer ID="DynamicLayer"
                      Path="..\\Data\\MPKS\\USCitiesStates_Lambert_Conformal_Conic.mpk"/>
        </esri:Map>


Cheers

Mike


Thanks for the pointing me in the right direction. Perhaps you can help me narrow this down and find a solution. I don't know much about spatial references but I am beginning to see that there are different spatial reference systems and I may be crossing a boundary between the one used in my shapefile and the one that my .mpk is associated with. We assumed that we would be able to use the EmptyMPK_WGS84.mpk found in the project that I linked to above in order to start out with an empty map.

With EmptyMPK_WGS84.mpk...
When I create my dynamic map service layer from my shapefile using the EmptyMPK_WGS84.mpk, the SpatialReference.WKID is set correctly but my FullExtent for the layer comes up as {NaN, NaN, NaN, NaN}. After adding the layer to the map, the map's extent also become {NaN, NaN, NaN, NaN}. If I manually set the FullExtent XMin, XMax, YMin, and YMax prior to adding the layer to the map, it works. The problem with that is that I have to know what the full extent is in order to set the correct values.

On the feature layer....When I create a feature layer from the same dynamic map service layer, the FullExtent shows up as null prior to adding it to the map. After adding it to the map, the map is able to determine the correct extent (this is where I got the values that I used above).

With a non-empty .mpk file that I have created through ArcMap...
When I create my dynamic map service layer from my shapefile, the SpatialReference.WKID comes up as an entirely different number than when I used the other .mpk (which is why I think the difference in spatial reference systems might be to blame). When I check my FullExtent for the layer here it has values populated. Adding it to the map works.

This is a bit concerning as I would like for our application to be generic enough to allow someone to start out with an empty map and add any shapefile that they wanted.
0 Kudos