ThinkGeo.com    |     Documentation    |     Premium Support

Drawing lots of different icons

In my app I need to draw many custom icons. It will allow multiple routes, and in each route I want a unique color for the icons, and in a route each intermediate icon would be numbered starting from one (I plan to generate the icon, drawing a number over the icon image in GDI+).


I know I can use a layer for that and configure an image for the points in that layer, but creating a layer for each icon made me confused and wondering if there's a better way.



Gustavo,


You can use our GdiPlusGeoCanvas instead of GDI+, our APIs are easier than GDI+'s if you want to draw something on our map control. And I want to confirm with you about your requirement, the different icon and different number is it like the following screen-shot?



Thanks


James



Yeah, that would be nice. Where can I find the sample code for something similar? 
  
 Besides genereted customized icons, I also would like to add them and many other kinds of static .png icons (POIs) to a layer or something, and not configure a layer for each specific type of icon, as I saw in the "Plot a latitude and a longitude point on the map" sample in the HowDoI app. 


Gustavo,


I am sorry I can not provide the entire code for you because it's in our another product MapSuiteRouting. The point is that you can use ValueStyle to draw different icon and use TextStyle to draw the number. Here is the sample code:


            // This layer contains the column "Key" which value is {1,2,3...}.
            ShapeFileFeatureLayer pointsLayer = new ShapeFileFeatureLayer(shapePathFilename);
            pointsLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(new TextStyle("Key", new GeoFont("Arial", 10), new GeoSolidBrush(GeoColor.SimpleColors.Black)));
            pointsLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            // Set icon images based on values
            ValueStyle valueStyle = new ValueStyle();
            valueStyle.ColumnName = "Key";
            valueStyle.ValueItems.Add(new ValueItem("1", new PointStyle(new GeoImage(geoImage1))));
            valueStyle.ValueItems.Add(new ValueItem("2", new PointStyle(new GeoImage(geoImage2))));
            valueStyle.ValueItems.Add(new ValueItem("3", new PointStyle(new GeoImage(geoImage3))));
            pointsLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(valueStyle);

Please let me know if that is not clear.


Thanks


James