ThinkGeo.com    |     Documentation    |     Premium Support

Adding Image to line shape files

I have a highways shape file and want to display an image with the highway name over each one.  The image is the symbol for interstate, state highway, etc.  The highways and names display ok, but the images never show up.  Here is the code, any ideas what I'm missing?


 


            layer = new ShapeFileFeatureLayer(MAPPING_PATH + "highways.shp");

            color = Color.Yellow;

            layer.ZoomLevelSet.ZoomLevel08.CustomStyles.Add(new LineStyle(new GeoPen(new GeoColor(color.R, color.G, color.B)), new GeoPen(new GeoColor(color.R, color.G, color.B))));

            layer.ZoomLevelSet.ZoomLevel08.CustomStyles.Add(new TextStyle("NAME", new GeoFont(this.Font.FontFamily.Name, 10), new GeoSolidBrush(GeoColor.StandardColors.Black)));

            layer.ZoomLevelSet.ZoomLevel08.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            valueStyle = new ValueStyle();

            valueStyle.ColumnName = "SHIELD";

            valueStyle.ValueItems.Add(new ValueItem("I", new PointStyle(new GeoImage(FEATURE_IMAGE_PATH + "interstate_highway.bmp"))));

            valueStyle.ValueItems.Add(new ValueItem("U", new PointStyle(new GeoImage(FEATURE_IMAGE_PATH + "us_highway.bmp"))));

            valueStyle.ValueItems.Add(new ValueItem("S", new PointStyle(new GeoImage(FEATURE_IMAGE_PATH + "state_highway.bmp"))));

           

            layer.ZoomLevelSet.ZoomLevel08.CustomStyles.Add(valueStyle);

            shapeOverlay.Layers.Add("highways", layer);



Michael,


I am sorry you probablly cannot get the image out because the PointStyle only draw when the feature is in PointType. Try using the ValueIconStyle instead.


I tried to change your code as following:



            ShapeFileFeatureLayer symbolLayer = new ShapeFileFeatureLayer(MAPPING_PATH + "highways.shp");
            Color color = Color.Yellow;
            symbolLayer.ZoomLevelSet.ZoomLevel08.DefaultLineStyle = new LineStyle(new GeoPen(new GeoColor(color.R, color.G, color.B)), new GeoPen(new GeoColor(color.R, color.G, color.B)));
            symbolLayer.ZoomLevelSet.ZoomLevel08.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            TextStyle textStyle = new TextStyle("NAME", new GeoFont(this.Font.FontFamily.Name, 10), new GeoSolidBrush(GeoColor.StandardColors.Black));
            ShapeFileFeatureLayer labelLayer = new ShapeFileFeatureLayer(MAPPING_PATH + "highways.shp");
            IconValueStyle iconValueStyle = new IconValueStyle();
            iconValueStyle.ColumnName = "SHIELD";
            iconValueStyle.IconValueItems.Add(new IconValueItem("I", new GeoImage(FEATURE_IMAGE_PATH + "interstate_highway.bmp"), textStyle));
            iconValueStyle.IconValueItems.Add(new IconValueItem("U", new GeoImage(FEATURE_IMAGE_PATH + "us_highway.bmp"), textStyle));
            iconValueStyle.IconValueItems.Add(new IconValueItem("S", new GeoImage(FEATURE_IMAGE_PATH + "state_highway.bmp"), textStyle));
            labelLayer.ZoomLevelSet.ZoomLevel08.CustomStyles.Add(iconValueStyle);
            labelLayer.ZoomLevelSet.ZoomLevel08.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            shapeOverlay.Layers.Add("Symbol", symbolLayer);
            shapeOverlay.Layers.Add("Label", labelLayer);

Any more questions just feel free to let me know.


Thanks.


Yale

 



Thx, 
 That did it.

You are welcome , Michael. 
  
 Just feel free to let me know if any mor problems. 
  
 Yale