$this->resource_name , // resource_name
array( // array of arrays for multiple methods. Add more arrays for different endpoints.
array( // endpoint for getting members
- 'methods' => WP_REST_Server::CREATABLE,
+ 'methods' => WP_REST_Server::READABLE,
'callback' => function( $request ) {
// 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
- // );
- // }
-
- // // 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()
- // )
- // );
+ if ($latMax > $lastLatMax) {
+ $poiAreas[] = array(
+ 'area' => 'New at top',
+ 'latMax' => $latMax,
+ 'latMin' => $lastLatMax,
+ 'lonMax' => $lonMax,
+ 'lonMin' => $lonMin
+ );
+ }
+
+ // 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()
+ )
+ );
+
+ $this->params = $request->get_params();
+
$test = json_encode($request['latMax']);
- return rest_ensure_response( $test );
+ $response['params'] = $this->params;
+ $response['poiData'] = $poiData;
+ $response['poiAreas'] = $poiAreas;
+
+ return rest_ensure_response( $response );
+ //return rest_ensure_response( get_object_vars ( (object) $response ) );
},
)
)