I am trying to set up a Gmap View using the Search API. The view works in a table and any other format, but I would also like to have a map view to display the node locations. This is the error I get:

Fatal error: Call to undefined method SearchApiViewsQuery::ensure_table() in .../sites/all/modules/gmap/gmap_plugin_style_gmap.inc on line 56

I can set up non search api gmap views.

I posted in Search API initially and was directed here.

Comments

dmiric’s picture

I get HTTP Error 500 when i try to edit a view that is made with gmap also an issue with Search Api, but I cant make it work with views either Markers are not placed correctly cant use center or node argument.

stopshinal’s picture

I'm having the same issue, NickUK, were you able to resolve things? Here is my export:

$view = new view;
$view->name = 'geo3';
$view->description = '';
$view->tag = 'default';
$view->base_table = 'search_api_index_default_node_index';
$view->human_name = 'geo3';
$view->core = 7;
$view->api_version = '3.0';
$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'] = 'geo3';
$handler->display->display_options['access']['type'] = 'none';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'none';
$handler->display->display_options['style_plugin'] = 'gmap';
$handler->display->display_options['style_options']['datasource'] = 'fields';
$handler->display->display_options['style_options']['markers'] = 'nodetype';
$handler->display->display_options['style_options']['latfield'] = 'field_location_latitude';
$handler->display->display_options['style_options']['lonfield'] = 'field_location_longitude';
$handler->display->display_options['style_options']['markerfield'] = 'nid';
$handler->display->display_options['style_options']['enablermt'] = 0;
$handler->display->display_options['style_options']['rmtfield'] = 'nid';
$handler->display->display_options['style_options']['tooltipfield'] = 'nid';
$handler->display->display_options['style_options']['bubbletextfield'] = 'nid';
$handler->display->display_options['row_plugin'] = 'fields';
/* Field: Node: Node ID */
$handler->display->display_options['fields']['nid']['id'] = 'nid';
$handler->display->display_options['fields']['nid']['table'] = 'search_api_index_default_node_index';
$handler->display->display_options['fields']['nid']['field'] = 'nid';
/* Field: Node: Title */
$handler->display->display_options['fields']['title']['id'] = 'title';
$handler->display->display_options['fields']['title']['table'] = 'search_api_index_default_node_index';
$handler->display->display_options['fields']['title']['field'] = 'title';
$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']['external'] = 0;
$handler->display->display_options['fields']['title']['alter']['replace_spaces'] = 0;
$handler->display->display_options['fields']['title']['alter']['trim_whitespace'] = 0;
$handler->display->display_options['fields']['title']['alter']['nl2br'] = 0;
$handler->display->display_options['fields']['title']['alter']['word_boundary'] = 1;
$handler->display->display_options['fields']['title']['alter']['ellipsis'] = 1;
$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']['element_label_colon'] = 1;
$handler->display->display_options['fields']['title']['element_default_classes'] = 1;
$handler->display->display_options['fields']['title']['hide_empty'] = 0;
$handler->display->display_options['fields']['title']['empty_zero'] = 0;
$handler->display->display_options['fields']['title']['hide_alter_empty'] = 1;
$handler->display->display_options['fields']['title']['link_to_entity'] = 0;
/* Field: Node: Type */
$handler->display->display_options['fields']['field_type']['id'] = 'field_type';
$handler->display->display_options['fields']['field_type']['table'] = 'search_api_index_default_node_index';
$handler->display->display_options['fields']['field_type']['field'] = 'field_type';
$handler->display->display_options['fields']['field_type']['alter']['alter_text'] = 0;
$handler->display->display_options['fields']['field_type']['alter']['make_link'] = 0;
$handler->display->display_options['fields']['field_type']['alter']['absolute'] = 0;
$handler->display->display_options['fields']['field_type']['alter']['external'] = 0;
$handler->display->display_options['fields']['field_type']['alter']['replace_spaces'] = 0;
$handler->display->display_options['fields']['field_type']['alter']['trim_whitespace'] = 0;
$handler->display->display_options['fields']['field_type']['alter']['nl2br'] = 0;
$handler->display->display_options['fields']['field_type']['alter']['word_boundary'] = 1;
$handler->display->display_options['fields']['field_type']['alter']['ellipsis'] = 1;
$handler->display->display_options['fields']['field_type']['alter']['strip_tags'] = 0;
$handler->display->display_options['fields']['field_type']['alter']['trim'] = 0;
$handler->display->display_options['fields']['field_type']['alter']['html'] = 0;
$handler->display->display_options['fields']['field_type']['element_label_colon'] = 1;
$handler->display->display_options['fields']['field_type']['element_default_classes'] = 1;
$handler->display->display_options['fields']['field_type']['hide_empty'] = 0;
$handler->display->display_options['fields']['field_type']['empty_zero'] = 0;
$handler->display->display_options['fields']['field_type']['hide_alter_empty'] = 1;
$handler->display->display_options['fields']['field_type']['field_api_classes'] = 0;
/* Field: Node: Location » Latitude */
$handler->display->display_options['fields']['field_location_latitude']['id'] = 'field_location_latitude';
$handler->display->display_options['fields']['field_location_latitude']['table'] = 'search_api_index_default_node_index';
$handler->display->display_options['fields']['field_location_latitude']['field'] = 'field_location_latitude';
$handler->display->display_options['fields']['field_location_latitude']['alter']['alter_text'] = 0;
$handler->display->display_options['fields']['field_location_latitude']['alter']['make_link'] = 0;
$handler->display->display_options['fields']['field_location_latitude']['alter']['absolute'] = 0;
$handler->display->display_options['fields']['field_location_latitude']['alter']['external'] = 0;
$handler->display->display_options['fields']['field_location_latitude']['alter']['replace_spaces'] = 0;
$handler->display->display_options['fields']['field_location_latitude']['alter']['trim_whitespace'] = 0;
$handler->display->display_options['fields']['field_location_latitude']['alter']['nl2br'] = 0;
$handler->display->display_options['fields']['field_location_latitude']['alter']['word_boundary'] = 1;
$handler->display->display_options['fields']['field_location_latitude']['alter']['ellipsis'] = 1;
$handler->display->display_options['fields']['field_location_latitude']['alter']['strip_tags'] = 0;
$handler->display->display_options['fields']['field_location_latitude']['alter']['trim'] = 0;
$handler->display->display_options['fields']['field_location_latitude']['alter']['html'] = 0;
$handler->display->display_options['fields']['field_location_latitude']['element_label_colon'] = 1;
$handler->display->display_options['fields']['field_location_latitude']['element_default_classes'] = 1;
$handler->display->display_options['fields']['field_location_latitude']['hide_empty'] = 0;
$handler->display->display_options['fields']['field_location_latitude']['empty_zero'] = 0;
$handler->display->display_options['fields']['field_location_latitude']['hide_alter_empty'] = 1;
$handler->display->display_options['fields']['field_location_latitude']['set_precision'] = 0;
$handler->display->display_options['fields']['field_location_latitude']['precision'] = '0';
$handler->display->display_options['fields']['field_location_latitude']['format_plural'] = 0;
$handler->display->display_options['fields']['field_location_latitude']['link_to_entity'] = 0;
/* Field: Node: Location » Longitude */
$handler->display->display_options['fields']['field_location_longitude']['id'] = 'field_location_longitude';
$handler->display->display_options['fields']['field_location_longitude']['table'] = 'search_api_index_default_node_index';
$handler->display->display_options['fields']['field_location_longitude']['field'] = 'field_location_longitude';
$handler->display->display_options['fields']['field_location_longitude']['alter']['alter_text'] = 0;
$handler->display->display_options['fields']['field_location_longitude']['alter']['make_link'] = 0;
$handler->display->display_options['fields']['field_location_longitude']['alter']['absolute'] = 0;
$handler->display->display_options['fields']['field_location_longitude']['alter']['external'] = 0;
$handler->display->display_options['fields']['field_location_longitude']['alter']['replace_spaces'] = 0;
$handler->display->display_options['fields']['field_location_longitude']['alter']['trim_whitespace'] = 0;
$handler->display->display_options['fields']['field_location_longitude']['alter']['nl2br'] = 0;
$handler->display->display_options['fields']['field_location_longitude']['alter']['word_boundary'] = 1;
$handler->display->display_options['fields']['field_location_longitude']['alter']['ellipsis'] = 1;
$handler->display->display_options['fields']['field_location_longitude']['alter']['strip_tags'] = 0;
$handler->display->display_options['fields']['field_location_longitude']['alter']['trim'] = 0;
$handler->display->display_options['fields']['field_location_longitude']['alter']['html'] = 0;
$handler->display->display_options['fields']['field_location_longitude']['element_label_colon'] = 1;
$handler->display->display_options['fields']['field_location_longitude']['element_default_classes'] = 1;
$handler->display->display_options['fields']['field_location_longitude']['hide_empty'] = 0;
$handler->display->display_options['fields']['field_location_longitude']['empty_zero'] = 0;
$handler->display->display_options['fields']['field_location_longitude']['hide_alter_empty'] = 1;
$handler->display->display_options['fields']['field_location_longitude']['set_precision'] = 0;
$handler->display->display_options['fields']['field_location_longitude']['precision'] = '0';
$handler->display->display_options['fields']['field_location_longitude']['format_plural'] = 0;
$handler->display->display_options['fields']['field_location_longitude']['link_to_entity'] = 0;

