This is a location.inc file for the Netherlands that can be used in replacement of the current one that will bring more support for adding the lat/lon into the location database for Google.

This incorporates the routenet maps talked about in: http://drupal.org/node/73714

It looks like Google Map API does not send back as much info for NL as it does the US and has been working for me. I am sure there are prob some fixes that need to be made with further testing.

I would also like to see the GoogleAPI not have to be country specfic as Google does not req a different api key for each country as far as I can tell. The GMap key should be in the main section or taken from Gmap mod if installed IMHO. But oh well..

This will just use the US based key if you have that installed.. otherwise it will just write it to the us pref key.

Comments

khoogheem’s picture

StatusFileSize
new14.45 KB

Ok.. I actually fixed something..

Figured out why things were not returning as much info. If you don't use a postal code it does not return as much, this seems to fix a few things. I wonder if this works the same for the US version as well...

This code will put a geocode in the location database if you use or don't use a postal code. Of course it gets a better fix on the location if you do use the postal code.. but for an application of mine where I want to show a Marker on a City such as Amsterdamn and don't care if it is right in the correct spot I don't care.. just need to show the content is from there. But if you do include the postal code it will zero in better.

here is the code section that can be fixed and is fixed in the file included.

function location_geocode_nl_google($location = array()) {
  $service_url = 'http://maps.google.com/maps/geo?output=xml&key='. variable_get('location_geocode_us_google_apikey', '') .'&q=';

  $address = location_address2singleline($location);
  
  $http_reply = drupal_http_request($service_url . urlencode($address));
  
  $status_code_match = array();
  preg_match('/<code>(.*)<\/code>/', $http_reply->data, $status_code_match);
  $status_code = $status_code_match[1];
  if ($status_code != 200) {
    return NULL;
  }
  
  $accuracy_code_match = array();
  preg_match('/Accuracy="([0-9])"/', $http_reply->data, $accuracy_code_match);
  $accuracy_code = $accuracy_code_match[1];
  //if ($accuracy_code != 8 && $accuracy_code != 7) {
  if($accuracy_code < 4){
    return NULL;
  }
bdragon’s picture

Component: Code » Data update

Changing component.

brmassa’s picture

Status: Needs review » Fixed

Kevin,

its commited on HEAD. Soon on Location 3.0.

regards,

massa

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.