Chapter 8. Conclusion

With all that you have learned about mapping with Drupal, you should now be able to create beautiful and useful maps for your website. Even using the pre-existing Drupal modules, you can build appropriate, useful, and interactive maps. Going beyond that, you can create your own modules to add imaginative and lively ways for your site’s users to interact with the maps, and you can personalize the maps with custom-built markers and interfaces.

Next Steps in Mapmaking

If you want to create even more interesting maps, with features that are not available through existing Drupal modules, you need to become familiar with JavaScript and with the JavaScript libraries that are used to create maps.

If you are using the OpenLayers module, get to know the OpenLayers JavaScript library. OpenLayers explained how to add new JavaScript Behaviors to your maps. There are many Behaviors in the OpenLayers JavaScript library that are not implemented in the OpenLayers module, but which you can activate using the method in Chapter 5. For example, it would be possible to add a shape on your map that rotates, with the speed of rotation representing the intensity of a tornado. The OpenLayers examples page contains an example showing the geometry.rotate method. Then again, you could create labels on your map that change depending on the zoom level. Find an example that is close to what you want to do, then view its source code to work out how it achieves its effect. In conjunction with that, study the class documentation. For the rotating tornado, you would read the documentation for the OpenLayers.Geometry.LineString class. There is one book in English on OpenLayers, which is listed in Appendix A.

As mentioned in Mapping with the OpenLayers Module, the OpenLayers JavaScript library is an open source project, so if you are running into limitations on what is possible and are inspired to add new features, you can get involved and contribute code. The OpenLayers email lists are the best way to stay current with new developments.

If you are using the GMap module, you will want to understand the Google Maps API. That API has several subsidiary APIs within it. The Web Services API is useful if you want to geocode an address, generate driving directions, or get the elevation of a point. The Maps Image APIs allow you to create an image of a map or Street View and display that on your website without using any JavaScript. Most relevant to the Drupal GMap module, however, is Version 2 of the Google Maps JavaScript API. This is the code that allows you to embed maps on your website using JavaScript, and this is how you can change the way that maps work and what is displayed on them. For example, if you wanted to change the zoom controls of your map from images to text, the instructions and example are in the documentation for map controls. If you wanted to make a map of the world that plays the national anthem of each country you click on, the JavaScript API Reference is where you would look for the code to do this. In addition to that documentation, there is a code playground, where all of the examples are listed and you can view the source code, change that code on the page, and then see how your changes come out on the map. Several books have been written on Google Maps, some of which are listed in Appendix A.

The Future of Mapping with Drupal

There are exciting developments all the time in open source mapmaking, and there is work being done to integrate these into Drupal. The new ideas at the moment are in two main fields: displaying maps and data storage.

There are several new JavaScript libraries for displaying maps, including Leaflet, which was introduced in Library size. The Leaflet project is to make maps display well on both mobile and desktop browsers, and to take advantage of HTML5 to be fast and have a small file size. The code is object-oriented, an architecture that is used to make the code modular and extensible. If you are interested in making open source maps that are fast and work well on mobile browsers, this is a project to work with.

The options for spatial data storage are improving, both in Drupal and in other open source projects. Some of the challenges and solutions were discussed in Databases. A couple of Drupal modules, PostGIS and GeoServer, are worth watching if you are working with especially vast databases and are attracted by the idea of integrating spatial databases into Drupal.

Another interesting development is integrating Apache Solr search for spatial data into Drupal. Solr is a fast open source search platform written in the Java programming language. It is much faster than searching using database queries, which is how search is done by default in Drupal. As well as geospatial search, Solr allows search results to be sortable and handles faceted search (navigating search results by multiple filters, such as showing only restaurants that serve brunch and are wheelchair-accessible). The Apache Solr module integrates Solr with Drupal, but it does require you to run Java on your web server in addition to PHP. The OpenLayers Apache Solr module then integrates many of the modules mentioned earlier in this book (Geofield, Geocoder, and OpenLayers) with LocalSolr. The OpenLayers Apache Solr module provides a map, layer, layer type, and block for OpenLayers.

There is an initiative within the Mapping and Location Group in Drupal to pull together all the disparate modules into a Geo Content Management System. The Geo module was an attempt to do this, and it has been widely and intensely discussed at DrupalCons (the twice-yearly Drupal conferences). The subject was raised in 2007 in Bdragon’s vision for doing locations “right” in Drupal and more recently in a post started by one of this book’s authors, summarizing the Drupal geo stack. The goal of this broad initiative is to separate out all of the different parts of mapping in Drupal (data storage, data input, searching spatial data, geocoding, and displaying maps) so that developers can choose which module they want to use for each part.

There are many ways to get involved in making maps in Drupal, so jump into whatever interests you most. Drupal developers use IRC (Internet Relay Chat) both to get help and to discuss module development. There is an introduction to IRC on the Community and Support page. Mapping is discussed in the #drupal-geo channel. The other way to keep up with new developments and initiatives is to join the Location and Mapping Group on http://groups.drupal.org/.

Over the next few years, the power of Drupal to make lively, useful interactive maps will only increase, the modules becoming more straightforward to use even as the options available become more flexible and creative. One thing’s for sure, there is no longer any excuse for offering information about places and locations without presenting that information the proper way, on a map. And there’s no longer any excuse for that map to be unhelpful, unresponsive, or boringly just like all the other maps. For inspiration we’ll leave you with one of the most beautiful and engaging maps to be made with Drupal for Energy.gov, shown in Figure 8-1. Happy mapping!

Energy.gov contains many beautiful maps. This map shows how much energy, waste and money has been saved by energy audits. It was built by Treehouse Agency using Drupal 7, MapBox, Geofield, OpenLayers, Apache Solr, OpenLayers Apache Solr, and Geocoder.
Figure 8-1. Energy.gov contains many beautiful maps. This map shows how much energy, waste and money has been saved by energy audits. It was built by Treehouse Agency using Drupal 7, MapBox, Geofield, OpenLayers, Apache Solr, OpenLayers Apache Solr, and Geocoder.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset