New home › Forums › Pro Add-on › feature request: pass url arguments to map page
Tagged: feature request, filtering, url arguments
- This topic has 3 replies, 3 voices, and was last updated 8 years, 7 months ago by johnlanglois.
-
AuthorPosts
-
January 26, 2015 at 11:00 am #10589LeglawMember
I’d like to be able to pass arguments to the page serves to filter the results. I propose this work with categories a user can set up through the WP admin settings.
For example, if I have defined categories “Foo”, “Bar”, and “Baz”, and a map at the url
http://example.com/my-map
, I’d like to be be able to do the following:Show markers in category Foo:
http://example.com/my-map?wpgzCategory=Foo
Show markers in category Bar:
http://example.com/my-map?wpgzCategory=Bar
Show markers in category Foo and Baz (experimental):
http://example.com/my-map?wpgzCategories=Foo,Baz
January 26, 2015 at 11:11 am #10657Nick DuncanKeymasterHi there
We currently have a shortcode that can handle this at the moment.For example:
[ wpgmza cat=”cat_id” ] – would that not help?
There is no way at the moment to pick up GET variables. We’ll try add functionality for this in the future.
January 27, 2015 at 6:35 am #10711LeglawMemberThank you that’s good to know — that may come in useful. I tried it, and it does indeed display markers from that category, although the filter dropdown doesn’t reflect the selected category.
I worked up javascript way to read the get params from the URL and update select the appropriate option from the category filter. It’s kind of hackish, but it works. In case anyone finds this useful:
(function($) { $(function() { var $wpgm_select_category = $('#wpgmza_filter_select'), _get_param = function(q,s) { s = s || window.location.search; var re = new RegExp('&'+q+'(?:=([^&]*))?(?=&|$)','i'); return (s=s.replace(/^\?/,'&').match(re)) ? (typeof s[1] === 'undefined' ? false : decodeURIComponent(s[1])) : false; }; google.maps.event.addDomListener(window, 'load', function() { var category_id = _get_param('wpgmCategoryId'); if (category_id) { setTimeout(function() { map_change_category(category_id) }, 500); } }); function map_change_category(category_id) { $wpgm_select_category .find('option[value='+category_id+']') .prop('selected', true) .addBack() .change(); } }); })(jQuery);
February 18, 2015 at 6:15 am #11195johnlangloisMemberI discovered this while looking for a way to pass values to the shortcode.
Is there an API or a page that lists the accepted parameters? -
AuthorPosts
- The topic ‘feature request: pass url arguments to map page’ is closed to new replies.