Maptips for GraphicsOverlay

445
6
10-11-2017 08:22 AM
Highlighted
New Contributor II

What is the best way to create maptips for graphics in a GraphicsOverlay? It was easy to do in the Silverlight API by setting the MapTip property of a graphic. I am using Runtime 100. Thanks!

Reply
0 Kudos
6 Replies
Highlighted
Esri Frequent Contributor

You would use the IdentifyGraphicOverlaysAsync method on a mouse-click event to find graphics under the cursor. You can then use the ShowCalloutAt... methods to display a sort of tooltip you'd like.

The automatic maptip-on-hover is no longer available out of the box.

Reply
0 Kudos
Highlighted
New Contributor II

Thanks, this is working well. Is there a way to change the default font name and font size for a callout?

Reply
0 Kudos
Highlighted
Esri Frequent Contributor

Which platform? WPF, UWP, Xamarin.Android, Xamarin.iOS or Xamarin.Forms?

Reply
0 Kudos
Highlighted
New Contributor II

I am using WPF. Sorry, did not make it clear.

Reply
0 Kudos
Highlighted
Esri Frequent Contributor

That's ok. The answer just differs per platform, since styling is quite platform dependent. The WPF MapView control uses a "Callout" control to render the callout. So you can change the styling completely by using an implicit style.

<esri:MapView>
    <esri:MapView.Resources>
        <Style TargetType="esri:Callout">
           <Setter Property="FontFamily" Value="Courier New" />
           <Setter Property="BorderBrush" Value="Red" />
           <Setter Property="BorderThickness" Value="5" />
        </Style>

    </esri:MapView.Resources>
</esri:MapView>

Also note that you can use the ShowCalloutAt overload that takes a UIElement. This allows you to just create a UserControl with whatever content you'd like and get it rendered inside the callout border, instead of relying on the default 4 text, description, button, icon parts.

Reply
0 Kudos
Highlighted
New Contributor II

Perfect answer! Thanks.

Reply
0 Kudos