Can you put a hyperlink in a maptip

876
7
04-16-2013 10:52 AM
DonFreeman
New Contributor
Hi -

I would like to place a hyperlink in a maptip. I believe the coding for this would be fairly straight forward but maptips close before you can get the mouse into it. So is this possible or not and what would the code look like?

<esri:FeatureLayer.MapTip>
 <Border CornerRadius="10" BorderBrush="SaddleBrown" BorderThickness="3" Margin="0,0,15,15" Background="LightGray">
 <StackPanel Margin="7" Orientation="Vertical">
 <TextBlock Text="{Binding [SCHNAME]}" Foreground="Black"  FontWeight="Bold"/>
 <TextBlock Text="{Binding [ADDRESS]}" Foreground="Black" />
 </StackPanel>
 </Border>
</esri:FeatureLayer.MapTip>

Thanks
0 Kudos
7 Replies
DominiqueBroux
Esri Frequent Contributor
but maptips close before you can get the mouse into it.

Did you try to set a maptip hide delay?
(like in this sample)
0 Kudos
DonFreeman
New Contributor
Thank you Dom. The sample you reference uses a GraphicsLayer. My map uses a FeatureLayer. I have tried this:
<esri:FeatureLayer ID="MonitoringSitesLayer"
             Url="http://gismaps.pagnet.org/ArcGIS/rest/services/AirQuality/MapServer/0"
            OutFields="*"
             Visible="true">
       <esri:FeatureLayer.MapTip>
         <Border Style="{StaticResource MapTip_Border}" esri:FeatureLayer.MapTipHideDelay="00:00:021.5">
         <StackPanel Margin="7" Orientation="Vertical">
          <TextBlock Text="{Binding [NAME]}" Foreground="Black"  FontWeight="Bold"/>
          <TextBlock Text="{Binding [ADDRESS]}" Foreground="Black" />
          <StackPanel Orientation="Horizontal">
           <TextBlock Text="PM10 - " Foreground="Black" />
           <TextBlock Text="{Binding [PM10]}" Foreground="Black" />
          </StackPanel>
          <StackPanel Orientation="Horizontal">
           <TextBlock Text="PM2.5 - " Foreground="Black" />
           <TextBlock Text="{Binding [PM2_5]}" Foreground="Black" />
          </StackPanel>
          <StackPanel Orientation="Horizontal">
           <TextBlock Text="CO - " Foreground="Black" />
           <TextBlock Text="{Binding [CO]}" Foreground="Black" />
          </StackPanel>
          <StackPanel Orientation="Horizontal">
           <TextBlock Text="Ozone - " Foreground="Black" />
           <TextBlock Text="{Binding [O3]}" Foreground="Black" />
          </StackPanel>
          <StackPanel Orientation="Horizontal">
           <TextBlock Text="SO2 - " Foreground="Black" />
           <TextBlock Text="{Binding [SO2]}" Foreground="Black" />
          </StackPanel>
          <StackPanel Orientation="Horizontal">
           <TextBlock Text="NO2 - " Foreground="Black" />
           <TextBlock Text="{Binding [NOX]}" Foreground="Black" />
          </StackPanel>

         </StackPanel>
        </Border>
       </esri:FeatureLayer.MapTip>
      </esri:FeatureLayer>

but it doesn't seem to work. I find nothing in the code behind that look pertinent. Did I miss something? The maptip remains until I try to move into it and then closes immediately.
0 Kudos
DominiqueBroux
Esri Frequent Contributor
The sample you reference uses a GraphicsLayer. My map uses a FeatureLayer.