/* Display: Page */
$handler = $view->new_display('page', 'Page', 'page');
$handler->display->display_options['path'] = 'geo3';

domidc’s picture

@nickuk where can I find the original issue?

Fixdit’s picture

Has this been solved by anyone yet?
Thanks in advance,

Ash and the Fixdit team.

smashwini’s picture

Priority: Normal » Critical

I am also facing same problem while setting up Gmap with search API. I am getting this fatal error : Call to undefined method SearchApiViewsQuery::ensure_table(). Has anyone able to solve this ?

podarok’s picture

Project: GMap Module » Search API
Component: Code » Miscellaneous
Priority: Critical » Normal

all bug reports has to be checked against latest dev and after that - backported to previous releases
Possibly this is Search API bug, lets connect it to its issue queue for testing

tuwebo’s picture

Hi all,
I come across this issue and I found that it is possible to show markers using the Extended GMap plugin style instead of GMap.
I follow these steps:

  1. Added Indexed Node: Location » Latitude (Location » Latitude) field to the view
  2. Added Indexed Node: Location » Longitude (Location » Longitude) field to the view
  3. Set the Format view (plugin) to Extended GMap
  4. In the plugin style options I have set Location » Latitude to Marker latitude and Location » Longitude to Marker longitude
  5. Added any other desirable fields to the view

