fetchStyleJson static method

Future<Map<String, dynamic>> fetchStyleJson(
  1. String layerId
)

Fetches a MapLibre style JSON from PowerMap APIs

Implementation

static Future<Map<String, dynamic>> fetchStyleJson(String layerId) async {
  final apikey = PowerMapSDK.mapApiKey;
  final url =
      '${PowerMapSDK.baseUrl}/api/v2/map/vtile/styles?name=$layerId&apikey=$apikey';

  final response = await http.get(Uri.parse(url));
  if (response.statusCode == 200) {
    return json.decode(response.body) as Map<String, dynamic>;
  }
  throw Exception('Failed to fetch layer vector style: $layerId');
}