Maptips do not ever display

957
10
11-05-2010 05:26 AM
BrentStevener
New Contributor II
I am trying several of the maptips samples on the Interactive SDK, and I just cannot get them to work with my particular service layer. I can step through debugging, and the features are being queried, and added to the graphics layer with a valid symbol. They just aren't showing on the graphics layer.

For instance, I have tried a sample similar to this SDK sample, using our service layer, and the code runs through like it should work, but again, no graphics show.

Can someone test with this test service layer: http://irnrgis.tamu.edu/ArcGIS/rest/services/Test/Trims/MapServer/0

Does it work for you? Am I going crazy?
0 Kudos
10 Replies
DominiqueBroux
Esri Frequent Contributor
Compared to the SDK sample, you have to take care of 2 points:
1) the spatial reference of your service is probably not the same than the map spatial reference. So you have to initialize it by something like :
 
ESRI.ArcGIS.Client.Tasks.Query query = new ESRI.ArcGIS.Client.Tasks.Query()
{
Geometry = new ESRI.ArcGIS.Client.Geometry.Envelope(-180, 0, 0, 90) { SpatialReference = new ESRI.ArcGIS.Client.Geometry.SpatialReference(4326) },
OutSpatialReference = new ESRI.ArcGIS.Client.Geometry.SpatialReference(4326),
ReturnGeometry = true
};
query.OutFields.Add("*");


2) Your geometry is Point instead of Polygon so you have to initialize the symbol with a marker symbol instead of a fill symbol:
 
feature.Symbol = LayoutRoot.Resources["MarkerSymbol"] as Symbol;


That being said, the easiest way is to use a feature layer which is doing this work for you without any code(and which is using the symbology defined at server side).
 
<esri:FeatureLayer Mode="Snapshot" OutFields="*"
Url="http://irnrgis.tamu.edu/ArcGIS/rest/services/Test/Trims/MapServer/0" />
0 Kudos
BrentStevener
New Contributor II
I have already done both of those suggestions, and the maptips still do not display. I even used the same service as the base layer, which would have the same spatial reference, and had already been using a marker symbol instead, and the maptips still do not show, even after making the above recommended changes.

The only thing I haven't tried is the feature layer, but as I said, I have tried this several different ways with different services, and I can't get my points to show as map tips when they are queried and added to the graphics layer fine.
0 Kudos
DominiqueBroux
Esri Frequent Contributor
I have tested with the code I gave and with your service and it's working...
So there is probably something else not working in your project but I would need more info to figure out where the issue could be.

Note again that using a feature layer would be much easier:)
0 Kudos
BrentStevener
New Contributor II
I have tested with the code I gave and with your service and it's working...
So there is probably something else not working in your project but I would need more info to figure out where the issue could be.

Note again that using a feature layer would be much easier:)


Can you zip up your project with your working code using my service and attach it here? I tried the feature layer, and the maptip does not show, but the features do. I am pulling my hair out wondering what the problem is.
0 Kudos
BrentStevener
New Contributor II
I am able to get maptips to work using a feature layer, using this sample.

However, I would like to know why using the Maptip control does not work for me using my service, in my first post. Any ideas?
0 Kudos
DominiqueBroux
Esri Frequent Contributor

Can you zip up your project with your working code using my service and attach it here? I tried the feature layer, and the maptip does not show, but the features do. I am pulling my hair out wondering what the problem is.


I was testing with the interactive samples that you can download by the right top icon of this page : http://help.arcgis.com/en/webapi/silverlight/samples/start.htm

Then you have to change the MaptipWidget.xaml file in order to declare your feature layer.
 
<esri:Map x:Name="MyMap" Background="White" Extent="-130,10,-70,60">
  <esri:ArcGISTiledMapServiceLayer ID="BaseMapLayer" 
         Url="http://services.arcgisonline.com/ArcGIS/rest/services/NGS_Topo_US_2D/MapServer" />
  <esri:FeatureLayer ID="MyGraphicsLayer" Mode="Snapshot" OutFields="*"
        Url="http://irnrgis.tamu.edu/ArcGIS/rest/services/Test/Trims/MapServer/0" />
</esri:Map>
�??

and that's it, you should get something like the screenshot I posted a little time ago.
0 Kudos
BrentStevener
New Contributor II
Well that's what I was doing, and no maptips show for me. This is why I have been pulling my hair out. Are you sure theres nothing else that you have code wise that is not shown?

This is why I would have preferred to look at your sample code that is using my service because I know there are code behind changes that you made to that file in order to get it to work that you have not posted. I just want to compare to mine and see what the issue is, or if I get the same problem with your files.
0 Kudos
BrentStevener
New Contributor II
If you for some reason don't feel like sending me your project files, try changing the base layer to our map service layer too and see if you can still get the maptips to work, using the following service definitions:
<esri:ArcGISDynamicMapServiceLayer ID="BaseMapLayer" 
                    Url="http://irnrgis.tamu.edu/ArcGIS/rest/services/Test/Trims/MapServer" />
<esri:FeatureLayer ID="MyGraphicsLayer" Mode="Snapshot" OutFields="*" Url="http://irnrgis.tamu.edu/ArcGIS/rest/services/Test/Trims/MapServer/0" />

If you can get it to work, can I please have your working MapTipWidget XAML and code file?
0 Kudos
DominiqueBroux
Esri Frequent Contributor
You are right.
I just noticed that in my XAML file, the binding of GraphicsLayer was done by XAML instead of code:
 
<Canvas HorizontalAlignment="Left" VerticalAlignment="Top" >
  <esri:MapTip x:Name="MyMapTip" BorderBrush="#99000000" GraphicsLayer="{Binding Layers[MyGraphicsLayer],  ElementName=MyMap}"
         BorderThickness="1" Title="State Info" VerticalOffset="10" 
HorizontalOffset="10" Background="#DDFFFFFF" />
</Canvas>


Probably a test I did some time ago. It's why I didn't need any code.

I attach my xaml file to be sure I don't forget anything else (or you can also keep the binding by code as it was in the sample).

Sorry for the confusion
0 Kudos