This way I can see my nodes rendered in a Gmap style, but I am totally newbie to the hole search_api so... maybe there is a better way.

Hope this helps, because all search_api rocks! and it looks like drunken monkey among many others are putting so much effort in getting this to work right now!

drunken monkey’s picture

Project: Search API » GMap Module
Component: Miscellaneous » Code

The problem here is that GMap assumes that Views' default query plugin is used, which contains the ensure_table() method in question, while the Search API query plugin doesn't (since it has no concept of tables).
The Search API module can't really do anything about that. Maybe making the call(s) in question (all calls of methods that are only present in the default query plugin, not in the common base) conditional with a method_exists() would already be sufficient to get things working. Otherwise, this would probably require deeper, more complex changes, maybe even hardcoding some special cases for the Search API, which would probably be out of the question.
Still, the easy path might be worth a try, if someone wants to give it a shot.

mikemadison’s picture

I'm seeing this same issue in Extended GMap now too. I think that Extended changed a bit to use the same ensure_table() methodology.

mikemadison’s picture

So far, GeoField's map is the only one I'm seeing that will function with SearchAPI.

jcam88’s picture

Issue summary: View changes

#7 describes the process and should be followed to display a gmap of nodes with search api in drupal 7.

1. Use location module or 2 cck fields to store decimal coordinates "latitude" "longitude".
2. Index these fields in search api settings (type: decimal).
3. Create view and add the indexed fields to the view fields area (make sure decimal point is "." to set thousand marker to "none").
4. Set view format to "extended gmap".
5. Set extended gmap "data source" setting to "choose latitude and longitude fields".
6. Assign the fields "purpose" in the extended gmap settings table.

You should now have a view that displays search api results in a map. You can create this view as an attachment and attach to another "list of results" view to create a "yelp" like map. Markers change as you page through.

sagesolutions’s picture

#11 Worked for me!

Thanks jcam88

hwasem’s picture

#11 worked for me! I am using version 7.x-2.10 and applied patch #2445429: Bubbles missing from gmap view, and then got it working.

I wasn't able to get the Marker Handling set to "By Content Type (for Node views)" in the view's Extended gMap Page Style settings. It was giving me errors. I was able to find a way around that using this tip #2297101: How to add different color markers in a single view.

Thank you!

beautifulmind’s picture

@jcam88, #11 worked very good.