feature request: pass url arguments to map page

New home Forums Pro Add-on feature request: pass url arguments to map page

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #10589
    Leglaw
    Member

    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

    #10657
    Nick Duncan
    Keymaster

    Hi 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.

    #10711
    Leglaw
    Member

    Thank 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);
    #11195
    johnlanglois
    Member

    I 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?

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘feature request: pass url arguments to map page’ is closed to new replies.