resource; $parking_fence = json_decode($model->parking_fence); $parking_centre = json_decode($model->parking_centre, true); $parking_fence_wx = []; foreach ($parking_fence as $v) { $parking_fence_wx[] = ['longitude' => $v[0], 'latitude' => $v[1]]; } if ($model->type == Parking::TYPE_STOP_BIKE) { // 停车区 $parink_area = [ 'points' => $parking_fence_wx, 'strokeWidth' => 4, 'strokeColor' => '#ff00ff', 'fillColor' => '#ff00ff22', 'zIndex' => $model->id, 'id' => 'P' . $model->id ]; $point = [ 'latitude' => $parking_centre[1], 'longitude' => $parking_centre[0], 'zIndex' => $model->id, 'id' => 'p' . $model->id, 'width' => 24, 'height' => 28, 'iconPath' => 'http://resource.bike.hanyiyun.com/yunwei/parkShow.png', ]; } else { // 禁停区 $parink_area = [ 'points' => $parking_fence_wx, 'strokeWidth' => 4, 'strokeColor' => '#ff0000', 'fillColor' => '#ff000022', 'zIndex' => $model->id, 'id' => 'N' . $model->id ]; $point = [ 'latitude' => $parking_centre[1], 'longitude' => $parking_centre[0], 'name' => $model->name, 'zIndex' => $model->id, 'id' => 'n' . $model->id, 'width' => 24, 'height' => 28, 'iconPath' => 'http://resource.bike.hanyiyun.com/yunwei/forbid.png', ]; } return [ 'id' => $model->id, 'area_id' => $model->area_id, 'name' => $model->name, 'area_name' => $model->area->name, 'max_number' => $model->max_number, 'parking_fence' => $parking_fence_wx, 'parking_centre' => ['longitude' => $parking_centre[0], 'latitude' => $parking_centre[1]], 'parking_radius' => $model->parking_radius, 'type' => $model->type, 'status' => (bool)$model->status, 'created_at' => (string)$model->created_at, 'updated_at' => (string)$model->updated_at, 'parking_area' => $parink_area, 'point' => $point, ]; } // public function additional($request) // { // // $model = $this->resource; // $parking_fence = json_decode($model->parking_fence); // $parking_centre = json_decode($model->parking_centre, true); // $parking_fence_wx = []; // foreach ($parking_fence as $v) { // $parking_fence_wx[] = ['longitude' => $v[0], 'latitude' => $v[1]]; // } // if ($model->type == Parking::TYPE_STOP_BIKE) { // // 停车区 // $parink_area = [ // 'points' => $parking_fence_wx, // 'strokeWidth' => 4, // 'strokeColor' => '#ff00ff', // 'fillColor' => '#ff00ff22', // 'zIndex' => $model->id, // 'id' => 'P' . $model->id // ]; // // $point = [ // 'latitude' => $parking_centre[1], // 'longitude' => $parking_centre[0], // 'zIndex' => $model->id, // 'id' => 'p' . $model->id, // 'width' => 24, // 'height' => 28, // 'iconPath' => 'http://resource.bike.hanyiyun.com/yunwei/parkShow.png', // ]; // } else { // // 禁停区 // // $parink_area = [ // 'points' => $parking_fence_wx, // 'strokeWidth' => 4, // 'strokeColor' => '#ff0000', // 'fillColor' => '#ff000022', // 'zIndex' => $model->id, // 'id' => 'N' . $model->id // ]; // // $point = [ // 'latitude' => $parking_centre[1], // 'longitude' => $parking_centre[0], // 'zIndex' => $model->id, // 'id' => 'n' . $model->id, // 'width' => 24, // 'height' => 28, // 'iconPath' => 'http://resource.bike.hanyiyun.com/yunwei/forbid.png', // ]; // } // return [ // 'data' => [ // 'parking_area' => $parink_area, // 'point' => $point, // ] // // ]; // } }