From caa960353325ec01c8113d49f72e3b848cac70f7 Mon Sep 17 00:00:00 2001 From: Chuck Scott Date: Tue, 22 Oct 2019 13:59:02 -0400 Subject: [PATCH] Solved problems with member pushpins now showing. --- models/admin/ajax/getPOI.php | 199 +++++++-------- readme.txt | 20 +- views/front/nearme/index.html | 444 +++++++++++++++++----------------- 3 files changed, 341 insertions(+), 322 deletions(-) diff --git a/models/admin/ajax/getPOI.php b/models/admin/ajax/getPOI.php index 0a24f58..fcc66ba 100644 --- a/models/admin/ajax/getPOI.php +++ b/models/admin/ajax/getPOI.php @@ -13,9 +13,8 @@ * @version 0.1 */ - // Load Members Data Class -require_once GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataMembers.php'; +require_once GLM_MEMBERS_PLUGIN_CLASS_PATH . '/data/dataMembers.php'; /* * This class exports the currently selected members list @@ -48,7 +47,7 @@ class GlmMembersAdmin_ajax_getPOI extends GlmDataMembers * @return object Class object * */ - public function __construct ($wpdb, $config) + public function __construct( $wpdb, $config ) { // Save WordPress Database object @@ -57,7 +56,7 @@ class GlmMembersAdmin_ajax_getPOI extends GlmDataMembers // Save plugin configuration object $this->config = $config; - parent::__construct(false, false); + parent::__construct( false, false ); } @@ -74,40 +73,40 @@ class GlmMembersAdmin_ajax_getPOI extends GlmDataMembers * * Echos JSON string as response and does not return */ - public function modelAction ($actionData = false) + public function modelAction( $actionData = false ) { $ret = false; - $poiAreas = false; // False means to search anywhere + $poiAreas = false; // False means to search anywhere // Get any search string - $searchText = html_entity_decode( filter_input(INPUT_GET, 'searchText', FILTER_SANITIZE_STRING), ENT_QUOTES | ENT_XML1); + $searchText = html_entity_decode( filter_input( INPUT_GET, 'searchText', FILTER_SANITIZE_STRING ), + ENT_QUOTES | ENT_XML1 ); - $request = filter_input(INPUT_GET, 'request', FILTER_SANITIZE_STRING); + $request = filter_input( INPUT_GET, 'request', FILTER_SANITIZE_STRING ); // Get the target LAT/LON area - $latMax = filter_input(INPUT_GET, 'latMax', FILTER_VALIDATE_FLOAT); - $latMin = filter_input(INPUT_GET, 'latMin', FILTER_VALIDATE_FLOAT); - $lonMax = filter_input(INPUT_GET, 'lonMax', FILTER_VALIDATE_FLOAT); - $lonMin = filter_input(INPUT_GET, 'lonMin', FILTER_VALIDATE_FLOAT); - + $latMax = filter_input( INPUT_GET, 'latMax', FILTER_VALIDATE_FLOAT ); + $latMin = filter_input( INPUT_GET, 'latMin', FILTER_VALIDATE_FLOAT ); + $lonMax = filter_input( INPUT_GET, 'lonMax', FILTER_VALIDATE_FLOAT ); + $lonMin = filter_input( INPUT_GET, 'lonMin', FILTER_VALIDATE_FLOAT ); // If this is not an "anywhere" search, then build the lat/lon areas - switch($request) { + switch ( $request ) { - case 'onMap'; + case 'onMap': // Check for good LAT/LON data - if ($latMax && $latMin && $lonMax && $lonMin) { + if ( $latMax && $latMin && $lonMax && $lonMin ) { // Get the previous target LAT/LON area - $lastLatMax = filter_input(INPUT_GET, 'lastLatMax', FILTER_VALIDATE_FLOAT); - $lastLatMin = filter_input(INPUT_GET, 'lastLatMin', FILTER_VALIDATE_FLOAT); - $lastLonMax = filter_input(INPUT_GET, 'lastLonMax', FILTER_VALIDATE_FLOAT); - $lastLonMin = filter_input(INPUT_GET, 'lastLonMin', FILTER_VALIDATE_FLOAT); + $lastLatMax = filter_input( INPUT_GET, 'lastLatMax', FILTER_VALIDATE_FLOAT ); + $lastLatMin = filter_input( INPUT_GET, 'lastLatMin', FILTER_VALIDATE_FLOAT ); + $lastLonMax = filter_input( INPUT_GET, 'lastLonMax', FILTER_VALIDATE_FLOAT ); + $lastLonMin = filter_input( INPUT_GET, 'lastLonMin', FILTER_VALIDATE_FLOAT ); // If this is the first load, request all POIs within map bounds - if ($lastLatMax == false) { + if ( $lastLatMax == false ) { // Add entire map as area to update $poiAreas[] = array( @@ -118,14 +117,14 @@ class GlmMembersAdmin_ajax_getPOI extends GlmDataMembers 'lonMin' => $lonMin ); - // Otherwise request only those POIs in the new map areas + // Otherwise request only those POIs in the new map areas } else { // Check for good last LAT/LON data - if ($lastLatMax && $lastLatMin && $lastLonMax && $lastLonMin) { + if ( $lastLatMax && $lastLatMin && $lastLonMax && $lastLonMin ) { // Check if there's new area at the top of the map - if ($latMax > $lastLatMax) { + if ( $latMax > $lastLatMax ) { $poiAreas[] = array( 'area' => 'New at top', 'latMax' => $latMax, @@ -136,7 +135,7 @@ class GlmMembersAdmin_ajax_getPOI extends GlmDataMembers } // Check if there's new area at the bottom of the map - if ($latMin < $lastLatMin) { + if ( $latMin < $lastLatMin ) { $poiAreas[] = array( 'area' => 'New at bottom', 'latMax' => $lastLatMin, @@ -147,7 +146,7 @@ class GlmMembersAdmin_ajax_getPOI extends GlmDataMembers } // Check if there's new area at the left of the map - if ($lonMin < $lastLonMin) { + if ( $lonMin < $lastLonMin ) { $poiAreas[] = array( 'area' => 'New at left', 'latMax' => $latMax, @@ -158,7 +157,7 @@ class GlmMembersAdmin_ajax_getPOI extends GlmDataMembers } // Check if there's new area at the right of the map - if ($lonMax > $lastLonMax) { + if ( $lonMax > $lastLonMax ) { $poiAreas[] = array( 'area' => 'New at right', 'latMax' => $latMax, @@ -167,11 +166,8 @@ class GlmMembersAdmin_ajax_getPOI extends GlmDataMembers 'lonMin' => $lastLonMax ); } - } - } - } break; @@ -182,92 +178,97 @@ class GlmMembersAdmin_ajax_getPOI extends GlmDataMembers default: $request = 'onMap'; break; - } - /* + /* * Get map items * * (NOTE that while this is for a front-end feature, that feature gets - * data via AJAX, which is processed by the admin controller.) + * data via AJAX, which is processed by the admin controller.) * * The array supplied is in the following standardized format. This format is * used for all generic map items aggregated from multiple sources. * - * 'request' What type of request is being made - Request only - * 'filter' A string filter to use to limit results - Request only - * 'area' A set of lat/lon areas to get results for (if request = 'onMap') - Request only - * If false then get all results without regard as to where they are. - * 'sources' An array of source information for what type of item and which add-on - Each source adds one entry here - * 'mapItems' Array of new map items to return to NearMe - Each source adds one or more map items here + * 'request' What type of request is being made - Request only + * 'filter' A string filter to use to limit results - Request only + * 'area' A set of lat/lon areas to get results for (if request = 'onMap') - Request only + * If false then get all results without regard as to where they are. + * 'sources' An array of source information for what type of item and which add-on - Each + * source adds one entry here + * 'mapItems' Array of new map items to return to NearMe - Each source adds one or more map + * items here * * array( - * 'request' => {'onMap', 'anywhere'} - * 'filter' => {some search string} - * 'area' => array( - * // First area to search - * array( - * 'latMax' => {lat at North end of area}, - * 'latMin' => {lat at South end of area}, - * 'lonMax' => {lon at East end of area}, - * 'lonMin' => {lon at West end of area} - * ), - * // Second area to search - * array( - * 'latMax' => {lat at North end of area}, - * 'latMin' => {lat at South end of area}, - * 'lonMax' => {lon at East end of area}, - * 'lonMin' => {lon at West end of area} - * ), - * // Additional areas - * ), - * 'sources' = array( - * {addOn Slug} => array( - * 'addOn' => {addOn Slug}, - * 'type' => {Name to use for the source - Needs to match the 'type' element in map items added by the addOn ) - * ), - * // Additional sources - * ), - * 'mapItems' => array( - * array( - * 'type' => {type of item, i.e. 'member', 'event', ...}, - * 'id' => {ID of item for reference}, - * 'lat' => {Latitude}, - * 'lon' => {Longitude}, - * 'name' => {Name of item}, - * 'loc_name' => {Name of Location}, - * 'addr1' => {Address line 1 of location}, - * 'addr2' => {Address line 2 of location}, - * 'city' => {City of location}, - * 'state' => {State code of location}, - * 'zip' => {Postal Code of location}, - * 'phone' => {Contact phone number}, - * 'email' => {Contact E-Mail address}, - * 'url' => {URL of item}, - * 'region' => {Region name, if available}, - * 'categories' => {array of categories - i.e. array( 0 = array( id => {id}, name => {name}), ... ) - * 'descr' => {Description}, - * 'short_descr' => {Short Description}, - * 'detail_page' => {URL of detail page, if available}, - * 'dates' => {Text stating date, dates, or date range}, - * 'times' => {Text stating time, times, or time range} - * ) - * ) + * 'request' => {'onMap', 'anywhere'} + * 'filter' => {some search string} + * 'area' => array( + * // First area to search + * array( + * 'latMax' => {lat at North end of area}, + * 'latMin' => {lat at South end of area}, + * 'lonMax' => {lon at East end of area}, + * 'lonMin' => {lon at West end of area} + * ), + * // Second area to search + * array( + * 'latMax' => {lat at North end of area}, + * 'latMin' => {lat at South end of area}, + * 'lonMax' => {lon at East end of area}, + * 'lonMin' => {lon at West end of area} + * ), + * // Additional areas + * ), + * 'sources' = array( + * {addOn Slug} => array( + * 'addOn' => {addOn Slug}, + * 'type' => {Name to use for the source - Needs to match the 'type' element in map items + * added by the addOn ) + * ), + * // Additional sources + * ), + * 'mapItems' => array( + * array( + * 'type' => {type of item, i.e. 'member', 'event', ...}, + * 'id' => {ID of item for reference}, + * 'lat' => {Latitude}, + * 'lon' => {Longitude}, + * 'name' => {Name of item}, + * 'loc_name' => {Name of Location}, + * 'addr1' => {Address line 1 of location}, + * 'addr2' => {Address line 2 of location}, + * 'city' => {City of location}, + * 'state' => {State code of location}, + * 'zip' => {Postal Code of location}, + * 'phone' => {Contact phone number}, + * 'email' => {Contact E-Mail address}, + * 'url' => {URL of item}, + * 'region' => {Region name, if available}, + * 'categories' => {array of categories - i.e. array( 0 = array( id => {id}, name => + * {name}), ... ) + * 'descr' => {Description}, + * 'short_descr' => {Short Description}, + * 'detail_page' => {URL of detail page, if available}, + * 'dates' => {Text stating date, dates, or date range}, + * 'times' => {Text stating time, times, or time range} * ) + * ) + * ) + * + * Current locations of an "add_filter()" call for this apply_filters() call are... + * glm-members-db/setup/adminHooks.php - Aprox Line 200 and below + * glm-members-db-events/setup/adminHooks.php - Aprox line 150 and below */ - $poiData = apply_filters( - 'glm-hook-list-map-items-by-latlon', + $poiData = apply_filters( 'glm-hook-list-map-items-by-latlon', array( - 'request' => $request, - 'filter' => $searchText, - 'area' => $poiAreas, + 'request' => $request, + 'filter' => $searchText, + 'area' => $poiAreas, 'sources' => array(), 'mapItems' => array() - ) - ); + ) ); - header('Content-type:application/json;charset=utf-8', true); - echo json_encode($poiData); + header( 'Content-type:application/json;charset=utf-8', true ); + echo json_encode( $poiData ); wp_die(); diff --git a/readme.txt b/readme.txt index e0ba2b9..e15049e 100644 --- a/readme.txt +++ b/readme.txt @@ -13,7 +13,25 @@ This is the Gaslight Media Near-Me Add-On for GLM Associate. == Description == The Gaslight Media Near-Me Add-On for GLM Associate is an add-on to the Gaslight Media Members Database, -which is required to install and run this plugin +which is required to install and run this plugin. + +The NearMe add-on works by displaying a map and then finding and displaying pushpins for desired members, +events, and other data. When the map is moved, the current selection of pushpins is updated using the +current selection criteria and filling getting data that falls withing the newly displayed areas. It +also purges data from areas that are no longer being displayed. + +The flow for making these requests is as follows... + +* Map moves and an AJAX call is made to "{$ajaxUrl}?action=glm_members_admin_ajax&glm_action=getPOI&request=...." + * That runs the models/admin/ajax/getPOI.php file + * getPOI.php applies filter 'glm-hook-list-map-items-by-latlon' + add_filter() has been run by any plugins that can contribute entries to the result these are currently... + * Members - glm-member-db/setup/adminHooks.php to get members that match + * Runs GLM_MEMBERS_PLUGIN_PATH.'/classes/memberDataByLatLon.php' + * Events - glm-member-db-events/setup/adminHooks.php to get members that match + * Runs - GLM_MEMBERS_EVENTS_PLUGIN_PATH . '/classes/eventDataByLatLon.php' + (CONSIDER MOVING TO classes as for members) + == Installation == diff --git a/views/front/nearme/index.html b/views/front/nearme/index.html index 714d0b4..5ecdcfd 100644 --- a/views/front/nearme/index.html +++ b/views/front/nearme/index.html @@ -5,15 +5,15 @@
Display only items matching this text:     - - Search All Areas + + Search All Areas
- +

- +
- My Location: + My Location: Follow Me Manual Map Selection    @@ -29,7 +29,7 @@
My Location (drag to change) - Clustered locations - Click to view: + Clustered locations - Click to view: @@ -44,19 +44,19 @@
- +
{ name } - Click for more
- + -{include file='front/footer.html'} \ No newline at end of file +{include file='front/footer.html'} \ No newline at end of file -- 2.17.1