Sharpmap Learning (3)

Source: Internet
Author: User

What I write is so plain that I hope to give some help to beginners. As for the in-depth study of SHARPMAP and GIS technology, Daniel, please give us a little more guidance to these rookie.

Today we will talk about the basic use of sharpmap, according to attribute to fill the color of the map objects, so that users can see more clearly the focus of the business object corresponding to the map representation, and how to customize the label layer display content, font size and so on. So today's main topic is customization: custom theme, custom label, and label Font.

First of all, we have to fill the map with different colors, so that they look colorful, easy to distinguish. For example, rivers and lakes to fill the blue, grass to fill the green, the house to fill the white, the road to fill the cyan and so on. How do you do it? Very simple, first look at the code:

SharpMap.Rendering.Thematics.CustomTheme itheme = new 

SharpMap.Rendering.Thematics.CustomTheme (Getmystyle);

When you initialize the map, add the preceding line of code. It defines a custom theme object whose constructor needs to pass in a method (delegate) that we write ourselves, which specifically describes how the theme is defined, and the method code is as follows:

private static SharpMap.Styles.VectorStyle Getmystyle (SharpMap.Data.FeatureDataRow

Row)

{

SharpMap.Styles.VectorStyle style = new

SharpMap.Styles.VectorStyle ();

Switch (row["Status"). ToString ().                    ToLower ())

{case

"available"://if status are interred, fill it with

yellow

Style.                    Fill = Brushes.yellow;

return style;

Default:

style.                    Fill = Brushes.green;

return style;

}

}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.