MapTips not working with MapApplication.Current.Map

2178
4
03-21-2012 07:15 AM
MichaelOberegger
New Contributor
I have run into an interesting problem where I am able to get MapTips working on a map that I create myself, but not on the map provided by the MapApplication.Current.Map reference.

I created an AddIn (just a Command that opens up a new user control/window) that contains the code from the example provided at http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#GraphicsMapTip, with a few changes. The control doesn't create it's own map, but uses the map provided from MapApplication.Current.Map. I use the same GraphicsLayer xaml code provided from the example, but just put it inside the user control's LayoutRoot resource list instead, and add the graphic layer to the application's map when the control loads with the MapApplication.Current.Map.Layers.Add method. Doing this, the geometries are showing up, but the MapTips won't display.

As a test, what I did was create my own map within the user control, using the same map xaml code from the example. I added the graphic layer to this map instead of the one provided from the MapApplication, and the geometries display with the MapTips. The code is exactly the same, just referencing a different map. I actually have a sample now with two identical graphic layers, one assigned to each map, with copies of the graphic returned from the query added to each layer. In this example, MapTips display in my user control with my own map, but not on the viewer's map.

Anyone know why this might be? Is there a step that I'm missing to get MapTips to display on the viewer's map? Any help is greatly appreciated.

Thanks!

Mike
0 Kudos
4 Replies
MichaelOberegger
New Contributor
Alright, so I sort of figured out what the issue was. When using the map from the viewer, the MapTip has to be assigned directly to the Graphic, and not the GraphicLayer. Not sure why this is... when using my own map, I can add the MapTip to the Graphic itself, OR the GraphicLayer, and it will work in both cases. For some reason, when using the viewer's map, adding the MapTip to only the GraphicLayer is not sufficient, and needs to be added to each Graphic individually.

I can work around this limitation (for lack of a better word), although I am still curious as to why this behavior exists. Feel free to add any thoughts on that, as I am very interested to hear them!

Thanks for your time!
0 Kudos
KatherineDalton
Esri Regular Contributor
Hi Mike,

A couple options on this - 1) Override the default pop-up for a layer by specifying the pop-up template/header or 1) Disable popups on a layer programmatically (via LayerProperties.IsPopupEnabled) and then Set GraphicsLayer.MapTip. But yes, you are correct, as long as Pop-ups are enabled you cannot specify the MapTip for a GraphicsLayer.

Katy
Katy Dalton | Technical Consultant
THE SCIENCE OF WHERE™
0 Kudos
RyanKoehnen
New Contributor III
Hi Mike,

A couple options on this - 1) Override the default pop-up for a layer by specifying the pop-up template/header or 1) Disable popups on a layer programmatically (via LayerProperties.IsPopupEnabled) and then Set GraphicsLayer.MapTip. But yes, you are correct, as long as Pop-ups are enabled you cannot specify the MapTip for a GraphicsLayer.

Katy


Katy,

Simple question- How do I get or set the LayerProperties object from a GraphicsLayer, or any other layer for that matter? Casting doesn't work, can't find a property or method, and it doesn't "look" like a dependency object, so I'm stuck at the moment.
0 Kudos
RyanKoehnen
New Contributor III
Katy,

Simple question- How do I get or set the LayerProperties object from a GraphicsLayer, or any other layer for that matter? Casting doesn't work, can't find a property or method, and it doesn't "look" like a dependency object, so I'm stuck at the moment.


Nevermind, I figured this out, LayerProperties is a static class... (duh!) 😉
0 Kudos