I'm using the 2009.2 version of xamWebMap that uses the SqlShapeReader to get specific borders from a geo database (I've also tried from shape files).
The problem that I'm having is that I'm having the caption repeat for all the islands when the shape is a multi-polygon type which I don't want. For instance United Kingdom shows a caption over the mainland and over northern ireland. Is there a way to disable this behavior?
Thanks
Sam
Hi David.
Thanks, I resolved the multipolygon label. I added a TexBlock as a Value Template in the Layer, bound to the shape name and removed the shape caption.
I share my solution:
<ig:MapLayer
Name="SystemBoundaryZCTA"
DataMapping="Name=Name;Value=Value;Caption=Value"
Brushes="#202E2EFE"
FillMode="RandomSelect"
IsClickable="False">
<ig:MapLayer.Reader>
<ig:SqlShapeReader DataMapping="Data=geom; Name=CityCaption; Value=FipsId">
</ig:SqlShapeReader>
</ig:MapLayer.Reader>
<ig:MapLayer.ValueTemplate>
<DataTemplate>
<StackPanel>
<TextBlock Foreground="White" FontSize="12" FontWeight="Bold" Text="{Binding Path=Name}" Visibility="{Binding Path=Visibility}" />
</StackPanel>
</DataTemplate>
</ig:MapLayer.ValueTemplate>
</ig:MapLayer>
would it be possible for you to share the shapefile you are using as a data source, or anything comparable? i would like to see what you mean, but i am having a hard time finding a multipolygon shapefile.
David Negley"] this can also be achieved in C# by looping through the MapElements in the layer.Imported event.
this can also be achieved in C# by looping through the MapElements in the layer.Imported event.
Hi.
I have the same problem, but I am working with multipolygons, so when I try loop MapElements I get only one element (and only one caption) for the all the shapes.
Is there another way?
This is what I tried with no successful:
void SystemCoverageMap_Imported(object sender, MapLayerImportEventArgs e)
{
var Layer = (MapLayer)sender;
//Hide on Layer
var elements = Layer.Elements;
List<string> distincts = new List<string>();
foreach (MapElement o in elements)
if (!distincts.Any(i => i == o.Caption))
distincts.Add(o.Caption);
}
else
o.Caption = "";
this indicates that there are several records with "UK" in the caption field. the XamWebMap doesn't have any way of guessing where to display the one true caption, although it will hide captions if they collide on the screen.
the best way to get around this is to add a better "Caption" column in your datasource, and set the Caption DataMapping to that column. this new column would have the duplicates removed.