Dynamic Local Layer

4173
10
07-01-2015 05:02 AM
SandeepKumar
New Contributor II

Hi,

  I am working on a offline application using ArcGIS Runtime for .NET and my requirement is to create Layer visibility control for local Base map layer. Can someone suggest me how to call dynamic local layer in ArcGIS Runtime for .NET and to display its sub layers in Layer visibility control (Layer On/Off Control).

0 Kudos
10 Replies
MichaelBranscomb
Esri Frequent Contributor

Hi,

Please can you clarify which specific type of layer or types of layer you are referring to?

Cheers

Mike

0 Kudos
SandeepKumar
New Contributor II

I am using a local tiled layer as basemap and want its sublayers to appear in layer visibility control.This is the code I am using to bind Layers of Basemap.

                    <TreeView Grid.Row="1" ItemsSource="{Binding ElementName=MyMap, Path=Layers}" Margin="20">

                        <TreeView.ItemContainerStyle>

                            <Style TargetType="TreeViewItem">

                                <Setter Property="TreeViewItem.IsExpanded" Value="True" />

                                <Setter Property="Focusable" Value="False" />

                            </Style>

                        </TreeView.ItemContainerStyle>

                        <TreeView.ItemTemplate>

                            <HierarchicalDataTemplate ItemsSource="{Binding ChildLayers}">

                                <Grid Width="150">

                                    <Grid.RowDefinitions>

                                        <RowDefinition />

                                        <RowDefinition />

                                    </Grid.RowDefinitions>

                                    <Grid.ColumnDefinitions>

                                        <ColumnDefinition Width="Auto" />

                                        <ColumnDefinition Width="*" />

                                    </Grid.ColumnDefinitions>

                                    <TextBlock Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2"

                                       Text="{Binding DisplayName}" FontSize="16" Margin="0,8,0,0"/>

                                    <CheckBox Grid.Row="1" Grid.Column="0" IsChecked="{Binding IsVisible, Mode=TwoWay}" />

                                    <Slider Grid.Row="1" Grid.Column="1" Value="{Binding Opacity, Mode=TwoWay}"

                                    TickFrequency="0.01" Minimum="0" Maximum="1" />

                                </Grid>

                            </HierarchicalDataTemplate>

                        </TreeView.ItemTemplate>

                    </TreeView>

But it binds the Basemap as a single layer. I want to show its sub layers in Tree view.So that I can show all layers used in Basemap in treeview list.

0 Kudos
AsserSwelam1
Occasional Contributor

Hi Sandeep,

You can not chose to show or hide specific sub layers in a tiled layer, Tiled layers is a cached tiles that you define what visible and what is not before creating it. So you only have the ability to show or hide the whole layer.

You can do that with Dynamic layer and show or hide the sub layers the way you want. And this desktop sample will show you how to do it

Thanks,

Asser

0 Kudos
SandeepKumar
New Contributor II

Hi Asser,

      Thanks for your kind support.But it seems like the code uses dynamic online service layer.I am working on a offline application,so i cant use online dynamic service layer.Also i want to know is it possible to use local dynamic layer in arcgis runtime sdk for .net.I see that it is possible to use local dynamic layer in ArcGIS Runtime sdk for wpf.But when i try to call it in sdk for .net it looks like unsupported.

0 Kudos
AsserSwelam1
Occasional Contributor

Hi Sandeep,

You can add your local dynamic layer .mpk file and use it the same way you use the online dynamic layer to show and hide the sublayers.

Here is a sample code of how to do that and the sample is here

LocalMapService localMapService = new LocalMapService(@" [local .mpk file path]");

                await localMapService.StartAsync();

                ArcGISDynamicMapServiceLayer arcGISDynamicMapServiceLayer = new ArcGISDynamicMapServiceLayer()

                {

                    ID = "arcGISDynamicMapServiceLayer",

                    ServiceUri = localMapService.UrlMapService,

                };

  MyMapView.Map.Layers.Add(arcGISDynamicMapServiceLayer);

Thanks,

Asser

0 Kudos
SandeepKumar
New Contributor II

Hi Asser,

    Again Thanks.Your code is so helpful, but when i apply this code ,there comes a message saying "The licence you are using is for testing and development only" and code fails to work. I do not have developer licence.Do I require to have developer licence to use local dynamic service.

0 Kudos
AsserSwelam1
Occasional Contributor

Hi Sandeep,

That because you need license for using local data and other functionalities, here is more info about the license and how to use them. License your app—ArcGIS Runtime SDK for .NET | ArcGIS for Developers

Update: the error have nothing to do with the code, without license you will get this error but you still be able to use all the functionalities in the API for development and testing with no problem. Try to review your code and make sure you use the right .mpk path.

Thanks,

Asser

0 Kudos
JosephGenther
Esri Contributor

Sandeep,

License the Standard level through Esri Sales for offline geoprocessing tasks like geocoding, routing, file geodatabase editing, edit and sync online content for offline use, etc. But for offline viewing only, or connected to ArcGIS Online or ArcGIS Server you'll only need the Basic license for free.

0 Kudos
MichaelBranscomb
Esri Frequent Contributor

Hi,

For licensing at the Standard level, you can either purchase a license code or use an Organizational subscription - for more info please see License your app—ArcGIS Runtime SDK for .NET | ArcGIS for Developers

Cheers

Mike