How can I draw symbols (restuarents, hospitals, ...) to my map?

Topics: Algorithms, General Topics, SharpMap v0.9 / v1.x
Aug 12, 2008 at 2:45 PM
Hello, your good-selft

the subject is clear

How could I do that? and what layer type should I use?
Aug 13, 2008 at 5:31 AM
You need to create a layer and specify the symbol for it to use (hospital, restaurant...).  In the example below, I use a point shapefile of cities and render the city locations using a symbol that is embedded in my resources

                        //shapefile
                        SharpMap.Layers.VectorLayer myGenericLayer = new SharpMap.Layers.VectorLayer(layerName);
                        //Specifing true will save the spatial index to a file which will make it load quicker the next time
                        myGenericLayer.DataSource = new SharpMap.Data.Providers.ShapeFile(mapPath, true);
                        //get the icon from the resources
                        System.Drawing.Bitmap bitmapCity = Mapper.Properties.Resources.city_pin;
                        myGenericLayer.Style.Symbol = new Bitmap(bitmapCity);
                        //determine if the layer if rendered by default
                        myGenericLayer.Enabled = lyr.layerVisible;
                        mapImage1.Map.Layers.Add(myGenericLayer);

You'll need to do a separate layer for each type of symbol that you want.  Otherwise, you can do the theme mode again and render each symbol on the fly.
Aug 13, 2008 at 8:30 AM
Ok, I'll check that.

and reply if necessary, thanks.