Select to view content in your preferred language

Trouble with maptip

803
2
04-30-2010 01:16 PM
DonFreeman
Emerging Contributor
Hi. I am experimenting with the maptip code shown in the example at http://resources.esri.com/help/9.3/arcgisserver/apis/silverlight/samples/start.htm#MapTipWidget. I copied the code pretty much intact to my page and it worked OK. However when I changed the map URL and querytask to my map, it no longer works. The code involved does not trigger. Can someone tell me what is supposed to trigger the mouseover or mouseclick event to produce the maptip? Also, what does the 5 represent in the querytask url http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/" & "Demographics/ESRI_Census_USA/MapServer/5? I assume that is layer #5 but is that correct?

Thanks
0 Kudos
2 Replies
DominiqueBroux
Esri Frequent Contributor
You are right the '5' represents the layer ID.

The mouse over and mouse click events to produce maptips are managed by the maptip widget, so you don't have to worry about that.

After changing the Url, do you get some features displayed in your graphic layer?

/Dominique
0 Kudos
DonFreeman
Emerging Contributor
You are right the '5' represents the layer ID.

The mouse over and mouse click events to produce maptips are managed by the maptip widget, so you don't have to worry about that.

After changing the Url, do you get some features displayed in your graphic layer?

/Dominique


Thanks dbroux. Actually I don't. After looking at it some more I decided to try a little different approach and instead of replacing the URL I just added another layer with appropriate changes. The new layer should show school districts somewhat analogous to the states but it shows nothing. My xaml and code behind is below.

<esri:GraphicsLayer ID="SchoolsGraphicsLayer" Initialized="SchoolsGraphicsLayer_Initialized" >
     <esri:GraphicsLayer.MapTip>
      <Border esri:GraphicsLayer.MapTipHideDelay="00:00:01.5" CornerRadius="10" BorderBrush="#FF222957" BorderThickness="3" Margin="0,0,15,15">
       <Border.Background>
        <LinearGradientBrush EndPoint="1.038,1.136" StartPoint="0.015,0.188">
         <GradientStop Color="#FFD1DFF2"/>
         <GradientStop Color="#FF092959" Offset="0.946"/>
        </LinearGradientBrush>
       </Border.Background>
       <Border.Effect>
        <DropShadowEffect ShadowDepth="10" BlurRadius="14" Direction="300" />
       </Border.Effect>
       <StackPanel Orientation="Vertical" Margin="20,15,20,15">
        <StackPanel Orientation="Horizontal" Margin="0,0,0,6">
         <TextBlock Text="School Name: " FontWeight="Bold" Foreground="#FF0F274E" FontSize="12" />
         <TextBlock Text="{Binding Converter={StaticResource MyDictionaryConverter}, 
                                        ConverterParameter=NAME, Mode=OneWay}" Foreground="#FFFFFFFF" FontSize="12" FontStyle="Italic" FontFamily="Portable User Interface" />
        </StackPanel>
        <StackPanel Orientation="Horizontal">
         <TextBlock Text="Address: " FontWeight="Bold" Foreground="#FF0F274E" FontSize="12" />
         <TextBlock Text="{Binding Converter={StaticResource MyDictionaryConverter}, 
                                        ConverterParameter=Address, Mode=OneWay}" Foreground="#FFFFFFFF" FontSize="12" FontStyle="Italic" FontFamily="Portable User Interface" />
        </StackPanel>
       </StackPanel>
      </Border>
     </esri:GraphicsLayer.MapTip>
    </esri:GraphicsLayer>


  Private Sub SchoolsGraphicsLayer_Initialized(ByVal sender As Object, ByVal args As EventArgs)
   Dim query As New ESRI.ArcGIS.Client.Tasks.Query() With {.Geometry = New ESRI.ArcGIS.Client.Geometry.Envelope(-180, 0, 0, 90)}
   query.OutFields.Add("*")

   Dim queryTask As New QueryTask("http://maps.pagnet.org/arcgis/rest/services/SchoolSearch2/MapServer/8")
   AddHandler queryTask.ExecuteCompleted, AddressOf SchoolsGraphicsLayerQueryTask_ExecuteCompleted
   queryTask.ExecuteAsync(query)
  End Sub

  Private Sub SchoolsGraphicsLayerQueryTask_ExecuteCompleted(ByVal sender As Object, ByVal queryArgs As ESRI.ArcGIS.Client.Tasks.QueryEventArgs)
   If queryArgs.FeatureSet Is Nothing Then
    Return
   End If

   Dim resultFeatureSet As FeatureSet = queryArgs.FeatureSet
   Dim graphicsLayer As ESRI.ArcGIS.Client.GraphicsLayer = TryCast(MyMap.Layers("SchoolsGraphicsLayer"), ESRI.ArcGIS.Client.GraphicsLayer)

   If resultFeatureSet IsNot Nothing AndAlso resultFeatureSet.Features.Count > 0 Then
    For Each graphicFeature As ESRI.ArcGIS.Client.Graphic In resultFeatureSet.Features
     graphicFeature.Symbol = DefaultFillSymbol
     graphicsLayer.Graphics.Add(graphicFeature)
    Next graphicFeature
   End If
  End Sub
0 Kudos