ThinkGeo.com    |     Documentation    |     Premium Support

Loading state and city shape files together to display cities when zoom in


I have two shape files one for state and one for cities.On first load it should display states and when i zoomin it should display the cities.The below code displays only state even if i zoom in.Can somebody advice how to achieve this.Expected outputs are attached.





protected
 void Page_Load(object sender, EventArgs e)
        {
               Map1.MapBackground.BackgroundBrush = new GeoSolidBrush(GeoColor.FromHtml("#E5E3DF"));
            Map1.CurrentExtent = new RectangleShape(-125, 72, 50, -46);
            Map1.MapUnit = GeographyUnit.Meter;
            LayerOverlay staticOverlay = new LayerOverlay("WorldStaticOverlay");
            ShapeFileFeatureLayer worldLayer = new ShapeFileFeatureLayer("C:\\Work\\Maps\\States.shp");
            worldLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.CreateSimpleAreaStyle(GeoColor.SimpleColors.Transparent, GeoColor.FromArgb(100, GeoColor.SimpleColors.DarkRed));
            worldLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level05;
            staticOverlay.Layers.Add("worldLayer", worldLayer);
                ShapeFileFeatureLayer worldLayer1 = new ShapeFileFeatureLayer("C:\\Work\\Maps\\Cities.shp");
            worldLayer1.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.CreateSimpleAreaStyle(GeoColor.SimpleColors.Transparent, GeoColor.FromArgb(100, GeoColor.SimpleColors.Green));
            worldLayer1.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
             
            LayerOverlay staticOverlay1 = new LayerOverlay();
            staticOverlay1.Layers.Add(worldLayer1);
             
            Map1.CustomOverlays.Add(staticOverlay);
            Map1.CustomOverlays.Add(staticOverlay1);
             
        }


Hi Ugendran,



The cities don’t display is because the layer is a point layer but you are using the AreaStyle for this layer rather than the point style. Here are some guidance on those styles:

 Examples of styles include…


        
  • AreaStyle - Designed to render areas such as polygons, ellipses and rectangles.

  •     
  • LineStyle - Renders lines and multilines.

  •     
  • PointStyle - Draws points on the map using various symbols.

  •     
  • TextStyle - Labels features on the map.

  •     
  • ClassBreakStyle - Used to render feature groups differently based on their data values, ie. 0-100 Red, 100-200 Blue.

  •     
  • ValueStyle - Renders features differntly based on absolute values in their data, ie. MiddleSchool = Red, HighSchool=Blue.




So, in order to display the point style, we should some codes like the below:


ShapeFileFeatureLayer worldLayer1 = new ShapeFileFeatureLayer(“C:\Work\Maps\Cities.shp”);
worldLayer1.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = PointStyles.City1;
worldLayer1.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

Hope it helps.

Thanks,

Troy