Maptips for GraphicsOverlay

1276
6
10-11-2017 08:22 AM
AlexZlotin1
New Contributor III

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!

0 Kudos
6 Replies
dotMorten_esri
Esri Notable 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.

0 Kudos
AlexZlotin1
New Contributor III

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

0 Kudos
dotMorten_esri
Esri Notable Contributor

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

0 Kudos
AlexZlotin1
New Contributor III

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

0 Kudos
dotMorten_esri
Esri Notable 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.

0 Kudos
AlexZlotin1
New Contributor III

Perfect answer! Thanks.

0 Kudos