diff --git a/code/widget/ListFilterWidgetGoogleMap.php b/code/widget/ListFilterWidgetGoogleMap.php index 2b0b221..4d8a9f3 100644 --- a/code/widget/ListFilterWidgetGoogleMap.php +++ b/code/widget/ListFilterWidgetGoogleMap.php @@ -139,9 +139,8 @@ public function getFeatureCollection() { $list = $this->getList(); if (!$list) { - // NOTE(Jake): Ensures if any filters are applied with no user input, that they - // still get applied for map markers. - $list = $this->FilteredList(array()); + // When filtering has been applied, fetch the filtered result set + $list = $this->FilteredList($this->getRequest()->getVars()); if (!$list) { throw new Exception('No form or record configured against '.__CLASS__.'.'); } @@ -289,6 +288,7 @@ public function getPopupTemplate(ViewableData $record) { */ public function onBeforeRender() { parent::onBeforeRender(); + Requirements::javascript(ListFilterUtility::MODULE_DIR.'/javascript/thirdparty/url-search-params-polyfill.min.js'); Requirements::javascript(ListFilterUtility::MODULE_DIR.'/javascript/ListFilterWidgetGoogleMap.js'); } diff --git a/javascript/ListFilterWidgetGoogleMap.js b/javascript/ListFilterWidgetGoogleMap.js index a1c8c67..7291baf 100644 --- a/javascript/ListFilterWidgetGoogleMap.js +++ b/javascript/ListFilterWidgetGoogleMap.js @@ -32,7 +32,7 @@ cacheAjaxURL[url] = false; $.ajax({ type: 'GET', - url: url, + url: url + new URLSearchParams(window.location).get('search'), async: true, crossDomain: true, headers: { diff --git a/javascript/thirdparty/url-search-params-polyfill.min.js b/javascript/thirdparty/url-search-params-polyfill.min.js new file mode 100644 index 0000000..1945433 --- /dev/null +++ b/javascript/thirdparty/url-search-params-polyfill.min.js @@ -0,0 +1,8 @@ +/** + * Minified by jsDelivr using UglifyJS v3.4.4. + * Original file: /npm/url-search-params-polyfill@5.0.0/index.js + * + * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files + */ +!function(r){"use strict";var n,t=r.URLSearchParams?r.URLSearchParams:null,e=t&&"a=1"===new t({a:1}).toString(),o=t&&"+"===new t("s=%2B").get("s"),a="__URLSearchParams__",i=!t||((n=new t).append("s"," &"),"s=+%26"===n.toString()),s=h.prototype,f=!(!r.Symbol||!r.Symbol.iterator);if(!(t&&e&&o&&i)){s.append=function(n,t){S(this[a],n,t)},s.delete=function(n){delete this[a][n]},s.get=function(n){var t=this[a];return n in t?t[n][0]:null},s.getAll=function(n){var t=this[a];return n in t?t[n].slice(0):[]},s.has=function(n){return n in this[a]},s.set=function(n,t){this[a][n]=[""+t]},s.toString=function(){var n,t,r,e,o=this[a],i=[];for(t in o)for(r=l(t),n=0,e=o[t];n