As a feature layer is a kind of GraphicsLayer, that should work with FeatureLayer as well.
I don't see anything wrong in your code. Strange :confused:
0 Kudos
DonFreeman
New Contributor
Thanks again Dom. Here is my map in total. Perhaps you can see what's up. The hyperlink is in the MonitoringSitesLayer.

    <esri:Map x:Name="MyMap"  Extent="748437,575771,1204687,267438" Margin="10,20,20,20" IsLogoVisible="False"  >
     <esri:Map.Layers>

      <esri:FeatureLayer ID="PimaCounty"
             Url="http://gismaps.pagnet.org/ArcGIS/rest/services/AirQuality/MapServer/8" />

      <esri:ArcGISDynamicMapServiceLayer ID="PAGBaseMap"
                 Url="http://gismaps.pagnet.org/ArcGIS/rest/services/StreetsBaseMap/MapServer"
                 VisibleLayers="0,1" />

      <esri:FeatureLayer ID="AjoSO2Layer"
             Url="http://gismaps.pagnet.org/ArcGIS/rest/services/AirQuality/MapServer/4"
             OutFields="NAME, DESC"
             Visible="false">
       <esri:FeatureLayer.MapTip>
        <Border Style="{StaticResource MapTip_Border}" >
         <StackPanel Margin="7" Orientation="Vertical">
          <TextBlock Text="{Binding [Name]}" Foreground="Black"  FontWeight="Bold"/>
          <TextBlock Text="{Binding [Desc]}" Foreground="Black" TextWrapping="Wrap" Width="400"/>
         </StackPanel>
        </Border>
       </esri:FeatureLayer.MapTip>
      </esri:FeatureLayer>
      
      <esri:FeatureLayer ID="AjoPM10Layer"
             Url="http://gismaps.pagnet.org/ArcGIS/rest/services/AirQuality/MapServer/3"
             OutFields="NAME, DESC"
             Visible="false">
       <esri:FeatureLayer.MapTip>
        <Border Style="{StaticResource MapTip_Border}" >
         <StackPanel Margin="7" Orientation="Vertical">
          <TextBlock Text="{Binding [Name]}" Foreground="Black"  FontWeight="Bold"/>
          <TextBlock Text="{Binding [Desc]}" Foreground="Black" TextWrapping="Wrap" Width="400"/>
         </StackPanel>
        </Border>
       </esri:FeatureLayer.MapTip>
      </esri:FeatureLayer>

      <esri:FeatureLayer ID="AirPlanningLayer"
             Url="http://gismaps.pagnet.org/ArcGIS/rest/services/AirQuality/MapServer/7"
             OutFields="NAME, DESC"
             Visible="true" >
       <esri:FeatureLayer.MapTip>
        <Border Style="{StaticResource MapTip_Border}" >
         <StackPanel Margin="7" Orientation="Vertical">
          <TextBlock Text="{Binding [Name]}" Foreground="Black"  FontWeight="Bold"/>
          <TextBlock Text="{Binding [Desc]}" Foreground="Black" TextWrapping="Wrap" Width="400"/>
         </StackPanel>
        </Border>
       </esri:FeatureLayer.MapTip>       
      </esri:FeatureLayer>

      <esri:FeatureLayer ID="TucsonCOMaintLayer"
             Url="http://gismaps.pagnet.org/ArcGIS/rest/services/AirQuality/MapServer/5"
             OutFields="Name, Desc"
             Visible="false">
       <esri:FeatureLayer.MapTip>
        <Border Style="{StaticResource MapTip_Border}" >
         <StackPanel Margin="7" Orientation="Vertical">
          <TextBlock Text="{Binding [Name]}" Foreground="Black"  FontWeight="Bold"/>
          <TextBlock Text="{Binding [Desc]}" Foreground="Black" TextWrapping="Wrap" Width="400"/>
         </StackPanel>
        </Border>
       </esri:FeatureLayer.MapTip>    
      </esri:FeatureLayer>

      <esri:FeatureLayer ID="RillitoPM10Layer"
             Url="http://gismaps.pagnet.org/ArcGIS/rest/services/AirQuality/MapServer/6"
             OutFields="Name, Desc"
             Visible="false">
       <esri:FeatureLayer.MapTip>
        <Border Style="{StaticResource MapTip_Border}" >
         <StackPanel Margin="7" Orientation="Vertical">
          <TextBlock Text="{Binding [Name]}" Foreground="Black" FontWeight="Bold"/>
          <TextBlock Text="{Binding [Desc]}" Foreground="Black" TextWrapping="Wrap" Width="400"/>
         </StackPanel>
        </Border>
       </esri:FeatureLayer.MapTip>
      </esri:FeatureLayer>

      <esri:FeatureLayer ID="SchoolsLayer" 
             Url="http://gismaps.pagnet.org/ArcGIS/rest/services/AirQuality/MapServer/2"
             OutFields="SCHNAME, ADDRESS"
             Visible="false">
       <esri:FeatureLayer.MapTip>
        <Border Style="{StaticResource MapTip_Border}" >
         <StackPanel Margin="7" Orientation="Vertical">
          <TextBlock Text="{Binding [SCHNAME]}" Foreground="Black"  FontWeight="Bold"/>
          <TextBlock Text="{Binding [ADDRESS]}" Foreground="Black" />
         </StackPanel>
        </Border>
       </esri:FeatureLayer.MapTip>
      </esri:FeatureLayer>

      <esri:FeatureLayer ID="HospitalsLayer"
             Url="http://gismaps.pagnet.org/ArcGIS/rest/services/AirQuality/MapServer/1"
             OutFields="NAME, ADDRESS"
             Visible="False" >
       <esri:FeatureLayer.MapTip>
        <Border Style="{StaticResource MapTip_Border}" >
         <StackPanel Margin="7" Orientation="Vertical">
          <TextBlock Text="{Binding [NAME]}" Foreground="Black"  FontWeight="Bold"/>
          <TextBlock Text="{Binding [ADDRESS]}" Foreground="Black" />
         </StackPanel>
        </Border>
       </esri:FeatureLayer.MapTip>
      </esri:FeatureLayer>

      <esri:FeatureLayer ID="MonitoringSitesLayer"
             Url="http://gismaps.pagnet.org/ArcGIS/rest/services/AirQuality/MapServer/0"
             OutFields="*"
             Visible="true" MouseLeftButtonUp="MonitorsFeatureLayer_MouseLeftButtonUp">
       <esri:FeatureLayer.MapTip >
         <Border Style="{StaticResource MapTip_Border}" esri:FeatureLayer.MapTipHideDelay="00:00:01.5">
         <StackPanel Margin="7" Orientation="Vertical">
          <TextBlock Text="{Binding [NAME]}" Foreground="Black"  FontWeight="Bold"/>
          <TextBlock Text="{Binding [ADDRESS]}" Foreground="Black" />
          <TextBlock Text="__________________________________________" Foreground="Black" />
          <TextBlock Text="Pollutants that are monitored at this site" Foreground="Black" />
          <StackPanel Orientation="Horizontal">
           <!--<TextBlock Text="PM10 - " Foreground="Black" />-->
           <TextBlock Text="{Binding [PM1]}" Foreground="Black" />
          </StackPanel>
          <StackPanel Orientation="Horizontal">
           <!--<TextBlock Text="PM2.5 - " Foreground="Black" />-->
           <TextBlock Text="{Binding [PM2]}" Foreground="Black" />
          </StackPanel>
          <StackPanel Orientation="Horizontal">
           <!--<TextBlock Text="CO - " Foreground="Black" />-->
           <TextBlock Text="{Binding [CO]}" Foreground="Black" />
          </StackPanel>
          <StackPanel Orientation="Horizontal">
           <!--<TextBlock Text="Ozone - " Foreground="Black" />-->
           <TextBlock Text="{Binding [O3]}" Foreground="Black" />
          </StackPanel>
          <StackPanel Orientation="Horizontal">
           <!--<TextBlock Text="SO2 - " Foreground="Black" />-->
           <TextBlock Text="{Binding [SO2]}" Foreground="Black" />
          </StackPanel>
          <StackPanel Orientation="Horizontal">
           <!--<TextBlock Text="NO2 - " Foreground="Black" />-->
           <TextBlock Text="{Binding [NOX]}" Foreground="Black" />
          </StackPanel>

          <HyperlinkButton x:Name="myHyperLink" NavigateUri="{Binding [WebLink]}" TargetName="_blank" Content="Click here for more info." Foreground="DarkSlateBlue"/>
         </StackPanel>
        </Border>
       </esri:FeatureLayer.MapTip>
      </esri:FeatureLayer>

     </esri:Map.Layers>
    </esri:Map>
