Geographical Data with Drupal: Location vs Geo

Oct 25, 2010
Eric Aguayo

Companies that need to provide resources with a geographical location through their websites can improve the experience of their customers by giving additional geographical information related to the place. One of the best ways to provide users with location information about places or other resources is by displaying the location on a map. In Drupal, there are several modules that can be used to display and manage geographical data.

One of the most popular modules in the Drupal community is the Location module, which provides the ability to collect information related to addresses and can be associated not only with nodes but also with users. The module allows setting multiple locations per node or user which can be used to give the users the ability to specify their home and work addresses, for example. Furthermore, the latest version of the Location module, which is currently version 3.1, comes with several features such as Views and CCK modules integration capability, to associate phone and fax numbers to locations, geographical search features, etc. In addition, there is a contributed module named GMap that provides the ability to display maps through the Google Maps API. The GMap module contains a sub-module that integrates with the Location module to provide the capability to choose location from a map or display Locations through Google Maps when viewing a node or a user associated with one or more locations by getting the latitude and longitude values of the location. By using the Views module along with the GMap module, multiple locations can be displayed within a single map. Also, custom markers can be created and displayed on a map based on taxonomy.

There is another module in the Drupal community called Geo, which is a more generic module that not only manages single point geographical data such as specific addresses but also allows having more general types of geographical data such as lines, polygons or areas. The Geo module allows importing shapefiles which are the most used file format to store geographical data developed by ESRI which is a leader company in producing applications for GIS (Geographical Information Systems). The Geo Module takes the advantages of the database geographical extensions to process calculations and store the geographical data. Currently the Geo Module provides support for MySQL which comes with spatial extensions out of the box and Postgres which can be installed with the PostGIS extensions which are a bit more specialized than the MySQL extension in terms of accuracy and extensibility. By itself, the Geo Module does not display the input data through a map or a user-friendly interface; it needs to rely on a mapping system that is compliant with the open standards defined by the OGC (Open Geospatial Consortium). Fortunately there is an application called OpenLayers which uses a JavaScript library of the same name to display geographical data in a map. It also provides the flexibility to add different types of layers which gives the ability to use Google Maps, Yahoo Maps or other services to render additional data or images over the map. Among other features that come with the OpenLayers module is the support for behaviors and presets management and integration with Views and CCK as well.

There are several other modules that provide features to display and manage locations and other geographical data besides the ones mentioned here. However, the “Location + GMap” and “Geo + Open Layers” are the most used options depending on the case. For addresses and specific point locations, the Location module is the preferred option due to its completeness and relatively simplicity plus the GMap module eases the process of displaying locations on maps. For cases that require more complex geographical data such as polygonal areas the Location module can still be used through a patch that can be found in the Drupal community which is expected to be applied to future releases. Nevertheless, even with the patch, the Location module still does not provide the better storage solution and geographical calculation capabilities and most likely extra development has to be performed if more complex features are needed in the future. In contrast, the Geo module works with the native support of the databases for geographical data which allows managing and displaying more complex geographical data such as windmills, rivers, etc. The drawback of using the Geo module is that it is currently on alpha release and there are not many widgets to handle geographical data at the moment. However, there is ongoing development and continuous improvements to this module, so a beta release is expected soon.

Here is a screenshot of an example preset map whose base layer is retrieved from one of the NASA web services:

If you liked this blog post you might also be interested in: