New to Telerik Reporting? Download free 30-day trial

How to Create a Map with custom polygons

This topic explains how to create a map that shows custom-defined shapes. The Map item processes and renders polygon primitives using ShapeMapSeries, which accept Well-known text/Well-known binary or ESRI Shapefile as a source. Since creating ESRI Shapefiles requires additional tools, in this example the WKT polygon representation will be used. The resulting report will display three American states whose coordinates will be obtained from a CSV data source.

Displaying custom polygons using the Map item

  1. We will use the Choropleth wizard that will create the ShapeMap series instance for us. Start it either by selecting the Choropleth Wizard icon from the Data Presentation Templates section or from the Insert menu in Standalone Report Designer.

  2. Add new CSV Data Source and name it statesData. This data source will hold the information about the state name and their WKT-coordinates. Click OK to continue with the data source wizard.

  3. On the page Choose a CSV Source paste the following text in the Enter CSV as text tab:

    North Dakota;POLYGON((-104.064281 49.004828,-104.064281 45.945270,-96.557949 45.945270,-96.796902 46.641745,-96.763943 46.935113,-96.840847 47.006332,-96.879299 47.620830,-97.151211 48.176931,-97.105495 48.689066,-97.231838 49.004828,-104.064281 49.004828))
    Wyoming;POLYGON((-111.064309 45.005438,-111.064309 41.006683,-104.066018 41.006683,-104.066018 45.005438,-111.064309 45.005438))
    New Mexico;POLYGON((-109.065510 37.006785,-109.051777 31.332360,-108.208414 31.333407,-108.208493 31.783783,-106.528509 31.783783,-106.645607 31.896072,-106.614021 31.921719,-106.621574 31.971244,-106.638054 31.982311,-106.618623 32.000556,-103.064750 32.000519,-103.041428 36.500404,-103.002656 36.500529,-103.002220 36.999981,-109.065510 37.006785))

    Note that the WKT consists of closed polygons (i.e. the last point coincides with the first one) that are enumerated in a counter-clockwise order. See the OGC 10-032r8 specification for more information.

    Click Next when ready.

  4. On the Configure the separators page check only the Semicolon option and click Next.

  5. Skip the Escape Format page by clicking Next.

  6. On the CSV Headers page tick the The CSV has headers option. Click Next.

  7. On the Map columns to type page there should be displayed two columns: State and WKT that have type string. In the Data preview box should be displayed the formatted output of the CSV data. If everything is correct, close the wizard by clicking Finish.

  8. The data source wizard closes and the Choropleth Wizard activates, displaying the statesData data source we just created. Click Next.

  9. On the Choose a spatial data source page select the Well-Known-Text or Well-Known-Binary field from the data source option and choose the WKT field in the combobox below. Click Next.

  10. The Choropleth setup expects to setup the fields required to create a choropleth. Since our data source doesn't include any analytical information that could be used, just drag one of the two available fields in the Color data field box. Click Finish.

  11. When the wizard closes, the Map item should display the three polygons that roughly represent the state borders of North Dakota, Wyoming and New Mexico. Depending on your scenario, you can setup a TileProvider and add some additional styling to the data points and map:

    Map CustomWKT

In this article we demonstrated how to display custom-shaped polygons using ShapeMapSeries and Choropleth wizard. This approach is useful when is needed to show an additional layer or layers of geospatial data in a report.

See Also

In this article