adding point of interest route to get the boundaries of the user from the mobile app
authorAnthony Talarico <talarico@gaslightmedia.com>
Thu, 1 Aug 2019 14:13:22 +0000 (10:13 -0400)
committerAnthony Talarico <talarico@gaslightmedia.com>
Thu, 1 Aug 2019 14:13:22 +0000 (10:13 -0400)
setup/routes/pointsOfInterest.php

index 950b1d4..417f6d0 100644 (file)
@@ -35,7 +35,7 @@ class GLMA_POI_Rest_Controller
     public function __construct( $wpdb, $config )
     {
         $this->namespace     = 'glm/v1/';
-        $this->resource_name = 'poi';
+        $this->resource_name = 'pointsofinterest';
 
         // Setup wpdb and config
         $this->wpdb   = $wpdb;
@@ -62,9 +62,61 @@ class GLMA_POI_Rest_Controller
                         // Callback function can be a lot shorter.
                         // You could just create a new model to get the results in an array
                         // and use return rest_ensure_response( $data );
-      
+                        // Check if there's new area at the top of the map
+                        // if ($latMax > $lastLatMax) {
+                        //     $poiAreas[] = array(
+                        //         'area'   => 'New at top',
+                        //         'latMax' => $latMax,
+                        //         'latMin' => $lastLatMax,
+                        //         'lonMax' => $lonMax,
+                        //         'lonMin' => $lonMin
+                        //     );
+                        // }
 
-                        return rest_ensure_response( $request );
+                        // // Check if there's new area at the bottom of the map
+                        // if ($latMin < $lastLatMin) {
+                        //     $poiAreas[] = array(
+                        //         'area'   => 'New at bottom',
+                        //         'latMax' => $lastLatMin,
+                        //         'latMin' => $latMin,
+                        //         'lonMax' => $lonMax,
+                        //         'lonMin' => $lonMin
+                        //     );
+                        // }
+
+                        // // Check if there's new area at the left of the map
+                        // if ($lonMin < $lastLonMin) {
+                        //     $poiAreas[] = array(
+                        //         'area'   => 'New at left',
+                        //         'latMax' => $latMax,
+                        //         'latMin' => $latMin,
+                        //         'lonMax' => $lastLonMin,
+                        //         'lonMin' => $lonMin
+                        //     );
+                        // }
+
+                        // // Check if there's new area at the right of the map
+                        // if ($lonMax > $lastLonMax) {
+                        //     $poiAreas[] = array(
+                        //         'area'   => 'New at right',
+                        //         'latMax' => $latMax,
+                        //         'latMin' => $latMin,
+                        //         'lonMax' => $lonMax,
+                        //         'lonMin' => $lastLonMax
+                        //     );
+                        // }
+                        // $poiData = apply_filters(
+                        //     'glm-hook-list-map-items-by-latlon',
+                        //     array(
+                        //         'request' => $request,
+                        //         'filter' => $searchText,
+                        //         'area'   => $poiAreas,
+                        //         'sources'  => array(),
+                        //         'mapItems' => array()
+                        //     )
+                        // );
+                        $test = json_encode($request['latMax']);
+                        return rest_ensure_response( $test );
                     },
                 )
             )
@@ -111,6 +163,7 @@ class GLMA_POI_Rest_Controller
  add_action(
      'rest_api_init',
      function(){
+        
          $controller = new GLMA_POI_Rest_Controller( $this->wpdb, $this->config );
          $controller->register_routes();
      }