Closed (fixed)
Project:
GMap Module
Version:
6.x-1.0-rc2
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
28 Feb 2007 at 20:31 UTC
Updated:
6 Sep 2009 at 14:37 UTC
The attached patch adds a series of new views style plugins, where each plugin is a gmap and another of the existing views plugins.
For example, you can now have a view that has a gmap above a table view or teaser list. The gmap and the table are both controlled from the same exposed filter form. This is a common use case that I've seen implemented in numerous theme systems. Now it can be done through a point and click interface.
I may extract this functionality for arbitrarily connecting any number of views style plugins with a single form, but i needed for it gmap, so I'm submitting a patch for that first.
Enjoy!
-Mark
| Comment | File | Size | Author |
|---|---|---|---|
| gmap_views.combineplugins.patch | 2.17 KB | mfredrickson |
Comments
Comment #1
nvoyageur commentedExcellent! I was wondering how I was going to get a gmap showing above a table rather than creating a block and having it show below a table view.
One Problem. When I use "Gmap + Table" the table headings disappear. I thought maybe they were just under the Gmap, but I disabled javascript and they were still not there.
Small bug. Table Headings (labels) don't show up with Gmap + Table.
Is this patch going to be integrated into the Gmap module? I vote yes.
Comment #2
EvanDonovan commentedThe functionality provided by this patch looks great. Unfortunately, when I tried this patch, it didn't load any of the other filters. This was when I tried patching against v. 1.1.2 & against 1.1.2.21.
I'm currently stepping through the code of the hook_views_views_style_plugins() implementation using the Execute PHP block provided by the devel module to see why the code won't be executing properly. I'll let you know if I find out anything more specific.
Any word back from bdragon on committing a version of this patch to the module, btw? I'd love to render my theme override functions in http://drupal.org/node/267708 obsolete :)
Comment #3
EvanDonovan commentedTurns out my issue was with a particular Views plugin that was returning a bad array & so causing the array_merge to fail. I changed the line that tests if the module is Gmap Views to
.
I have combined your gmap_plus theming function & plugin code with the code from v.1.1.2.21 and it's working for me now.
Comment #4
EvanDonovan commentedIn order to use different markers on my GMap + [arbitrary_view] views, I had to change the condition in gmap_views_query_alter to the following:
if ($view->page && substr($view->page_type,0,4) == 'gmap' || $view->block && substr($view->block_type,0,4) == 'gmap').See http://drupal.org/node/267553 for the rationale behind the ||. The substr is to test whether the view's type begins with gmap.
Comment #5
EvanDonovan commentedI am also encountering the issue in #1 - table headings are not showing up. I'll look into that further.
I'm surprised that no one else seems interested in this patch. I would think that this would be fairly basic functionality for a mapping solution.
Comment #6
becw commentedYou can do something similar by using Panels to put two view on the same page; the views can use the same set of arguments, too.
Comment #7
altparty commented@ EvanDonovan: Excellent work! I agree with #5.
Comment #8
jcamfield commentedWith panels will the filter also "manage" both panels?
Comment #9
jcamfield commentedI'm pursuing this with Panels but am having trouble with the sorting of my two views. My Table view of nodes sorts fine, and the arguments are "in" my Gmap view, but gmap views doesn't seem to "accept" sorting? The gmap pane is sorted differently from the table pane (even at the outset) and they don't sync: http://beta.servicewire.org/gysd/map/2008/full/us/tx?sort=asc&order=City
Am I going about this the wrong way? (does sorting even make sense to gmap views?)
Comment #10
pprt commentedVery interested in this patch, however I'm getting an error when applying it.
Using Cygwin, tried to apply patch on v5.x-1.x-dev and got "Hunk #3 FAILED at 99."
Anyone encounter this issue? Is it possible to post a patched version of GMap?
Comment #11
summit commentedHi,Very much interested in a D6 version
Thanks a lot in advance for considering!
Greetings,
Martijn
Comment #12
socialnicheguru commentedsubscribing
Comment #13
asak commentedsubscribing.
Comment #14
kkrgopalan commentedsubscribing
Comment #15
kasiawaka commentedThis seems to be a solutions I've been looking for but it's not working for me. I've applied this patch against gmap_views.module from Gmap 5.x-1.x-dev (gmap_views.module,v 1.1.2.28) and also tried with Gmap 5.x-1.0 (gmap_views.module,v 1.1.2.27). After applying this patch, I tried to create a new view - I understand that I should see a new view type(s) under, for example, Page View Type? Nothing changes there.
Any help, tips or pointers would be greatly appreciated.
Kasia
Comment #16
socialnicheguru commentedthis hasn't worked for me either.
Comment #17
kasiawaka commentedIt works!
I applied the patch yesterday and it wasn't working but today it is - I guess it was an issue with caching ect.
Mark, thank you for the patch!
Here is step by step what I did, maybe it will help someone.
1. Applied the patch against Gmap 5.x.-1.x-dev from 2009-Jan-13. To be exact, the patch was applied against gmap_views.module v.1.1.2.28. I applied the patch manually (just replaced and added the code, since there are only several lines).
2. Wait a day ... just kidding. Clear cache?
3. Go to Views -> Add new (or modify your existing one) and change the View Type to one of the new options:
- Gmap + Full Nodes
- Gmap + List View
- Gmap + Table View
- Gmap + Teaser List
I wanted to have a Google map and the table in the same view so I:
- created a new View
- checkmarked Page -> Provide Page View
- View Type = Gmap + Table View
- under Fields I added all fields I want to see on the table part of the view (like node name, address, phone # ect.). IMPORTANT: For the Gmap to work, I had to include Location: Latitude and Location: Longitude fields. They will show up on the table view, so if you want to hide them, use CSS to do it:
Add to you css stylesheet (under themes/your_default_stylesheet)
Of course, replace your_view_name with the actual view name. If you want those 2 fields to be hidden from all views, skip the ".view-your_view_name" altogether.
- under Filters I added: Location: Proximity, Location: Country and Taxonomy terms (my search will search all nodes that have location within chosen proximity and that belong to the chosen Taxonomy term - you can skip that part or setup the way you want it. It doesn't influence how the new Gmap + Table View works
- I exposed all those filters so users can manipulate search query by adding their zipcode, proximity (5-250miles), country and category (taxonomy term).
As mentioned in the previous posts, there are some small issues (not preventing to use it, just small twicks):
1. Gmap + Table View removes table headings from display (if I will find a solution, will post here)
2. Markers on the map get replaced with generic Drupal markers (in case if you had a custom markers assigned before). Solution already mentioned in EvanDonovan post on this page but I will repeat it here again:
In gmap_views.module, in function
replace line
with
Comment #18
socialnicheguru commentedis this available for D6?
Comment #19
EvanDonovan commentedThis is not yet coded for D6, since Views 2 has a different API. But, as I am in the process of upgrading my organization's site to Drupal 6, I will see if it can be ported.
Comment #20
greenlite commentedAwesome! Thank you for the detailed instructions kasiawaka!!
Comment #21
EvanDonovan commentedDue to improvements in Views 2, this code is no longer necessary in the 6.x version of Gmap. To create a GMap + Table view (or any combination of two different views styles), follow the steps below:
1) Create a GMap view, then create a Page display for it.
2) Save the view, and add an Attachment display.
3) Choose Table for the Attachment's display style.
Make sure that you click the "Override" button or you will set the Page display style to Table also.
4) Under Attachment Settings, choose Position: After and Attach to: Page.
5) Save the view again, and you should be set.
Let me know if that works for you.
Comment #22
uprojects commented@EvanDonovan It work for me thank you !!!
Comment #23
saroshrabia commentedHi,
I have created a view with Gmap + Table, my view also has the following aruguments
Country --> Province --> City.
The view does show the map + table but on the main page, aruguments listed twice
For example
USA
Canada
USA
Canada
Below is the export code from my view
==============
$view = new view;
$view->name = 'test';
$view->description = 'test';
$view->tag = '';
$view->view_php = '';
$view->base_table = 'location';
$view->is_cacheable = FALSE;
$view->api_version = 2;
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
$handler = $view->new_display('default', 'Defaults', 'default');
$handler->override_option('fields', array(
'address' => array(
'label' => 'Address',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'link_class' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'strip_tags' => 0,
'html' => 0,
),
'hide' => array(
'name' => 0,
'street' => 0,
'additional' => 0,
'city' => 0,
'province' => 0,
'postal_code' => 0,
'country' => 0,
'locpick' => 0,
'fax' => 0,
'phone' => 0,
'province_name' => 0,
'country_name' => 0,
'map_link' => 0,
'coords' => 0,
),
'exclude' => 0,
'id' => 'address',
'table' => 'location',
'field' => 'address',
'override' => array(
'button' => 'Override',
),
'relationship' => 'none',
),
'city' => array(
'label' => 'City',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'link_class' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'strip_tags' => 0,
'html' => 0,
),
'exclude' => 0,
'id' => 'city',
'table' => 'location',
'field' => 'city',
'override' => array(
'button' => 'Override',
),
'relationship' => 'none',
),
'country' => array(
'label' => 'Country',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'link_class' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'strip_tags' => 0,
'html' => 0,
),
'style' => 'name',
'exclude' => 0,
'id' => 'country',
'table' => 'location',
'field' => 'country',
'override' => array(
'button' => 'Override',
),
'relationship' => 'none',
),
'name' => array(
'label' => 'Name',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'link_class' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'strip_tags' => 0,
'html' => 0,
),
'exclude' => 0,
'id' => 'name',
'table' => 'location',
'field' => 'name',
'override' => array(
'button' => 'Override',
),
'relationship' => 'none',
),
'phone' => array(
'label' => 'Phone',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'link_class' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'strip_tags' => 0,
'html' => 0,
),
'exclude' => 0,
'id' => 'phone',
'table' => 'location_phone',
'field' => 'phone',
'override' => array(
'button' => 'Override',
),
'relationship' => 'none',
),
'postal_code' => array(
'label' => 'Postal Code',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'link_class' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'strip_tags' => 0,
'html' => 0,
),
'exclude' => 0,
'id' => 'postal_code',
'table' => 'location',
'field' => 'postal_code',
'override' => array(
'button' => 'Override',
),
'relationship' => 'none',
),
'province' => array(
'label' => 'Province',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'link_class' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'strip_tags' => 0,
'html' => 0,
),
'style' => 'name',
'exclude' => 0,
'id' => 'province',
'table' => 'location',
'field' => 'province',
'override' => array(
'button' => 'Override',
),
'relationship' => 'none',
),
'street' => array(
'label' => 'Street',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'link_class' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'strip_tags' => 0,
'html' => 0,
),
'style' => 'both',
'exclude' => 0,
'id' => 'street',
'table' => 'location',
'field' => 'street',
'override' => array(
'button' => 'Override',
),
'relationship' => 'none',
),
));
$handler->override_option('arguments', array(
'country' => array(
'default_action' => 'summary asc',
'style_plugin' => 'default_summary',
'style_options' => array(
'count' => 1,
'override' => 0,
'items_per_page' => '25',
),
'wildcard' => 'all',
'wildcard_substitution' => 'All',
'title' => '%1',
'breadcrumb' => '',
'default_argument_type' => 'fixed',
'default_argument' => '',
'validate_type' => 'none',
'validate_fail' => 'not found',
'id' => 'country',
'table' => 'location',
'field' => 'country',
'validate_user_argument_type' => 'uid',
'validate_user_roles' => array(
'2' => 0,
),
'override' => array(
'button' => 'Override',
),
'relationship' => 'none',
'default_options_div_prefix' => '',
'default_argument_user' => 0,
'default_argument_fixed' => '',
'default_argument_php' => '',
'validate_argument_node_type' => array(
'panel' => 0,
'page' => 0,
'story' => 0,
'sunnimosque' => 0,
),
'validate_argument_node_access' => 0,
'validate_argument_nid_type' => 'nid',
'validate_argument_vocabulary' => array(),
'validate_argument_type' => 'tid',
'validate_argument_transform' => 0,
'validate_user_restrict_roles' => 0,
'validate_argument_php' => 'return FALSE;',
),
'province' => array(
'default_action' => 'summary asc',
'style_plugin' => 'default_summary',
'style_options' => array(
'count' => 1,
'override' => 0,
'items_per_page' => '25',
),
'wildcard' => 'all',
'wildcard_substitution' => 'All',
'title' => '%2',
'breadcrumb' => '',
'default_argument_type' => 'fixed',
'default_argument' => '',
'validate_type' => 'none',
'validate_fail' => 'not found',
'id' => 'province',
'table' => 'location',
'field' => 'province',
'validate_user_argument_type' => 'uid',
'validate_user_roles' => array(
'2' => 0,
),
'override' => array(
'button' => 'Override',
),
'relationship' => 'none',
'default_options_div_prefix' => '',
'default_argument_user' => 0,
'default_argument_fixed' => '',
'default_argument_php' => '',
'validate_argument_node_type' => array(
'panel' => 0,
'page' => 0,
'story' => 0,
'sunnimosque' => 0,
),
'validate_argument_node_access' => 0,
'validate_argument_nid_type' => 'nid',
'validate_argument_vocabulary' => array(),
'validate_argument_type' => 'tid',
'validate_argument_transform' => 0,
'validate_user_restrict_roles' => 0,
'validate_argument_php' => 'return FALSE;',
),
'city' => array(
'default_action' => 'summary asc',
'style_plugin' => 'default_summary',
'style_options' => array(),
'wildcard' => 'all',
'wildcard_substitution' => 'All',
'title' => '%1',
'breadcrumb' => '',
'default_argument_type' => 'fixed',
'default_argument' => '',
'validate_type' => 'none',
'validate_fail' => 'not found',
'glossary' => 0,
'limit' => '0',
'case' => 'none',
'path_case' => 'none',
'transform_dash' => 0,
'id' => 'city',
'table' => 'location',
'field' => 'city',
'validate_user_argument_type' => 'uid',
'validate_user_roles' => array(
'2' => 0,
),
'override' => array(
'button' => 'Override',
),
'relationship' => 'none',
'default_options_div_prefix' => '',
'default_argument_user' => 0,
'default_argument_fixed' => '',
'default_argument_php' => '',
'validate_argument_node_type' => array(
'panel' => 0,
'page' => 0,
'story' => 0,
'sunnimosque' => 0,
),
'validate_argument_node_access' => 0,
'validate_argument_nid_type' => 'nid',
'validate_argument_vocabulary' => array(),
'validate_argument_type' => 'tid',
'validate_argument_transform' => 0,
'validate_user_restrict_roles' => 0,
'validate_argument_php' => 'return FALSE;',
),
));
$handler->override_option('access', array(
'type' => 'none',
));
$handler->override_option('cache', array(
'type' => 'none',
));
$handler->override_option('style_plugin', 'gmap');
$handler = $view->new_display('page', 'Page', 'page_1');
$handler->override_option('path', 'test/dir');
$handler->override_option('menu', array(
'type' => 'none',
'title' => '',
'description' => '',
'weight' => 0,
'name' => 'navigation',
));
$handler->override_option('tab_options', array(
'type' => 'none',
'title' => '',
'description' => '',
'weight' => 0,
));
$handler = $view->new_display('attachment', 'Attachment', 'attachment_1');
$handler->override_option('style_plugin', 'table');
$handler->override_option('style_options', array(
'grouping' => '',
'override' => 1,
'sticky' => 0,
'order' => 'asc',
'columns' => array(
'address' => 'address',
'city' => 'city',
'country' => 'country',
'name' => 'name',
'phone' => 'phone',
'postal_code' => 'postal_code',
'province' => 'province',
'street' => 'street',
),
'info' => array(
'address' => array(
'separator' => '',
),
'city' => array(
'sortable' => 0,
'separator' => '',
),
'country' => array(
'sortable' => 0,
'separator' => '',
),
'name' => array(
'sortable' => 0,
'separator' => '',
),
'phone' => array(
'sortable' => 0,
'separator' => '',
),
'postal_code' => array(
'sortable' => 0,
'separator' => '',
),
'province' => array(
'sortable' => 0,
'separator' => '',
),
'street' => array(
'sortable' => 0,
'separator' => '',
),
),
'default' => '-1',
));
$handler->override_option('attachment_position', 'after');
$handler->override_option('inherit_arguments', 1);
$handler->override_option('inherit_exposed_filters', FALSE);
$handler->override_option('displays', array(
'page_1' => 'page_1',
'default' => 0,
));
============
What I want is to have the arguments (country, state, city) to display only once on the main page instead of twice. Any help would be appericiated.
Thanks
Sarosh
Comment #24
becw commentedI have to admit I didn't try to load up your View, but you probably need to override argument behavior on the map attachment. For in the Views arguments section, click the little 'reorder' button and then click 'override' and save it; then edit each of your arguments and change 'action to take if argument is not present' from 'show summary' to 'hide view/display 404'.
This will mean that if you want to edit your view arguments you have to make your changes both on the page display and the attachment display, but it's the only way for arguments to behave differently on different displays.
Comment #25
saroshrabia commentedHello,
I have figured it out, how to do this,
I took the following approach. http://drupalsn.com/learn-drupal/drupal-questions/question-2650
Step 1:
Create a view page + attachment (using the what ever argument you need)
Select view style gmap
Step 2:
for attachment
Override the setting and select view style to table or any other
Than click on each argument and under Action to take if argument is not present:
click default value, change value type to php code and copy/paste the code below (modify it according)
follow this step for each argument and change the $path[1] with appropriate path like if your second path is http://www.test.com/testattach/system1/site2 then your path variable should be $path[2] and so on.
I hope this make sense.
Thanks
Comment #26
becw commentedSince the code in this issue is something that is achievable with regular Views attachments, I'm going to close this issue.