MapTips widget Vs Graphic MapTips Vs InfoWindow (which one to use?)

4268
17
03-03-2011 08:12 AM
CameronBlandy
Occasional Contributor
Hello all,

I am trying to determine which Map Tip / Info Window I should use for my application. My application will have similiar functionality to the ESRI ShowCase template in VS 2010. Instead of different BaseMaps to choose I will have different Themes to choose. When I click on a theme a dynamic map layer will be created and displayed.

1). Can we put Map Tips on a dynamic map layer (we want to use the symbology from the map service)? If not then we need to use a Feautre Layer or Graphics layer and then define the symbology which would be very painful, correct??

2). Assuming we need to create a Graphics/Feature layer for the Map Tips how do we define a standard map Tip / Info Window template that can be used for all Graphics/Feature Layers added to the map given that each Graphics/Feature Layer will have a different set of attribtutes to display? Is the Binding for this straight forward.

I'd appreciate some help on this topic and some answers to my question as I am a little confused.

Cameron
0 Kudos
17 Replies
CameronBlandy
Occasional Contributor
Is there a way to add a Title or label to info window?  I'm looking to make it the layer name.


If you use the MapTip widget (the Toolkit) you can easily assign the layer name to the Title property.

void featureLayer_Initialized(object sender, System.EventArgs e)
        {
            FeatureLayer featureLayer = sender as FeatureLayer;
            
            Map.Layers.Add(featureLayer);

            string layerName = featureLayer.LayerInfo.Name.ToString();

            MapTip maptip= new MapTip();
            maptip.Title = layerName;
            maptip.GraphicsLayer = featureLayer;

    }
0 Kudos
karenvolarich
New Contributor III
Not using that method.  I'm using a hybrid of identify with the info window.  I already have all my layers added via dynamic services,  I don't feel like recreating graphics and adding new features for more than 100 layers...again...overkill.

So if anybody knows a way to add a title/label to an info window that would be great.  I can't find anything in the API.
0 Kudos
JenniferNery
Esri Regular Contributor
InfoWindow does not have Title bar like the Toolkit.MapTip since you set InfoWindow.DataTemplate, you can format controls as you wish and make a title bar. If InfoWindow.Content is pointed to graphic.Attributes, then you need to add LayerName to attributes.

<DataTemplate x:Key="MyInfoWindowTemplate">
 <Grid>
  <Grid.RowDefinitions>
   <RowDefinition/>
   <RowDefinition/>
  </Grid.RowDefinitions>    
  <TextBlock Text="{Binding [LayerName]}" FontWeight="Bold" />
  <TextBlock Text="{Binding [STATE_NAME]}" Foreground="Black" FontSize="12" Grid.Row="1" />
 </Grid>
</DataTemplate>


Since you are using ArcGISDynamicMapServiceLayer, I imagine you are also using IdentifyTask to identify the feature clicked.
void it_ExecuteCompleted(object sender, IdentifyEventArgs e)
{
 MapPoint clickPoint = e.UserState as MapPoint;
 foreach (var result in e.IdentifyResults)
 {
  MyInfoWindow.Anchor = clickPoint;
  MyInfoWindow.IsOpen = true;
  result.Feature.Attributes ["LayerName"] = result.LayerName;
  MyInfoWindow.Content = result.Feature.Attributes;
  return;
 }
}
0 Kudos
michaelcasallo
New Contributor

Jennifer,

I have a project where we are using the esriToolkit:InfoWindow to display information about a vessel at a given location

I see where we are Binding the information to the window in a Binding[START_DATE] tag

My question is, how can I take the date/time received and then convert it an acceptable format for our users?

Thanks!

0 Kudos
karenvolarich
New Contributor III
<DataTemplate x:Key="MyDynamicMapInfoWindowTemplate">
                <ScrollViewer Margin="0,5,0,0" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" Width="285" Height="325" >
                        <slData:DataGrid AutoGenerateColumns="False" HeadersVisibility="None" ItemsSource="{Binding}" >
                            <slData:DataGrid.Columns>
                            <slData:DataGridTextColumn Binding="{Binding Path=Key}" FontWeight="Bold"/>
                            <slData:DataGridTemplateColumn>
                                <slData:DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <TextBlock Text="{Binding Path=Value}" />
                                    </DataTemplate>
                                </slData:DataGridTemplateColumn.CellTemplate>
                            </slData:DataGridTemplateColumn>
                        </slData:DataGrid.Columns>
                    </slData:DataGrid>
                </ScrollViewer>
            </DataTemplate>


I can't seem to figure the place where the row definition would go...this is a little different than just the grid.  But data grid doesn't seem to let me define row defintions.
0 Kudos
JenniferNery
Esri Regular Contributor
How about defining DataTemplate as
<DataTemplate x:Key="MyInfoWindowTemplate">
 <Grid>
  <Grid.RowDefinitions>
   <RowDefinition/>
   <RowDefinition/>
  </Grid.RowDefinitions>    
  <TextBlock Text="{Binding [LayerName]}" FontWeight="Bold" />
  <slDataataGrid AutoGenerateColumns="False" HeadersVisibility="None" ItemsSource="{Binding}"  Grid.Row="1" />
...
 </Grid>
</DataTemplate>
0 Kudos
karenvolarich
New Contributor III
It appears Grid and DataGrid conflict with each other within the Visual Tree.  When using just a Grid, the fields don't match up within the info window.  When using a data grid they do.  Part of the issue of using a data grid versus just a grid (I'm pretty sure that's a bug with the API).
0 Kudos
karenvolarich
New Contributor III
Ok, got it working... got rid of the row definitions...

<DataTemplate x:Key="MyDynamicMapInfoWindowTemplate">
                <Grid Margin="10">
                        <TextBlock Text="{Binding [LayerName]}" FontWeight="Bold" Margin="-12"/>
                        <ScrollViewer Margin="0,5,0,0" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" Width="285" Height="325" >
                            <slData:DataGrid AutoGenerateColumns="False" HeadersVisibility="None" ItemsSource="{Binding}">
                                <slData:DataGrid.Columns>
                                    <slData:DataGridTextColumn Binding="{Binding Path=Key}" FontWeight="Bold"/>
                                    <slData:DataGridTemplateColumn>
                                        <slData:DataGridTemplateColumn.CellTemplate>
                                            <DataTemplate>
                                                <TextBlock Text="{Binding Path=Value}" />
                                            </DataTemplate>
                                        </slData:DataGridTemplateColumn.CellTemplate>
                                    </slData:DataGridTemplateColumn>
                                </slData:DataGrid.Columns>
                            </slData:DataGrid>
                        </ScrollViewer>
                </Grid>
            </DataTemplate>
0 Kudos