Hi,
I am trying to trace a polygon on the information layer with data retrieved from SQL Server.
Everything SEEMS fine, but the fact is that the polygon is NOT being rendered!
I have this LoadPolygon function that invokes the proper stored procedure in MSSQL and when the data is fully loaded, it triggs the LoadedPolygon event. I have checked and the data IS being properly loaded in the LoadedPolygon through the string var MinnesotaState (the polygon should be a stroke line surrounding the MN state). Only the RadMap is declared in the XAML file and all the rest is instantiated programatically in the xaml.cs code (the information layer, the SQLGeospatialDataReader and the MapShapeFill).
The data loaded is in the format:
POLYGON ((-96.799938 46.817947, -96.799911999999992 46.817628, ... etc ... ))
The application compiles and run smoothly (no warnings or errors), but the polygon itself is NEVER rendered...
What am I missing here?
Thanks!
Here my "MainPage.xaml":
<UserControl x:Class="YV_GIS.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="600" d:DesignWidth="1000"
xmlns:telerikQuickStart="clr-namespace:Telerik.Windows.Controls.QuickStart;assembly=Telerik.Windows.Controls"
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation">
<Grid x:Name="LayoutRoot" Background="White" Height="600" Width="1000">
<telerik:RadMap x:Name="radMap" Width="1000" Height="600" />
</Grid>
</UserControl>
And here my "MainPage.xaml.cs":
namespace YV_GIS
{
public partial class MainPage : UserControl
{
public MainPage()
{
InitializeComponent();
this.radMap.Provider = new BingMapProvider(MapMode.Aerial, true, "myBingKey");
this.radMap.InitializeCompleted += new EventHandler(radMap_InitializeCompleted);
}
private void radMap_InitializeCompleted(object sender, EventArgs e)
{
LoadPolygon("ReadPolygon.aspx");
}
private void LoadPolygon(String myurl)
{
WebClient webClient = new WebClient();
webClient.Headers["content-type"] = "application/x-www-form-urlencoded";
webClient.Encoding = Encoding.UTF8;
webClient.UploadStringCompleted += new UploadStringCompletedEventHandler(LoadedPolygon);
webClient.UploadStringAsync(new Uri(SERVER_ADDRESS + myurl, UriKind.Absolute), "POST", "");
}
private void LoadedPolygon(object sender, UploadStringCompletedEventArgs e)
{
XDocument xmlDoc = XDocument.Parse(e.Result);
var MyPolygons = from MyPolygon in xmlDoc.Descendants("geodata")
select new
{
polygon = MyPolygon.Element("polygon").Value,
};
String MinnesotaState = "";
foreach (var MyPolygon in MyPolygons)
MinnesotaState += MyPolygon.polygon;
SqlGeospatialDataReader MySQLGDR = new SqlGeospatialDataReader();
MySQLGDR.Source = MinnesotaState;
InformationLayer MyInfoLayer = new InformationLayer();
MyInfoLayer.Reader = MySQLGDR;
MapShapeFill MyShapeFill = new MapShapeFill();
MyShapeFill.Fill = new SolidColorBrush(Colors.Gray);
MyShapeFill.Stroke = new SolidColorBrush(Colors.Red);
MyShapeFill.StrokeThickness = 3;
MyInfoLayer.ShapeFill = MyShapeFill;
MyInfoLayer.UpdateLayout();
}
}
}
I am trying to trace a polygon on the information layer with data retrieved from SQL Server.
Everything SEEMS fine, but the fact is that the polygon is NOT being rendered!
I have this LoadPolygon function that invokes the proper stored procedure in MSSQL and when the data is fully loaded, it triggs the LoadedPolygon event. I have checked and the data IS being properly loaded in the LoadedPolygon through the string var MinnesotaState (the polygon should be a stroke line surrounding the MN state). Only the RadMap is declared in the XAML file and all the rest is instantiated programatically in the xaml.cs code (the information layer, the SQLGeospatialDataReader and the MapShapeFill).
The data loaded is in the format:
POLYGON ((-96.799938 46.817947, -96.799911999999992 46.817628, ... etc ... ))
The application compiles and run smoothly (no warnings or errors), but the polygon itself is NEVER rendered...
What am I missing here?
Thanks!
Here my "MainPage.xaml":
<UserControl x:Class="YV_GIS.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="600" d:DesignWidth="1000"
xmlns:telerikQuickStart="clr-namespace:Telerik.Windows.Controls.QuickStart;assembly=Telerik.Windows.Controls"
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation">
<Grid x:Name="LayoutRoot" Background="White" Height="600" Width="1000">
<telerik:RadMap x:Name="radMap" Width="1000" Height="600" />
</Grid>
</UserControl>
And here my "MainPage.xaml.cs":
namespace YV_GIS
{
public partial class MainPage : UserControl
{
public MainPage()
{
InitializeComponent();
this.radMap.Provider = new BingMapProvider(MapMode.Aerial, true, "myBingKey");
this.radMap.InitializeCompleted += new EventHandler(radMap_InitializeCompleted);
}
private void radMap_InitializeCompleted(object sender, EventArgs e)
{
LoadPolygon("ReadPolygon.aspx");
}
private void LoadPolygon(String myurl)
{
WebClient webClient = new WebClient();
webClient.Headers["content-type"] = "application/x-www-form-urlencoded";
webClient.Encoding = Encoding.UTF8;
webClient.UploadStringCompleted += new UploadStringCompletedEventHandler(LoadedPolygon);
webClient.UploadStringAsync(new Uri(SERVER_ADDRESS + myurl, UriKind.Absolute), "POST", "");
}
private void LoadedPolygon(object sender, UploadStringCompletedEventArgs e)
{
XDocument xmlDoc = XDocument.Parse(e.Result);
var MyPolygons = from MyPolygon in xmlDoc.Descendants("geodata")
select new
{
polygon = MyPolygon.Element("polygon").Value,
};
String MinnesotaState = "";
foreach (var MyPolygon in MyPolygons)
MinnesotaState += MyPolygon.polygon;
SqlGeospatialDataReader MySQLGDR = new SqlGeospatialDataReader();
MySQLGDR.Source = MinnesotaState;
InformationLayer MyInfoLayer = new InformationLayer();
MyInfoLayer.Reader = MySQLGDR;
MapShapeFill MyShapeFill = new MapShapeFill();
MyShapeFill.Fill = new SolidColorBrush(Colors.Gray);
MyShapeFill.Stroke = new SolidColorBrush(Colors.Red);
MyShapeFill.StrokeThickness = 3;
MyInfoLayer.ShapeFill = MyShapeFill;
MyInfoLayer.UpdateLayout();
}
}
}