Would you (in principle) accept a patch to add support for Google Static Maps, even though the MapStraction javascript library doesn't support it?

If so, would a javascript-less method or a javascript-required method be prefered?

I am working on a javascript-less patch and am almost ready to contribute it. Please contact me in IRC ('Bevan' in #Drupal) to discuss.

Comments

levelos’s picture

In principal, sure that could be a nice feature to have available. Happy to review the patch if you want to submit it.

Bevan’s picture

The attached patch adds support for Google Static Maps API.

The implementation/patch;

  • works with 0, 1 or more markers
  • adds labels to markers 1 through 9. Markers 10 and up are labelled with a dot
  • works without javascript
  • does not depend on the mapstraction javascript library
  • does not require nor use the google maps API key
  • includes #829916: Missing index errors and two NULL options
  • has been tested with the attached view – node_map.view.php
  • has been tested in Firefox 3.6 for Mac and Chrome for Mac
  • has been tested with Google Maps (not static), but not with other providers
  • removes the closing php tag ("?>") from the end of mapstraction.module, which can introduce "headers already sent" errors under certain versions/configurations of PHP, and is not Drupal convention/standard.

The patch introduces some changes to the module's internal functions and API;

  • The has_key, src and render options for providers become optional.
  • There are 2 new options for providers; content and validate settings
  • validate settings callback allows a provider to validate submissions of the Views' style options form. The validator for the new provider, "googlestatic", checks that width and height are positive integers in pixels, and saves the integers for use at render-time. It calls form_set_error if an invalid width/height are used. This is a screenshot.
  • content callback for a provider is like the render callback, but takes an additional parameter $rows, which has the raw data to be rendered. The return value of the content callback populates $content in the mapstraction-map theme hook.
  • mapstraction-map.tpl.php supports a $content variable that contains content for the <div>. $content is populated by the return value of the content callback for each provider.
  • All providers except googlestatic use the basic content callback mapstraction_basic_content(), thus setting $content in the <div> to "Javascript must be enabled to view the map.". This text should be replaced on page load by the provider's initializer javascript. If any provider does not work with this, it's content callback setting can be removed. That provider would then use an empty $content variable.
  • mxn javascript files and Drupal.settings.mapstraction settings are only added to the page if the mapstraction javascript library has a file named according to the provider ID.
Bevan’s picture

StatusFileSize
new16.37 KB

Drupal.org lost the patch on save. Trying again...

Bevan’s picture

Status: Active » Needs review
geerlingguy’s picture

This would be a nice accessibility/mobile device feature. See 24 Ways' article on Static Maps. Subscribe, and I will look into reviewing at some point.