Mapping With Drupal - Alan Palazzolo [13]
In some cases a map is not the best interface for geographic data, whether because of the size of the data set or because people can not access visual information due to a visual impairment. For both accessibility and search engine optimization, it is often worth creating alternative text-based ways of displaying the same data. The Views module in Drupal makes this straightforward. A map is just one display type in Views; you can provide the same information as a list or table. This is covered in Other Ways of Displaying Spatial Data.
Chapter 3. Spatial Data
Before you can display a map, you need to get spatial data into your site in some way. Drupal gives you many options for modules and data formats to use. This chapter provides an overview of these and outlines the strengths and weaknesses of each. Four aspects of dealing with spatial data will be covered: how the data is stored in Drupal, how the data is input by users, how the data is manipulated, and how it can be queried.
NOTE
Many modules handle several aspects of data storage, manipulation, and display, so you will notice the same modules in several sections of this chapter and the rest of the book.
Drupal has a vibrant community of contributors, and this translates to many different modules and approaches to similar problems. This is great for promoting innovation and solving specific needs, but can make it difficult for site builders to work out the best solutions for their particular problems. This chapter will not be able to cover all the possibilities for spatial data in Drupal, but it will give you an in-depth look at the more established methods.
NOTE
The Drupal Mapping Group has a wiki page that describes the different geospatial modules and is the best place to get an overview of the modules available for your geospatial needs.
Data Storage
Different data formats for spatial data were introduced in Data Storage. This section will introduce the different modules and approaches for working with those data formats, and work through tutorials for implementing these with Drupal.
NOTE
If you are unfamiliar with Drupal terminology like module and node, you can look them up online in the Drupal glossary.
Database Layer in Drupal
Drupal 7 offers a powerful and adaptable database abstraction layer. The abstraction layer allows developers to write database queries and modules that will work on different types of databases. Drupal aims to support MySQL, Postgres, and SQLite. Other database, such as Microsoft SQL Server and Oracle, can be supported by installing contributed modules.
NOTE
Drupal core has a huge amount of inline documentation in the code, which is automatically parsed and collected on Drupal’s API reference website. This includes a page on the database abstraction layer. There is also lots of community-sourced documentation on the database documentation page.
As discussed in Data Storage, spatial databases have specific data types to handle geographical features, and they provide specific querying ability for spatial data. Unfortunately Drupal does not natively support these data types or these querying methods, so there are a number of contributed modules to solve this problem.
NOTE
There is currently a ticket in the Drupal issue queue to add support for spatial data. Feel free to help out or just show your support by commenting on the ticket.
Methods
There are two main methods for storing spatial data in Drupal 7: one is with the Geofield module, and the other is the Location module. The rest of this chapter and Chapter 4 will illustrate the differences between the Geofield and Location modules and help you choose the correct approach for your maps.
WARNING
Please be aware that the methods outlined in this chapter are not interchangeable. They all store the spatial data in their own ways. This means that you should think carefully right at the start about what kind of spatial data you want to