/** * <p> Retrieve the markers to display on Google Maps and the center position * if no items are returned for the Current Project</p> * <p> This method is called via an AJAX request from the client side. </p> * <p> The method receive by inheritance some post data * properties JSON object which includes objectTypes as "keys" and nested associative propNames * example: * "properties": { * "facility_obj": { * "objectLatPropName": "facility_lat", * "objectLngPropName": "facility_long" * }, * "project_obj": { * "objectActivePropName": "project_active" * } * Since we must use "project_active" property to determine marker icon we must use multiple mapped objects there and we can't send only facility property info * For more info: * \Applications\PMTool\Helpers\MapHelper::CreateFacilityMarkerItems * @link * </p> * <p> * @param object $rq <p> * The current HttpRequest. * </p> * @return mixed $result <p> * The result is a standard JSON response containing * the specific data to the request, e.g.: * - the list markers for a given filter * - the default position used to center the map (this configured in the appsettings.xml) */ public function executeListCurrentProject(\Library\HttpRequest $rq) { $result = $this->InitResponseWS(); //get datapost and decode properties string to array $dataPost = $this->dataPost(); $properties = json_decode($dataPost['properties'], true); //get current session project $sessionProject = \Applications\PMTool\Helpers\ProjectHelper::GetCurrentSessionProject($this->app()->user()); //load marker icons from config $icons = \Applications\PMTool\Helpers\MapHelper::GetActiveInactiveIcons($this->app()->relative_path, $this->app()->imageUtil, $this->app()->config()); //create google maps marker items $projectLocationMarkers = \Applications\PMTool\Helpers\MapHelper::CreateFacilityMarkerItems(array($sessionProject), $properties, $icons); $result["noLatLngIcon"] = $icons["noLatLng"]; $result["items"] = $projectLocationMarkers; $result["defaultPosition"] = \Applications\PMTool\Helpers\MapHelper::GetCoordinatesToCenterOverARegion($this->app()->config()); $result["boundary"] = \Applications\PMTool\Helpers\MapHelper::GetBoundary($sessionProject); $result["facility_id"] = $sessionProject[\Library\Enums\SessionKeys::FacilityObject]->facility_id(); $result["project_id"] = $sessionProject[\Library\Enums\SessionKeys::FacilityObject]->project_id(); $result["type"] = "facility"; $result["activeTask"] = false; $result["controls"] = array("markers" => false, "shapes" => true, "ruler" => true); $this->SendResponseWS($result, array("resx_file" => \Applications\PMTool\Resources\Enums\ResxFileNameKeys::Map, "resx_key" => $this->action(), "step" => count($projectLocationMarkers) >= 0 ? "success" : "error")); }