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.
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | openlayers_geocoder-1066696_google_maps_country-8.patch | 1.8 KB | steinmb |
| #4 | configure_domain-1066696-3.patch | 2.78 KB | nicolash |
Comments
Comment #1
nicolash commentedChanging status to get some attention.
Comment #2
muhleder commentedThis 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.
Comment #3
nicolash commentedOk, I've made the domain configurable, but append '/maps/api/geocode/json?' in code to minimise wrong configurations.
Comment #4
nicolash commentedpatch lost in preview...
Comment #5
muhleder commentedCode 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.
Comment #6
nicolash commentedHm, 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.
Comment #7
muhleder commented--- 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
Comment #8
steinmb commentedRe-rolling this. Only done a brief test so this needs some more testing and reviewing.