power_geojson 3.38.9
power_geojson: ^3.38.9 copied to clipboard
A Powerful tool for Geojson with flutter_map, styled from properties, supports esri json, soon supports multiple projection and coordinate systems
Flutter power_geojson #
Render GeoJSON (and Esri JSON) FeatureCollections on top of flutter_map with one-liners for markers, polygons, and polylines. Includes clustering, fallbacks, property-driven styling, and a tiny JSON helper for DateTime/Enum-safe serialization.
Highlights #
- Markers, polygons, and polylines driven directly from GeoJSON/Esri JSON.
- Load from network, assets, files, memory (
Uint8List), or raw strings. - Built-in marker clustering via
PowerMarkerClusterOptionsand HTTP fallbacks. - Property-based styling through
MarkerProperties,PolygonProperties, andPolylineProperties. - PowerJSON helper for safe JSON string building (DateTime, Enum, TimeOfDay).
Installation #
Add the dependency to your pubspec.yaml:
dependencies:
power_geojson: ^3.38.9
Quick start #
import 'package:flutter/material.dart';
import 'package:flutter_map/flutter_map.dart';
import 'package:latlong2/latlong.dart';
import 'package:power_geojson/power_geojson.dart';
class GeoMap extends StatelessWidget {
const GeoMap({super.key});
@override
Widget build(BuildContext context) {
return FlutterMap(
options: const MapOptions(
initialCenter: LatLng(33.59, -7.62),
initialZoom: 11,
),
children: [
TileLayer(
urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
userAgentPackageName: 'com.example.power_geojson_example',
),
PowerGeoJSONPolygons.asset(
'assets/polygons.geojson',
polygonProperties: PolygonProperties(
color: Colors.blue.withOpacity(0.2),
borderColor: Colors.blue,
borderStrokeWidth: 1.5,
),
),
PowerGeoJSONPolylines.network(
'https://example.com/lines.geojson',
polylineProperties: const PolylineProperties(
color: Colors.orange,
strokeWidth: 3,
),
fallback: (status) => Text('Network error: $status'),
),
PowerGeoJSONMarkers.network(
'https://example.com/points.geojson',
markerProperties: const MarkerProperties(height: 40, width: 40),
powerClusterOptions: PowerMarkerClusterOptions(
maxClusterRadius: 40,
builder: (context, markers) => const Icon(
Icons.location_on,
color: Colors.red,
),
),
),
],
);
}
}
Pick a data source #
- Asset:
PowerGeoJSONPolygons.asset('assets/polygons.geojson') - Network with fallback:
PowerGeoJSONPolylines.network(url, fallback: (status) => Text('Status $status')) - File:
PowerGeoJSONMarkers.file('/tmp/points.geojson', markerProperties: MarkerProperties(height: 32, width: 32)) - Memory/String:
PowerGeoJSONPolygons.memory(bytes)orPowerGeoJSONPolylines.string(jsonString)
PowerJSON quick helper #
final jsonText = PowerJSON({
'id': 7,
'timestamp': DateTime.now(),
'role': UserRole.admin,
'tags': ['geo', 'power'],
}).toText();
Documentation #
Full API docs live on pub.dev.
Changelog #
See CHANGELOG.md for recent updates.
Issues and contributions #
Contributions are welcome!
License #
This project is licensed under the MIT License - see LICENSE.