Hi,
Currently we are evaluating XamMap control and came across a problem while using GeoSpatial Data Source. XamMap not functioning properly if I use multiple layers with GeoSpatial Data. It is working very nice with single layer and using other data formats like ShapeFile,Geo Imaginary DataSource.
Any suggestions would be greatly appriciated.
Thanks In Advance,
Sudheer CV.
Hi Sudheer
Could you elaborate a bit more on the issues you have when loading multiple shapefiles. Are all the features from shapefiles visible or are you experiencing performance issues ? Currently we are working on optimizing the performance of the XamMap and it will be ready for the next release.
Best Regards,
Iwan Kotev
Hi Iwan,
I have posted reply but it seems it was not successful. Any how the problem is not with ShapeFiles, with GeoSpatial Data I am getting problem with multiple layers. I created three layers for State,County and Street level. I need to display State layer first, so done necessary data binding, for remaining two layers I have not done any binding but kept them to visible after certain scale(say 6) of zooming. Nothing displayed on map when I run the application. So I removed County and Street layers and it is working fine.
I need to bind the County layer based on the State selected and Street layer based on the County slected.
Any suggestions?
Thanks in advance.
Sudheer Cv.
Hi Sudheer,
Could you try to load only the Country and then only the Street layer just to chech if these two shapefiles can be loaded.
Please take a look at this sample on how to show multiple shapefiles based on zooming in and out: https://es.infragistics.com/samples/silverlight/map/#/multiple-layers
Best Regards, Ivan Kotev
Hi Ivan,
My problem is not with ShapeFiles, it is with GeoSpatial Data.
Setting DataSource dynamically is supported by the SqlShapeReader and should work. I have built a sample application which loads and unloads geo-data from SQL Server:
In XAML:
<StackPanel x:Name="LayoutRoot"> <Button Content="Load" Click="Button_Click" Width="120"/> <Button Content="Unload" Click="Button_Click_1" Width="120"/> <Map:XamMap x:Name="xamMap"> <Map:XamMap.Layers> <Map:MapLayer LayerName="CountryLayer" Fill="Gray" FillMode="None" > <Map:MapLayer.Reader> <Map:SqlShapeReader DataMapping="Data=TheGeomDataColumn;Id=gid;Name=STATE_NAME;Caption=STATE_NAME"/> </Map:MapLayer.Reader> </Map:MapLayer> </Map:XamMap.Layers> </Map:XamMap></StackPanel>
And in Code behind:
private void Button_Click(object sender, RoutedEventArgs e){ var connString = "Data Source=localhost; Initial Catalog=spatialTest; Integrated Security=true"; var countryData = new Service1Client(); countryData.GetDataCompleted += roadData_GetDataCompleted; countryData.GetDataAsync(connString, "SELECT * FROM usa_st");}
private void Button_Click_1(object sender, RoutedEventArgs e) for (int i = xamMap.Layers[0].Elements.Count - 1; i >= 0; i--) { xamMap.Layers[0].Elements.RemoveAt(i); }}
private void roadData_GetDataCompleted(object sender, GetDataCompletedEventArgs e){ SqlShapeReader sqlReader = xamMap.Layers["CountryLayer"].Reader as SqlShapeReader; if (sqlReader != null) { sqlReader.DataSource = e.Result; xamMap.Layers["CountryLayer"].ImportAsync(); }}
It might be that there is some issue with data coming from the SQL Server or WCF service. Can you confirm that you are getting data in e.Result (in the GetDataCompleted method), also is there any information for exceptions in Visual Studio's Output window ?
Could you provide the code for setting "Sample" Layer's DataSource. In your previous sample you are setting dynamically only xamMap.Layers[0], which is the "Region" layer.
I am able to implement multiple layers if I bind the Data Source to Section layer initially, but my requirement is to bind the DataSource at later stage depending upon the Region that User selected. So initially I am not aware of the Section information to bind. I am able to implement this functionality using Shapefiles, but it is causing problems using GeoSpatialData.
What I want to do is, to create Map Layer initially but need to bind the Data Source dynamically at a later stage.
Thanks,
The code looks fine. Can you load only the "Section" layer ? Just checking, but you are setting the right DataMapping and DataSource for Section' SqlShapeReader and MapLayer's Visibility to "Visible" and not to "Collapsed" ?
Can you provide sample data from the SQL server?
Thanks.
Ivan Kotev
this is my Mark Up.
<igMap:XamMap Name="xamMap" >
<igMap:XamMap.Layers>
<igMap:MapLayer Name="Region" FillMode="Choropleth" >
<!--ToolTip="{}{Name}"-->
<igMap:MapLayer.Reader>
<igMap:SqlShapeReader DataMapping="Data=SpatialData;Name=ShapeID;Caption=ShapeID;Value=ShapeID;"></igMap:SqlShapeReader>
</igMap:MapLayer.Reader>
</igMap:MapLayer>
<igMap:MapLayer Name="Section" FillMode="Choropleth" Fill="Transparent" Visibility="Collapsed" VisibleFromScale="6" VisibleToScale="15">
<igMap:SqlShapeReader ></igMap:SqlShapeReader>
</igMap:XamMap.Layers>
</igMap:XamMap>
here is my code.
public partial class MultiLayers_GeoSpatial : UserControl
{
InfragisticsServiceClient svc = new InfragisticsServiceClient();
string connString = "Data Source=IRSDSK068\\SQLEXPRESS;Initial Catalog=GeoSpatialData;uid=igtest;pwd=igtest;";
public MultiLayers_GeoSpatial()
InitializeComponent();
svc.GetDataCompleted += new EventHandler<GetDataCompletedEventArgs>(svc_GetDataCompleted);
svc.GetDataAsync(connString, "select ShapeID,SpatialData from tblSpatialData_US where shapeid<19");
}
void svc_GetDataCompleted(object sender, GetDataCompletedEventArgs e)
SqlShapeReader reader = xamMap.Layers[0].Reader as SqlShapeReader;
reader.DataSource = e.Result;
xamMap.Layers[0].ImportAsync();
It is working good without "Section" layer.
I am using Sql Server as GeoSpatial Data with Geography data type.
Could you provide some sample code so we can investigate this issue? Are you using SQL Server as a GeoSpatial Data Source ?