Orientação gerada a partir de informações públicas. Apenas para referência.
O pacote geojson fornece utilitários para trabalhar com dados GeoJSON em aplicativos Flutter. Inclui um parser reativo que permite o processamento em tempo real de estruturas GeoJSON, suporta operações de busca espacial e oferece recursos de geofencing para gatilhos baseados em localização. Projetado para desenvolvedores que integram funcionalidades de mapeamento e geoespaciais, simplifica a análise e manipulação de conteúdo GeoJSON em múltiplas plataformas. O pacote é ideal para aplicações que exigem manipulação dinâmica de dados de mapa, como ferramentas de navegação, rastreamento de localização ou mapas interativos.
Casos de uso
Aplicações de mapa interativo
Notificações baseadas em localização
Visualização de dados geoespaciais
Planejamento de rota em tempo real
Gerenciamento de camadas do mapa
Principais recursos
Análise reativa do GeoJSON
Busca espacial embutida
Suporte a geofencing
Compatibilidade multiplataforma
Manipulação de dados baseada em fluxo
Indicado para
Aplicativos de mapeamento para móvel e desktop
Serviços orientados por localização
Integrações de GIS
painéis de dados em tempo real
Equipes de desenvolvimento usando Flutter para projetos geoespaciais
Considerações
Requer conhecimento do formato GeoJSON
Pode ser necessário dependências adicionais para renderização completa do mapa
O desempenho depende do tamanho dos dados
Limitado a lógica geoespacial básica
Não é uma solução GIS completa
README original
Snapshot do README original do repositório-fonte vinculado. Consulte o repositório para o conteúdo mais recente.
Geojson
Utilities to work with geojson data in Dart. Features:
Parser with a reactive api: streams are available to retrieve the geojson features as soon as they are parsed
Search: search for properties
Geofencing: geofence points in a polygon or from a distance
Note: the data is parsed in an isolate to avoid slowing down the main thread
nameProperty: the property used for the geoserie name, automaticaly set if null
verbose: print the parsed data if true
These functions are suitable for small data. Example:
final features = awaitfeaturesFromGeoJson(data);
Web support
featuresFromGeoJsonMainThread: as the web do not support isolates use this function to parse in the main thread. Parameters:
data: a string with the geojson data, required
nameProperty: the property used for the geoserie name, automaticaly set if null
verbose: print the parsed data if true
Reactive api
Parse and listen
Typed streams are available to retrieve the features as soon as they are parsed. This is useful when the data is big.
processedFeatures: the parsed features: all the geometries
processedPoints: the parsed points
processedMultipoints: the parsed multipoints
processedLines: the parsed lines
processedMultilines: the parsed multilines
processedPolygons: the parsed polygons
processedMultipolygons: the parsed multipolygons
endSignal: parsing is finished indicator
Example: add assets on a Flutter map:
import'package:flutter/services.dart'show rootBundle;
import'package:geojson/geojson.dart';
import'package:flutter_map/flutter_map.dart';
/// Data for the Flutter map polylines layerfinal lines = <Polyline>[];
Future<void> parseAndDrawAssetsOnMap() async {
final geo = GeoJson();
geo.processedLines.listen((GeoJsonLine line) {
/// when a line is parsed add it to the map right awaysetState(() => lines.add(Polyline(
strokeWidth: 2.0, color: Colors.blue, points: line.geoSerie.toLatLng())));
});
geo.endSignal.listen((_) => geo.dispose());
final data = await rootBundle
.loadString('assets/railroads_of_north_america.geojson');
await geo.parse(data, verbose: true);
}
Data properties
After the data is parsed the GeoJson instance has properties to access the data:
A search method is also available, taking string data in parameter instead of a file path. The streams are available to retrieve the data as soon as it is found
Geofencing
Geofence points within a distance of a given point:
final geo = GeoJson();
/// `point` is the [GeoJsonPoint] to search from/// `points` is the list of [GeoJsonPoint] to search in/// `distance` is the distance to search in metersawait geo.geofenceDistance(
point: point, points: points, distance: distance);
List<GeoPoint> foundPoints = geo.points;
Geofence points in a polygon:
final geo = GeoJson();
/// `polygon` is the [GeoJsonPolygon] to check/// `points` is the list of [GeoJsonPoint] to search inawait geo.geofencePolygon(polygon: polygon, points: points);
List<GeoPoint> foundPoints = geo.points;
Note: the processedPoints stream is available to retrieve geofenced points as soon as they are found
Maps
To draw geojson data on a map check the Map controller package
Supported geojson features
All the data structures use GeoPoint and GeoSerie from the GeoPoint package to store the geometry data. Data structures used: