【类 型】:feat
【原 因】:从数据库获取 地图样式列表接口 【过 程】: 【影 响】:
This commit is contained in:
parent
1c0592d6e3
commit
fa29542107
@ -1045,4 +1045,32 @@ class PlaneController extends PublicController
|
|||||||
echo json_encode(array('status' => 0, 'msg' => '参数不完整'));
|
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' => '暂无地图样式数据'
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user