Hi,
I have a question about the sample sized point style.
I tried to recreate this sample in a wpf application and that doesn’t work ;-(
My Code is :
sql2008Layer = new MsSql2008FeatureLayer(connectString, “BaseDeDonn”, “FID”, 0);
sql2008Layer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
sql2008Layer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(AreaStyles.CreateSimpleAreaStyle(GeoColor.SimpleColors.Transparent, GeoColor.FromArgb(100, GeoColor.SimpleColors.Orange), 5));
SizedPointStyle sizedpointStyle = new SizedPointStyle(PointStyles.CreateSimpleCircleStyle(GeoColor.SimpleColors.Blue, 1), “Surface”, 1);
sizedpointStyle.Name = “Surface2”;
sizedpointStyle.IsActive = true;
sql2008Layer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(sizedpointStyle);
LayerOverlay staticOverlay = new LayerOverlay();
staticOverlay.Layers.Add(“sql2008Layer”, sql2008Layer);
wpfMap1.Overlays.Add(staticOverlay);
wpfMap1.CurrentExtent = sql2008Layer.GetBoundingBox();
wpfMap1.Refresh();
And the sizedPointStyle isn’t visible.
The data “Surface” is a decimal(18,10). I tested with a int type and that doesn’t work too.
Thanks for your help.
Regards.
Steph.
SizedPointStyle
Hi Steph,
Thanks to let us know your problem.
After to view the sample(wiki.thinkgeo.com/wiki/File:ServicesEditionSample_SizedPointStyle_CS_090728.zip), I found maybe you miss a line:
sql2008Layer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
If it still don’t works after add this line, please try to use ShapeFileFeatureLayer instead of MsSql2008FeatureLayer in your project to test, so that we can make sure whether the problem comes from SizedPointStyle or SQL envrionment.
And a simple sample should be helpful if your problem haven’t been solved.
Regards,
Don
Hi Don,
Thanks for your help.
I tested with one of my shape file and that doesn’t work.
But the geometry of my shape file are polygons type. With the sample the shape of the file WorlsCapitals are point.
This style works only with point type of geometry ?
We can not take the centroid of the feature ?
Is there a particular type of data which works with this style ?
For example, for WordsCapitals, “population” is an integer type. This Style can work with decimal type … ?
Thanks for your help.
Regards.
Steph
Hi Step,
You can view the code in SizedPointStyle.cs of the sample.
The size value will be converted to Float before calculate, so any type data should be OK.
And this only support Point, you can get centroid of your feature and build a new layer with the centroid points and render the new layer with SizedPointStyle.
The other solution is modify the code of SizedPointStyle, you can modify the DrawCore function like this:
protected override void DrawCore(IEnumerable<Feature> features, GeoCanvas canvas, Collection<SimpleCandidate> labelsInThisLayer, Collection<SimpleCandidate> labelsInAllLayers)
{
// Loop through each feaure and determine how large the point should
// be then adjust it’s size.
foreach (Feature feature in features)
{
float sizeData = Convert.ToSingle(feature.ColumnValues[sizeColumnName]);
float symbolSize = sizeData / ratio;
pointStyle.SymbolSize = symbolSize;
Feature tmpFeature = feature.GetBoundingBox().GetCenterPoint();
if (feature.GetShape() is PolygonShape)
{
tmpFeature = new Feature((feature.GetShape() as PolygonShape).GetCenterPoint());
}
pointStyle.Draw(new Collection<Feature>() { tmpFeature }, canvas, labelsInThisLayer, labelsInAllLayers);
}
}
That should works for you.
Any question please let me know.
Regards,
Don