A little while back an anonymous monk asked about perl support for Google maps API: Google maps and Perl. He was specifically asking about draggable markers. The replies generally pointed him to javascript which is of course correct. However there is a certain amount of server side work, and I had just written a private module to handle that, which I expected to use very often going forward. However I was unsure whether this amounted to something worth publishing to CPAN. However since I could see how my stuff could be used in such applications I felt pushed to publish it: Geo::Google::MapObject. I covered the original specific question http://search.cpan.org/~silasmonk/Geo-Google-MapObject-0.02/lib/Geo/Google/MapObject.pm#Taking_it_further. My test website http://testmaps.periapt.co.uk/ is also available for viewing, where you control where on earth three little alien creatures next visit.

I think my underlying approach is worth stating to see if anyone has good reasons for alternatives.

  1. The solution must degrade gracefully from a javascript enabled environment to a javascript free environment.
  2. The solution must make as few assumptions about the surrounding framework as possible.
  3. The data should be concentrated in a single place.
  4. I don't like perl code that generates javascript or CSS. That seems messy and would prevent caching of what should be static resources.

Anyway so I published the module because I find it useful and I had some evidence that others might too. Still the fact that perl forms such a small part of the solution makes me feel quite odd. It is almost as if the following conversation took place (with me as the shopkeeper).

  1. Hungry Monk Excuse me kind shopkeeper. Could you sell me some tools for making ham sandwiches?
  2. shopkeeper Hmm. Ham sandwiches. Well that's more of an agricultural thing really. I mean we do sell breadknives, butter knives and knives for cutting meat. But that forms such a tiny part of the overall process of making a ham sandwich.
  3. Hungry Monk I'll buy it. I'm really hungry.
  4. Shopkeeper Okay let’s start with the documentation. The shopkeeper places on the counter several large volumes: “Ham sandwich making, Volume 1: Ham from farm to butcher” and “Ham sandwich making: Volume 2: bread from farm to baker”, “Ham sandwich making: Volume 3: Butter from grass to dairy.” And finally a slim pamphlet: “Your first ham sandwich – putting it altogether.”

Replies are listed 'Best First'.
Re: RFC: Geo::Google::MapObject
by jdrago_999 (Hermit) on Oct 05, 2009 at 01:12 UTC

    Impressive :)

    Would it be possible to show an example in which dragging (then dropping) an alien on the map results in some kind of round-trip ajax/json thing to/from the server?

    For example: "You dropped Alien #1 at (lat)/(long)"

    Your note about ham sandwich making is dead on. After years of looking at CPAN-style documentation (SYNOPSIS right at the top) I tire of reading through page after page just searching for a quick copy-n-paste example so I can see how to use some code).

      Would it be possible to show an example in which dragging (then dropping) an alien on the map results in some kind of round-trip ajax/json thing to/from the server?

      For example: "You dropped Alien #1 at (lat)/(long)"

      Actually one does not need to go back to the server for this. The information is available in the client before it posts a request to the server. So I easily could add a bit of javascript to display something to that effect. You can also see the same information by just refreshing (ctl-R) in the table on the right.

      In terms of what I need to change the following strike me as priorities:

      1. Experimenting with or analyzing the algorithm to calculate the zoom level. Arguably the current one is not adequate, though it definitely meets the requirements I set for it. As such it might count as a bug. Still I specifically put in hooks to make it changeable without changing the code.
      2. Adding screens to show the paths that the creatures have travelled. As this would depend on adding missing features to the module this ranks highly for me.
      3. Something to dynamically translate the points to real locations as in http://gmaps-samples.googlecode.com/svn/trunk/geocoder/singlegeocode.html. It was in my original intention that when you hover over the table on the right a tooltip with a small map pops up but I got stuck.
      4. As the website if one of my experimental labs, it may be that the next thing I need to add is - Larry forbid - advertising.
      Anyway it will be my needs or feedback that will determine what (if anything) I do next with this site.

      Edit:I've made some experimental changes to zoom algorithm and put in appropriate links.