Reverse geocoding in Drupal 7
When working with Drupal 6 mapping few years ago, there where limited number of mapping solutions, which mainly focused on the integration between gmap and location modules.
Today, when coming back to mapping, now in Drupal 7, I found out there are many different modules and solutions. Like in any other task when developing under Drupal, there is a need to do a research, understand what is the "de-facto" standard solution in use, and verify it answer to the specific project in hand.
I was happy to find out 3 amazing modules:
- Geofield - a field to save geolocation information. While it already includes displaying the data on google maps, its main strength is in saving the data and the interactions with other modules.
- OpenLayers - it would be a joke to compare between the gmap module I knew from Drupal 6 and this amazing module with all of its capabilities. True - it takes some time to grasp everything (and you rather read some exampes like this in order to make your life easier)
- Geocoder - getting lat/long of a given address, and vice verse, is an important feature of the current project I am working on. While the GeoNames modules is simpler and was easier to install and configure, the Geocoder is the actual "standard", and its flexibility is what makes it my choice.
Using those 3 modules as a basis, and with some trials and errors I was able to create not only what I wanted, but even more.
Still, those modules are not perfect, and I had to move to Geofield dev release due to this bug (I wasn't able to allow the user to select only one location on the map without patching to the solution mentioned).
I also wanted to automatically give the user the ability to select a location on the map, so I followed this issue and created a patch to solve it as well.
But the main task I work on is related to the long-term "Drupal startup" of mine - "Drupal of Things". While it is a tiny part of the project, there is a simple scenario needs to be available:
- A "thing" (well, you can say "a mobile app" if you like) updates its current location. All it knows is lat/long (and maybe altitude as well).
- The location should be translated (well, "reverse geocoded") into an address.
- Depending on the new address, "something" should happen.
Tons of use cases can (and will) be build ontop of this. Starting from a simple "hey, a friend of mine just got into the city..." and ending with "where the hell is my dog ?!?".
Now back to the problem - while geocoding is almost out-of-the-box, reverse geocoding was just not implemented, as can be seen here. In addition, there was no Rules integration for the Geocoder module (there is for D6 Geocode, but it is irrelevant for my needs).
24 hours later, I released a patch for the Geocoder to support reverse geocoding with the google plugin implemented, and a basic Geocoder Rules module is also available - and all my current needs exist.
I can start again to write why I love and believe in the open source community and specifically Drupal, or to try and explain why those are the reasons I think Drupal as a modular system is different and better then other open source frameworks (Ruby/Django/etc), but I want to focus on other things:
- Contributing is not only coding - writing issues, commenting on issues, and even writing something like "this is what I think should be done" - is actually helping and guiding. Even if you are not a developer - you can and should contribute. I used the wisdom of all of the comments online to make my development better and faster.
- Modules are never perfect, but don't think you should write your own module instead, or else you will jsut encounter the bugs already solved in the existing module.You encounter a bug ? A feature is missing ?Dig in and solve it !
Good night,
Shushu
Ralates to: Drupal Planet