Hi,
I have this project where I should draw several polygons in the Information Layer, and should have the ability to paint them on different colors. I tried the following approach (that draws two objects), but it is painting ALL the polygons in the IL with the same color, actually the latest color.
Seems to me that the colors are being applyed onto the IL and not the polygons. There is a way to use different colors for the different polygons in the same IL, or should I use different IL (one for each polygon)?
This is my MainPage.xaml.cs:
And this is my MainPage.xaml:
Thanks!
I have this project where I should draw several polygons in the Information Layer, and should have the ability to paint them on different colors. I tried the following approach (that draws two objects), but it is painting ALL the polygons in the IL with the same color, actually the latest color.
Seems to me that the colors are being applyed onto the IL and not the polygons. There is a way to use different colors for the different polygons in the same IL, or should I use different IL (one for each polygon)?
This is my MainPage.xaml.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Threading;
using System.Windows.Browser;
using System.Configuration;
using Telerik.Windows.Controls.Map;
using System.Collections.ObjectModel;
using System.Xml.Linq;
namespace YV_GIS
{
public partial class MainPage : UserControl
{
double _LATITUDE;
double _LONGITUDE;
private Collection<
GeoType
> _GeoShapes;
public Collection<
GeoType
> GeoShapes
{
get
{
return this._GeoShapes;
}
set
{
this._GeoShapes = value;
}
}
public MainPage()
{
GeoShapes = new Collection<
GeoType
>();
InitializeComponent();
// Initialize Bing map provider
this.radMap.Provider = new BingMapProvider(MapMode.Aerial, true, "mytoken");
this.radMap.InitializeCompleted += new EventHandler(radMap_InitializeCompleted);
DrawPolygon(Colors.Gray,Colors.Green, 1,"POLYGON ((-94.264725 45.56285, -94.26535 45.562862, -94.26879 45.56287, -94.26881 45.56248, -94.26838 45.562424, -94.26808 45.56223, -94.26748 45.562176, -94.266174 45.562145, -94.26584 45.562073, -94.26506 45.562, -94.26496 45.56204, -94.26497 45.562084, -94.26473 45.56217))");
DrawPolygon(Colors.Gray,Colors.Red, 2,"POLYGON ((-94.264725 45.56285, -94.26535 45.562862, -94.26879 45.56287, -94.26473 45.56217))");
}
private void radMap_InitializeCompleted(object sender, EventArgs e)
{
Navigate(CoordToDec(45, 34, 02,"N"), CoordToDec(94, 16, 04,"W"));
Zoom(5); // 100m
}
private void DrawPolygon(Color fill, Color stroke, int thick, String coordinates)
{
GeoType Poly = new GeoType();
Poly.Fill = fill;
Poly.Stroke = stroke;
Poly.Thick = thick;
Poly.Geometry = coordinates;
GeoShapes.Add(Poly);
MySQLReader.Source = GeoShapes;
MySQLReader.GeospatialPropertyName = "Geometry";
MyShapeFill.Fill = new SolidColorBrush(fill);
MyShapeFill.Stroke = new SolidColorBrush(stroke);
MyShapeFill.StrokeThickness = thick;
}
private void Navigate(double latitude,double longitude)
{
// set current location
_LATITUDE = latitude;
_LONGITUDE = longitude;
// pan map
Location MyLocation = new Location();
MyLocation.Latitude = _LATITUDE;
MyLocation.Longitude = _LONGITUDE;
this.radMap.Center = MyLocation;
}
private void Zoom(int zoom)
{
this.radMap.ZoomLevel = zoom;
}
// converts full cordinate in degrees,minutes,seconds to decimal value
private float CoordToDec(int degrees,float minutes,float seconds,string direction)
{
int factor = 1;
if ((direction == "S") || (direction == "W"))
factor = -1;
return (degrees + (minutes / 60) + (seconds / 3600))*factor;
}
}
public class GeoType
{
private string _geometry;
public string Geometry
{
get
{
return this._geometry;
}
set
{
this._geometry = value;
}
}
}
}
And this is my MainPage.xaml:
<
UserControl
x:Class
=
"YV_GIS.MainPage"
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"
>
<
telerik:InformationLayer
Name
=
"MyInformationLayer"
>
<
telerik:InformationLayer.Reader
>
<
telerik:SqlGeospatialDataReader
x:Name
=
"MySQLReader"
/>
</
telerik:InformationLayer.Reader
>
<
telerik:InformationLayer.ShapeFill
>
<
telerik:MapShapeFill
x:Name
=
"MyShapeFill"
/>
</
telerik:InformationLayer.ShapeFill
>
</
telerik:InformationLayer
>
</
telerik:RadMap
>
</
Grid
>
</
UserControl
>
Thanks!