diff --git a/FlyCube/MpApi/Controller/PlaneController.class.php b/FlyCube/MpApi/Controller/PlaneController.class.php index 3e57256..4f63b8f 100644 --- a/FlyCube/MpApi/Controller/PlaneController.class.php +++ b/FlyCube/MpApi/Controller/PlaneController.class.php @@ -1045,4 +1045,32 @@ class PlaneController extends PublicController echo json_encode(array('status' => 0, 'msg' => '参数不完整')); } } + /** + * @description: 获取地图样式列表 + */ + public function getMapStyleList() + { + $where['is_active'] = 1; + $mapStyleDb = D('map_styles'); + $field = array('id', 'name', 'sprite', 'glyphs', 'version', 'source_name', 'source_type', 'tile_size', 'tiles', 'attribution', 'layer_id', 'layer_type', 'layer_source', 'sort_order'); + + $list = $mapStyleDb->where($where)->field($field)->order('sort_order ASC')->select(); + if ($list) { + // 把 tiles 字段从 JSON 字符串解析成数组 + foreach ($list as &$style) { + $style['tiles'] = json_decode($style['tiles'], true); + } + + echo json_encode(array( + 'status' => 1, + 'msg' => '访问成功', + 'mapStyleList' => $list + )); + } else { + echo json_encode(array( + 'status' => 0, + 'msg' => '暂无地图样式数据' + )); + } + } }