network<T extends Object> static method

Widget network<T extends Object>(
  1. String url, {
  2. Client? client,
  3. List<int> statusCodes = const <int>[200],
  4. Map<String, String>? headers,
  5. Key? key,
  6. bool polygonCulling = false,
  7. Polygon<T> builder(
    1. List<List<LatLng>> coordinates,
    2. Map<String, dynamic>? map
    )?,
  8. PolygonProperties<T>? polygonProperties,
  9. MapController? mapController,
  10. Widget fallback(
    1. int? statusCode
    )?,
})

Loads and displays polygons from a network source on a map.

The url parameter specifies the URL of the polygon data source.

Example:

PowerGeoJSONPolygons.network(
  'https://example.com/polygon_data.geojson',
  builder: (coordinates, properties) {
    // Customize polygon rendering
    return Polygon(
      points: coordinates[0].map((point) => LatLng(point[1], point[0])).toList(),
      // Add more polygon properties as needed
    );
  },
  mapController: myMapController,
)

Implementation

static Widget network<T extends Object>(
  String url, {
  Client? client,
  List<int> statusCodes = const <int>[200],
  Map<String, String>? headers,
  // layer
  Key? key,
  bool polygonCulling = false,
  Polygon<T> Function(
    List<List<LatLng>> coordinates,
    Map<String, dynamic>? map,
  )?
  builder,
  PolygonProperties<T>? polygonProperties,
  MapController? mapController,
  Widget Function(int? statusCode)? fallback,
}) {
  assert(
    (builder == null && polygonProperties != null) ||
        (polygonProperties == null && builder != null),
  );
  Uri uriString = url.toUri();
  return EnhancedFutureBuilder<Widget>(
    future: _networkPolygons(
      uriString,
      builder: builder,
      headers: headers,
      client: client,
      statusCodes: statusCodes,
      polygonProperties: polygonProperties,
      key: key,
      polygonCulling: polygonCulling,
      mapController: mapController,
      fallback: fallback,
    ),
    rememberFutureResult: true,
    whenDone: (Widget snapshotData) => snapshotData,
    whenNotDone: const Center(child: CupertinoActivityIndicator()),
  );
}