i am using afghanistan river shapefile but problem is file display name of river i wants to display river picture on it with actual points area how i do it my code is:
ShapeFileFeatureLayer river= new ShapeFileFeatureLayer(MapPath("~/Layers/riverLayer635271929535992893.shp"));
// We can customize our own TextStyle. Here we passed in the font, the size, the style and the color.
river.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = TextStyles.CreateSimpleTextStyle("NAM",
"Arial", 8, DrawingFontStyles.Italic, GeoColor.StandardColors.Black, 3, 3);
// The TextStyle we set here is available from ZoomLevel01 to ZoomLevel05.
river.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level05;
river.ZoomLevelSet.ZoomLevel06.DefaultTextStyle = TextStyles.Capital3("NAM");
river.ZoomLevelSet.ZoomLevel01.DefaultLineStyle = LineStyles.River1;
// The TextStyle we set here is available from ZoomLevel06 to ZoomLevel20.
river.ZoomLevelSet.ZoomLevel06.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
River shape file display
Hi Raja,
Your code have some problem, you hadn’t set text style for zoom level 1 ~ 5, and you hadn’t set line style for 6 ~ 20.
You should want to modify it like this:
// The TextStyle we set here is available from ZoomLevel01 to ZoomLevel05.
river.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = TextStyles.Capital3(“NAM”);
river.ZoomLevelSet.ZoomLevel01.DefaultLineStyle = LineStyles.River1;
river.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level05;
// The TextStyle we set here is available from ZoomLevel06 to ZoomLevel20.
river.ZoomLevelSet.ZoomLevel06.DefaultTextStyle = TextStyles.Capital3(“NAM”); // Please modify the style
river.ZoomLevelSet.ZoomLevel06.DefaultLineStyle = LineStyles.River1; // Please modify the style
river.ZoomLevelSet.ZoomLevel06.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
Regards,
Don
could you please give me example of river show on map thanks
could you please give me example of river show on map thanks
Hi Raja,
Could you please upload your sample project with your data, so we can help you see why it don’t shows correct and modify the code?
Regards,
Don
i am trying to upload my project but it failed this is my entire layer function please review it.
Map1.MapUnit = GeographyUnit.DecimalDegree;
GoogleOverlay google = new GoogleOverlay("Google Map");
google.JavaScriptLibraryUri = new Uri(@"maps.googleapis.com/maps/api/js?sensor=false");
google.GoogleMapType = GoogleMapType.Normal;
ShapeFileFeatureLayer worldLayer = new ShapeFileFeatureLayer(MapPath("~/App_Data/Countries02.shp"));
worldLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.Country1;
worldLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
ShapeFileFeatureLayer cities = new ShapeFileFeatureLayer(MapPath("~/Layers/Hospital Layer635271929535992893.shp"));
cities.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.Country1;
cities.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
ShapeFileFeatureLayer provinceShapefile = new ShapeFileFeatureLayer(MapPath("~/App_Data/province.shp"));
provinceShapefile.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = TextStyles.CreateSimpleTextStyle("FIELD4","Arial",
8, DrawingFontStyles.Italic, GeoColor.StandardColors.Black, 3, 3);
provinceShapefile.ZoomLevelSet.ZoomLevel02.DefaultLineStyle = LineStyles.ContestedBorder1;
provinceShapefile.ZoomLevelSet.ZoomLevel06.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
//
ShapeFileFeatureLayer capitalLayer = new ShapeFileFeatureLayer(MapPath("~/App_Data/WorldCapitals.shp"));
// We can customize our own Style. Here we passed in a color and a size.
capitalLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle =
PointStyles.CreateSimpleCircleStyle(GeoColor.StandardColors.White, 7, GeoColor.StandardColors.Brown);
// The Style we set here is available from ZoomLevel01 to ZoomLevel05. That means if we zoom in a bit more, the appearance we set here will not be visible anymore.
capitalLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level05;
capitalLayer.ZoomLevelSet.ZoomLevel06.DefaultPointStyle = PointStyles.Capital3;
// The Style we set here is available from ZoomLevel06 to ZoomLevel20. That means if we zoom out a bit more, the appearance we set here will not be visible any more.
capitalLayer.ZoomLevelSet.ZoomLevel06.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
ShapeFileFeatureLayer capitalLabelLayer = new ShapeFileFeatureLayer(MapPath("~/App_Data/WorldCapitals.shp"));
// We can customize our own TextStyle. Here we passed in the font, the size, the style and the color.
capitalLabelLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = TextStyles.CreateSimpleTextStyle("CITY_NAME",
"Arial", 8, DrawingFontStyles.Italic, GeoColor.StandardColors.Black, 3, 3);
// The TextStyle we set here is available from ZoomLevel01 to ZoomLevel05.
capitalLabelLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level05;
capitalLabelLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle = LineStyles.Highway1;
capitalLabelLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = PointStyles.Capital1;
capitalLabelLayer.ZoomLevelSet.ZoomLevel06.DefaultTextStyle = TextStyles.Capital3("CITY_NAME");
// The TextStyle we set here is available from ZoomLevel06 to ZoomLevel20.
capitalLabelLayer.ZoomLevelSet.ZoomLevel06.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
InMemoryFeatureLayer myData = ReportsForDEOAndQc();
capitalLabelLayer.DrawingMarginPercentage = 50;
ShapeFileFeatureLayer Road = new ShapeFileFeatureLayer(MapPath("~/App_Data/kalibo_road.shp"));
// We can customize our own TextStyle. Here we passed in the font, the size, the style and the color.
Road.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = TextStyles.CreateSimpleTextStyle("FIELD2",
"Arial", 8, DrawingFontStyles.Italic, GeoColor.StandardColors.Black, 3, 3);
// The TextStyle we set here is available from ZoomLevel01 to ZoomLevel05.
Road.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level05;
Road.ZoomLevelSet.ZoomLevel06.DefaultTextStyle = TextStyles.Capital3("FIELD2");
Road.ZoomLevelSet.ZoomLevel01.DefaultLineStyle = LineStyles.River1;
// The TextStyle we set here is available from ZoomLevel06 to ZoomLevel20.
Road.ZoomLevelSet.ZoomLevel06.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
ShapeFileFeatureLayer.BuildIndexFile(MapPath("~/App_Data/afg_airports_airfields.shp"));
Road.DrawingMarginPercentage = 50;
ShapeFileFeatureLayer River = new ShapeFileFeatureLayer(MapPath("~/app_data/river-region.shp"));
ClassBreakStyle classBreakStyle = new ClassBreakStyle("AREA_");
classBreakStyle.ClassBreaks.Add(new ClassBreak(0, new AreaStyle(new GeoPen(GeoColor.StandardColors.Black, 3))));
classBreakStyle.ClassBreaks.Add(new ClassBreak(20, new AreaStyle(new GeoPen(GeoColor.StandardColors.YellowGreen, 3))));
//River.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level05;
classBreakStyle.ClassBreaks.Add(new ClassBreak(40, new AreaStyle(new GeoPen(GeoColor.StandardColors.Red, 3))));
//River.ZoomLevelSet.ZoomLevel06.DefaultTextStyle = TextStyles.River1("NAME1_");
//River.ZoomLevelSet.ZoomLevel01.DefaultLineStyle = LineStyles.River1;
//River.ZoomLevelSet.ZoomLevel06.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
River.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(classBreakStyle);
River.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
ShapeFileFeatureLayer Prov = new ShapeFileFeatureLayer(MapPath("~/app_data/Province.shp"));
ClassBreakStyle classBreakStyle1 = new ClassBreakStyle("FIELD1");
classBreakStyle1.ClassBreaks.Add(new ClassBreak(0, new AreaStyle(new GeoPen(GeoColor.StandardColors.Black, 3))));
classBreakStyle1.ClassBreaks.Add(new ClassBreak(20, new AreaStyle(new GeoPen(GeoColor.StandardColors.YellowGreen, 3))));
//River.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level05;
classBreakStyle1.ClassBreaks.Add(new ClassBreak(40, new AreaStyle(new GeoPen(GeoColor.StandardColors.Red, 3))));
//River.ZoomLevelSet.ZoomLevel06.DefaultTextStyle = TextStyles.River1("NAME1_");
//River.ZoomLevelSet.ZoomLevel01.DefaultLineStyle = LineStyles.River1;
//River.ZoomLevelSet.ZoomLevel06.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
Prov.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(classBreakStyle1);
Prov.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
Map1.StaticOverlay.Layers.Add(worldLayer);
Map1.StaticOverlay.Layers.Add(capitalLayer);
Map1.StaticOverlay.Layers.Add(capitalLabelLayer);
Map1.StaticOverlay.Layers.Add(Prov);
Map1.StaticOverlay.Layers.Add(cities);
Map1.StaticOverlay.Layers.Add(myData);
//Map1.StaticOverlay.Layers.Add(River);
Map1.CurrentExtent = new RectangleShape(5, 78, 30, 26);
Map1.MapTools.OverlaySwitcher.Enabled = true;
Map1.MapTools.MouseCoordinate.Enabled = true;
// Set the background color to make the map beautiful.
Map1.MapBackground.BackgroundBrush = new GeoSolidBrush(GeoColor.GeographicColors.ShallowOcean);
thanks
Hi Raja,
Does your river render by this line?
ShapeFileFeatureLayer River = new ShapeFileFeatureLayer(MapPath("~/app_data/river-region.shp"));
It looks your code is so confusion,your river should be line shapes, but you render it mainly for area style.
Please make sure what’s shape type then set style for it.
And you asked: “problem is file display name of river i wants to display river picture on it with actual points area”, I want to make sure whether that meant you want to shows an image instead of label for the river line?
Regards,
Don
Ok i am going to clean code for you
//this will add worldlayer on map
ShapeFileFeatureLayer worldLayer = new ShapeFileFeatureLayer(MapPath("~/App_Data/Countries02.shp"));
worldLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.Country1;
worldLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
//
this will add world capitals on map
ShapeFileFeatureLayer capitalLayer = new ShapeFileFeatureLayer(MapPath("~/App_Data/WorldCapitals.shp"));
// We can customize our own Style. Here we passed in a color and a size.
capitalLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle =
PointStyles.CreateSimpleCircleStyle(GeoColor.StandardColors.White, 7, GeoColor.StandardColors.Brown);
// The Style we set here is available from ZoomLevel01 to ZoomLevel05. That means if we zoom in a bit more, the appearance we set here will not be visible anymore.
capitalLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level05;
capitalLayer.ZoomLevelSet.ZoomLevel06.DefaultPointStyle = PointStyles.Capital3;
// The Style we set here is available from ZoomLevel06 to ZoomLevel20. That means if we zoom out a bit more, the appearance we set here will not be visible any more.
capitalLayer.ZoomLevelSet.ZoomLevel06.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
ShapeFileFeatureLayer capitalLabelLayer = new ShapeFileFeatureLayer(MapPath("~/App_Data/WorldCapitals.shp"));
// We can customize our own TextStyle. Here we passed in the font, the size, the style and the color.
capitalLabelLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = TextStyles.CreateSimpleTextStyle(“CITY_NAME”,
“Arial”, 8, DrawingFontStyles.Italic, GeoColor.StandardColors.Black, 3, 3);
// The TextStyle we set here is available from ZoomLevel01 to ZoomLevel05.
capitalLabelLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level05;
capitalLabelLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle = LineStyles.Highway1;
capitalLabelLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = PointStyles.Capital1;
capitalLabelLayer.ZoomLevelSet.ZoomLevel06.DefaultTextStyle = TextStyles.Capital3(“CITY_NAME”);
// The TextStyle we set here is available from ZoomLevel06 to ZoomLevel20.
capitalLabelLayer.ZoomLevelSet.ZoomLevel06.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
and this code show break river in line class and drag line on map
ShapeFileFeatureLayer River = new ShapeFileFeatureLayer(MapPath("~/app_data/river-region.shp"));
ClassBreakStyle classBreakStyle = new ClassBreakStyle(“AREA_”);
classBreakStyle.ClassBreaks.Add(new ClassBreak(0, new AreaStyle(new GeoPen(GeoColor.StandardColors.Black, 3))));
classBreakStyle.ClassBreaks.Add(new ClassBreak(20, new AreaStyle(new GeoPen(GeoColor.StandardColors.YellowGreen, 3))));
//River.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level05;
classBreakStyle.ClassBreaks.Add(new ClassBreak(40, new AreaStyle(new GeoPen(GeoColor.StandardColors.Red, 3))));
//River.ZoomLevelSet.ZoomLevel06.DefaultTextStyle = TextStyles.River1(“NAME1_”);
//River.ZoomLevelSet.ZoomLevel01.DefaultLineStyle = LineStyles.River1;
//River.ZoomLevelSet.ZoomLevel06.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
River.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(classBreakStyle);
River.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
but instead of this i wants to display river like an image is there is any way i don’t know how to get river like actual water display in map
Hi Raja,
I think I know what’s your target.
If your river is line shape, you can draw it a little thick and set a blue color for it, which can looks better.
If your river is polygon shape, you can directly render it as AreaStyles.Water1 or AreaStyles.Water2.
Regards,
Don