Project

General

Profile

Mapping Polygons and Countries

The basic setup and creation of maps follow the same basic 3-steps as outlined in the Basic Mapping Documentation. Mapping Polygons simply requires selecting the correct Geofield widget and understanding the UI. Mapping countries, however, takes installing two new modules, using a new field type and setting up the data layer from step 1 slightly differently.

Mapping Polygons

The setup for polygons follows the same basic data setup as points: Create a content type for the data we're collecting, and add a geofield. Select OpenStreet Map as the widget. Set the field to be required and adjust the default map center and zoom for data entry if that's needed. The rest of the defaults should be fine to accept. When editing the content, the map appears for the user to enter the data.

To create an area on the map instead of a point, select the polygon tool in the top right hand corner of the map. It looks like a closed set of lines that's shaded in the middle. Then click you're first point on the map to start the polygon. You must select them in a single direction around the outside of the shape. You can't add points between two already added ones. To finish selecting, hold down the shift key when selecting the last one to release the drawing. There's a polygon on the map widget that will render as a series of longitude and latitude points when viewing the content.

Creating a map of polygon data follows the same three steps as described in the Basic Mapping Documentation. The data formatter when creating the aggregation layer is the same as a single point, WKT. Hand creating polygons is an unlikely data entry scenario, though. It is demonstrative for using a series of longitude and latitude like for mapping countries.

Mapping Countries

Since country borders are unstable, maintaining the exact longitude and latitude could become cumbersome. As such there's a countries border module we can install that maintains these points for us. We simply select the country when entering the data, and reference that selection when building the map with the actual coordinates. If the borders of a country change, the module will be updated and subsequently our maps will be automatically updated.

We first have to install two modules, countries and countries_borders. The former provides an explicit field data type for the country, while the latter provides the longitude and latitude coordinates for each. The former is for data entry; the latter for data aggregation.

Create a content type and add a field type of country and choose the widget of Countries by Continent. This is a chain selected list of countries, which is better data entry presentation than the entire list of countries as radio buttons or checkboxes or the error prone open text box. Though these all do have their uses. In some cases it might be desired to list all the available countries of a given content type, and since it's possible to limit the available in the next configuration step, we could list all the available countries. Set the field to be required and unless you're limiting the available countries there are no other configuration options needed. When creating or editing the content, only the countries are listed. There is no direct mapping data. That's handled at the data aggregation step, step 1 of the normal 3 step process for creating maps.

After creating the data aggregation view and before adding any fields, you need to add a Relationship to the view. Click open the Advanced section on the right hand side, click Add next to the Relationship heading. Then select the content country field we created in the above steps. The defaults should be fine; we don't need to require the relationship.

Now we proceed to adding the fields. We add a Country: Borders field, which is the mapping data from the countries_border module. We configure this field to use the relationship we created to the country data from the content type; it should be the only option. Formatter should be WKT and data options should be Use full geometry. Conceptually the way this field work is it will provide the longitude and latitude coordinate series for what country we've selected when entering the data. That's how the relationship works. Add the Title and the Body as we've done with other maps in order to provide information about the data being mapped.

When configuring the OpenLayers Data Overlay, set the Map Data Sources to WKT and select the Country: Borders field as WKT source. The final steps for mapping the countries will follow the same steps as in the Basic Mapping Documentation.

Also available in: PDF HTML TXT

Go to top
Add picture from clipboard (Maximum size: 40 MB)