Currently the geocoder URL is set to the US via the GOOGLE_GEOCODER_URL constant. It would make it easier to tailor the results by having the geocoder URL configurable to other available maps.google.[country] domains.

According to this, the geocoder URL responds just like the country specific maps page:

The Maps geocoder is programmed to bias its results depending on from which domain it receives requests. For example, entering "syracuse" in the search box on maps.google.com will geocode the city of "Syracuse, NY", while entering the same query on maps.google.it (Italy's domain) will find the city of "Siracusa" in Sicily.

I've confirmed that by changing GOOGLE_GEOCODER_URL to maps.google.com.au and received more relevant results for Australia. I started rolling a patch that would make this configurable in the widget settings, but I think it would make more sense as a global setting. It would also be the easiest to implement...something like

define('GOOGLE_GEOCODER_URL', variable_get('openlayers_geocoder_url', 'http://maps.google.com') .'/maps/api/geocode/json?');

Then sites can just set their preference in settings.php.

For reference, here's a list of top level domains for Google Maps...I don't know whether it's accurate or not.

Comments

nicolash’s picture

Status: Active » Needs review

Changing status to get some attention.

muhleder’s picture

Status: Needs review » Needs work

This looks like a good idea. I've been working with this and encountered a similar problem.

A solution would involve a settings page where a user could set the openlayers_geocoder_url variable, and then replacing GOOGLE_GEOCODER_URL with variable_get('openlayers_geocoder_url', 'http://maps.google.com/maps/api/geocode/json?');

Don't think it's a good idea to have definitions dynamically defined as above.

Setting to needs work till an actual patch exists :) Would write it myself but quite busy and prob won't need this personally.

nicolash’s picture

Component: User interface » Code
Status: Needs work » Needs review
StatusFileSize
new2.78 KB

Ok, I've made the domain configurable, but append '/maps/api/geocode/json?' in code to minimise wrong configurations.

nicolash’s picture

StatusFileSize
new2.78 KB

patch lost in preview...

muhleder’s picture

Status: Needs review » Reviewed & tested by the community

Code looks good and functionality works here.

Btw, had to use

patch -p0 < configure_domain-1066696-3.patch

to apply the patch (would normally use `drush patch http://drupal.org/files/issues/configure_domain-1066696-3_0.patch`)

Not sure if thats a problem with the patch or drush patch tools, but a minor issue.

Marking as RTBC for attention of the maintainer.

nicolash’s picture

Hm, weird....I had a few problems recently with another patch and the drupal testbot...wouldn't mind getting to the bottom of this.

Basically I just did a straight git clone via command line on OSX, then branch and commit via SmartGit and finally get the patch done with "git diff origin/[version] > my.patch"

I'll look into this in more detail anyway, but if you have any pointers they'd be much appreciated.

muhleder’s picture

--- a/openlayers_geocoder.module
+++ b/openlayers_geocoder.module

if this was

--- openlayers_geocoder.module
+++ openlayers_geocoder.module

then it would have worked for me using drush patch tools.

Not sure what the recommended way to produce a patch is now we're on git, would be nice to be able to generate a patch from a git diff, especially if you're running a few patches on the same module.

I've been using drush, diff and hacked myself, but this only works if you're just making one change to a module.

# Download hacked and diff modules.
drush dl hacked diff
# Enable them
drush en hacked diff -y
# Generate a patch file for mymodule
drush hacked-diff mymodule > file.patch

steinmb’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new1.8 KB

Re-rolling this. Only done a brief test so this needs some more testing and reviewing.