First off, I'm seriously impressed with the location set of modules. I've gone from nought to 90% finished map search directory in a few hours with Location and GMap.
The problem I am having it that the proximity doesn't work for countries in the United States
I stripped down the view to bare bones to check if it was anything else I was doing but am still having the problem. An export of the view is below
* I am using an exposed Distance Proximity filter (with options set so that the user can choose the country)
* My Zipcodes table starts empty
* When I do a search in the United Kingdom for a post code it is added to the zipcodes tables
* ..and the the view behaves perfectly as expected
** (even if I enter a street address short enough to pass DB validation it works, fantastic)
* but if I select United States form the drop down
* the view returns all results no matter what i enter in postal code
* and nothing gets entered to the zipcodes table
I think I am trying to achieve a fairly standard solution and I imagine you can visualise what I'm aiming for.
So I guess my question is: Is this a bug that needs fixing? is there some setup or settings I have missed that would enable this? Am I going about it in totally the wrong way?
Thanks! Let me know if you want any more info or data
PS I had a Google and search of these forums and found this that might be related http://drupal.org/node/1175452
Edit: I should also mention that all nodes have successfully stored lat/long
----
$view = new view;
$view->name = 'list1';
$view->description = '';
$view->tag = 'default';
$view->base_table = 'node';
$view->human_name = 'list1';
$view->core = 7;
$view->api_version = '3.0-alpha1';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
/* Display: Master */
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['title'] = 'list1';
$handler->display->display_options['access']['type'] = 'perm';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['query']['options']['query_comment'] = FALSE;
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'full';
$handler->display->display_options['pager']['options']['items_per_page'] = '10';
$handler->display->display_options['style_plugin'] = 'gmap';
$handler->display->display_options['style_options']['macro'] = '[gmap behavior=+autozoom ]';
$handler->display->display_options['style_options']['latfield'] = 'title';
$handler->display->display_options['style_options']['lonfield'] = 'title';
$handler->display->display_options['style_options']['markerfield'] = 'title';
$handler->display->display_options['style_options']['enablermt'] = 0;
$handler->display->display_options['style_options']['rmtfield'] = 'title';
$handler->display->display_options['style_options']['tooltipfield'] = 'title';
$handler->display->display_options['style_options']['bubbletextenabled'] = 1;
$handler->display->display_options['style_options']['bubbletextfield'] = 'title';
$handler->display->display_options['row_plugin'] = 'fields';
$handler->display->display_options['row_options']['hide_empty'] = 0;
$handler->display->display_options['row_options']['default_field_elements'] = 1;
/* Field: Content: Title */
$handler->display->display_options['fields']['title']['id'] = 'title';
$handler->display->display_options['fields']['title']['table'] = 'node';
$handler->display->display_options['fields']['title']['field'] = 'title';
$handler->display->display_options['fields']['title']['label'] = '';
$handler->display->display_options['fields']['title']['alter']['alter_text'] = 0;
$handler->display->display_options['fields']['title']['alter']['make_link'] = 0;
$handler->display->display_options['fields']['title']['alter']['absolute'] = 0;
$handler->display->display_options['fields']['title']['alter']['word_boundary'] = 0;
$handler->display->display_options['fields']['title']['alter']['ellipsis'] = 0;
$handler->display->display_options['fields']['title']['alter']['strip_tags'] = 0;
$handler->display->display_options['fields']['title']['alter']['trim'] = 0;
$handler->display->display_options['fields']['title']['alter']['html'] = 0;
$handler->display->display_options['fields']['title']['hide_empty'] = 0;
$handler->display->display_options['fields']['title']['empty_zero'] = 0;
$handler->display->display_options['fields']['title']['link_to_node'] = 1;
/* Sort criterion: Content: Post date */
$handler->display->display_options['sorts']['created']['id'] = 'created';
$handler->display->display_options['sorts']['created']['table'] = 'node';
$handler->display->display_options['sorts']['created']['field'] = 'created';
$handler->display->display_options['sorts']['created']['order'] = 'DESC';
/* Filter criterion: Content: Published */
$handler->display->display_options['filters']['status']['id'] = 'status';
$handler->display->display_options['filters']['status']['table'] = 'node';
$handler->display->display_options['filters']['status']['field'] = 'status';
$handler->display->display_options['filters']['status']['value'] = 1;
$handler->display->display_options['filters']['status']['group'] = 0;
$handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
/* Filter criterion: Content: Title */
$handler->display->display_options['filters']['title']['id'] = 'title';
$handler->display->display_options['filters']['title']['table'] = 'node';
$handler->display->display_options['filters']['title']['field'] = 'title';
$handler->display->display_options['filters']['title']['operator'] = 'contains';
$handler->display->display_options['filters']['title']['group'] = 0;
$handler->display->display_options['filters']['title']['exposed'] = TRUE;
$handler->display->display_options['filters']['title']['expose']['operator_id'] = 'title_op';
$handler->display->display_options['filters']['title']['expose']['label'] = 'Title';
$handler->display->display_options['filters']['title']['expose']['operator'] = 'title_op';
$handler->display->display_options['filters']['title']['expose']['identifier'] = 'title';
$handler->display->display_options['filters']['title']['expose']['required'] = 0;
$handler->display->display_options['filters']['title']['expose']['multiple'] = FALSE;
/* Filter criterion: Location: Distance / Proximity */
$handler->display->display_options['filters']['distance_1']['id'] = 'distance_1';
$handler->display->display_options['filters']['distance_1']['table'] = 'location';
$handler->display->display_options['filters']['distance_1']['field'] = 'distance';
$handler->display->display_options['filters']['distance_1']['operator'] = 'dist';
$handler->display->display_options['filters']['distance_1']['value'] = array(
'latitude' => '',
'longitude' => '',
'postal_code' => '',
'country' => '',
'php_code' => '',
'nid_arg' => '',
'nid_loc_field' => 'node',
'uid_arg' => '',
'search_distance' => '100',
'search_units' => 'mile',
);
$handler->display->display_options['filters']['distance_1']['group'] = 0;
$handler->display->display_options['filters']['distance_1']['exposed'] = TRUE;
$handler->display->display_options['filters']['distance_1']['expose']['operator_id'] = 'distance_1_op';
$handler->display->display_options['filters']['distance_1']['expose']['label'] = 'Distance / Proximity';
$handler->display->display_options['filters']['distance_1']['expose']['operator'] = 'distance_1_op';
$handler->display->display_options['filters']['distance_1']['expose']['identifier'] = 'distance_1';
$handler->display->display_options['filters']['distance_1']['expose']['remember'] = 1;
$handler->display->display_options['filters']['distance_1']['expose']['multiple'] = FALSE;
$handler->display->display_options['filters']['distance_1']['expose']['gmap_macro'] = array(
'default' => '[gmap ]',
);
$handler->display->display_options['filters']['distance_1']['expose']['user_location_choose'] = array(
'default' => FALSE,
);
$handler->display->display_options['filters']['distance_1']['origin'] = 'postal';
/* Display: Page */
$handler = $view->new_display('page', 'Page', 'page');
$handler->display->display_options['path'] = 'list';
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | only_return_country_function_output_if_result_1314292_1.patch | 563 bytes | Joe Vallender |
Comments
Comment #1
Joe Vallender commentedPossible solution
Change to location_latlon_rough() - line 260 of location.inc
to
So we don't check that simply that the function exists, but that it has results before deciding whether to add a new zipcode to the table.
Is working for me, and makes sense. What do you think?
Comment #2
Joe Vallender commentedpatch for the above. it's only a tiny tweak but I haven't actually sent anything back from my new drupal.org account or since the Git switch so it's a good excuse for me to do so :o)
Comment #3
ankur commentedThanks for the patch. I committed it to the 7.x-3.x and 7.x-4.x branches. However, I should say that, although it's not well documented, the country-specific function for the US is relying on whether you've imported the zipcodes data for that country into your database.
In the location module directory, there's a file in database/zipcodes.us.mysql that is to be imported into the database. Once this is imported, the country-specific function for retrieving an approximate lat/lon for a US postal code should return a result.
Comment #3.0
ankur commentedEdit: I should also mention that all nodes have successfully stored lat/long