0 Kudos
DominiqueBroux
Esri Frequent Contributor
Here is my map in total. Perhaps you can see what's up.

I tried your map and I didn't notice any problem (see screenshot).
[ATTACH=CONFIG]23715[/ATTACH]
As you did share your static resource 'Maptip_Border', I created one myself  (with a background in order to avoid interaction with underlying objects) and the hyperlink seems working well.
0 Kudos
DonFreeman
New Contributor
I tried your map and I didn't notice any problem (see screenshot).
[ATTACH=CONFIG]23715[/ATTACH]
As you did share your static resource 'Maptip_Border', I created one myself  (with a background in order to avoid interaction with underlying objects) and the hyperlink seems working well.


Oh , sorry I missed the border style. I initially tried to send the entire page but the site rejected it because it was too large. Here is my style which also has a background.
 <Style x:Key="MapTip_Border" TargetType="Border">
    <Setter Property = "CornerRadius" Value="10" />
    <Setter Property="BorderBrush" Value="SaddleBrown"/>
    <Setter Property="BorderThickness" Value="3" />    
    <Setter Property="Margin" Value="0,0,15,15" />
    <Setter Property="Background" Value="LightGray" />    
   </Style>

I find that if I snap the mouse into the maptip with a very fast motion I can sometimes (1 in 10) get into it before it closes, but usually not and certainly not for the public users who will be using the map. Could there be some other settings in the page that would cause this problem? I have attached the full page to this post. Thanks
0 Kudos
TolgaBakirman
New Contributor
This topic helped me a lot!

Thanks,

Regards,
0 Kudos