Hi,
This issue has grown from this thread (which I closed because it evolved) http://drupal.org/node/915972
I have found in a lot of countries (except the US) the results of geocoding (using street address, region, country) are often inaccurate, anything from streets, to several miles. However, if the location has a known name, including that name in the "street address" field can vastly improve results thanks to google's all seeing eye!
I am wanting to include the Location Name as part of the geocoding lookup, but I have discovered that the Location module does not include the Location Name string into the geocoding request sent to google.
Does anyone have any suggestions for how I could get the Location Name prefixed onto all geocoding requests?
Thanks,
Jason
(Location Name: vastly improving geocoding results since 2010!)
PS: for those who like to work through examples, we'll use the Tour Eiffel (Eiffel Tower) in France:
Using the fields "street" + "region" + "country" only (Quai Branly, Paris - Ile-de-France, France) we are close to the Tour Eiffel, but not completely accurate.
But using the above fields with the place name prefixed as part of the street string (Tour Eiffel, Quai Branly, Paris - Ile-de-France, France) we get a 100% accurate result.
| Comment | File | Size | Author |
|---|---|---|---|
| #13 | location_name_google_request-916120-13.patch | 9.48 KB | egfrith |
| #10 | location_name_google_request-916120-10.patch | 9.48 KB | egfrith |
Comments
Comment #1
entilza72 commentedComment #2
entilza72 commentedSorry for the bump (it's been almost 4 days).
I'm happy to discuss changing elements of the code with someone who has some experience in Location code.
Basically: I want to include Location Name in the Location Street string sent for Geocoding to vastly improve the results when using the google service. Obviously there's no way to do it from within Drupal, but I am looking for suggestions from knowledgable folk on the coding side.
Thanks,
Jason.
Comment #3
hutch commentedA good starting point would be the file location.inc, function location_latlon_exact() and work upstream from there to figure out how to get what you want into the search string.
Comment #4
entilza72 commentedThaks for the starting tips Hutch. It's looking quite daunting at the moment, but I am sure once I start looking into it, it won't be that bad. I'll post up anything I figure out.
Cheers,
Jason
Comment #5
linl commentedHi,
I found a similar problem with UK postcodes not being accurate enough to pinpoint a particular building. I think I've found where to fix it for the "See map:" link, but not (yet!) for the "Location map" block. In fact your posts in this issue #502780: incomplete 'see map' link to google maps helped to point me in the right direction - thanks!
Taking the UK as an example, in sites/all/modules/location/supported/location.uk.inc is the function:
If you add "name" and "additional" fields into the array:
these will be passed into the query string for the google map link and it should then put the marker on the actual building.
Also, some of the location_map_link_country-code_google() functions in the inc files (e.g. the US one) include location coordinates and these will also lead to inaccurate markers. There's more detail about this here: #923582: Option to not include coordinates when generating google map links.
Hope that helps. I've tried a couple of locations and it seems to work OK.
Comment #6
entilza72 commentedHi LinL,
Thanks for your response!
I think a lot of people's Location woes come from the large number of location.*.inc files that are incomplete. Very few have full code as seen in "us" or "au" files.
Your suggestion to add 'name' (I'm assuming that's the variable name) to the $location[] array is perfectly sound. I haven't clearly stated it, but part of my "problem" is the need to deliver maps world wide. This method would require changing a large number of .inc files (over 100?), making my Location module very different to anything that may get updated in the future.
I'm trying to come at the problem from "higher up" the process chain in order to change 1 file instead of 100+, but I have been unable to come up with a way to do so.
I think your suggestion is going to be the only valid way. Definately a job for a tool that can "find and replace" across an entrie directory! ;-)
Thanks again.
Jason.
Comment #7
linl commentedHi Jason,
Yes, I know what you mean! I soon gave up on the idea of going through all the .inc files adding the necessary functions.
What I have done is written a patch to location.inc that will default to a Google "See map" link if the supported/*.inc files don't have what's needed. I've submitted it to this issue: #403634: Provide default map links (google) for all countries (only because it had a more relevant title). I also included the "name" and "additional" fields in the default map link code.
Comment #8
iantresman commentedComment #5 solved it for me. It would be nice to see this included in the release.
Something like Notepad++ would allow a developer to quickly go through all the .inc files, and make the changes quickly.
Comment #9
glynster commentedWorks like a charm and now renders actually as would when you use Google Maps to search for a location. So much better indeed. I just applied this to Drupal 7.
Comment #10
egfrith commentedI've made a patch that puts this behaviour into location_map_link_google() in location.inc and all instances of location_map_link__google() in the .inc files in the supported directory. I think the patch is fairly straightforward. However, the only country I've tested is gb.
Comment #11
egfrith commentedComment #13
egfrith commentedComment #17
egfrith commentedHmm.... I can't work out why this test is failing. It doesn't look as though it's to do with the patch, as testUSA() is failing at line 36, where it's trying to set the configuration.
Comment #18
legolasboClosing support tickets that have been inactive for over a year to clean up the issue queue. Please reopen if this is still an issue.
Comment #19
System Lord commentedThis patch worked for me. However, only works for (potential) new users. Doesn't work for existing users that have gone back to fill in Location name (note: I had this field disabled before this patch). Editing existing Location name also does not update map string. Not even "Re geocode" works. By the way, "Re geocode" is NOT a function average folks understand. I always have to hide it with css. There should be a checkbox under cron button for admin to select as needed, and have every [FULL - including Location name] location re-geocoded. Or include a function after edit > save to do it automatically.
Comment #20
System Lord commentedStrange. It's now not working.
FYI...Google maps does not need coordinates to successfully render a map. You could have just a zip code and a map will render. Is there a reason for inlcuding lat/lon in map string? I understand having it for geocoding and thereby being able to use Views proximity search and what not, but the google map string does not need it.
Comment #21
System Lord commentedFrom a fit of anger, I removed all of the "Google link" lines from location.us.inc and it works perfectly now. Google map links now render without lon/lat. location.inc seems to be handling map links as a result, which doesn't include "if (location_has_coordinates($location)".
I know this issue is about 'name' being added to map string, but from my experience, adding 'name' made no change to the way the map is rendered because it still put lat/lon in front of the string which causes Google to focus rendering on that.
Since this code is applicable to the Google link only, removing it doesn't affect geocoding addresses. At least so far as I can tell.
REMOVED: