Search packages, repositories and app categories

Package detailsv1.0.8

flutter_map_geojson

This package parses GeoJson formatted spatial data and creates arrays of Flutter Map objects using default or custom defined create functions.

AndroidiOSWebmacOSWindowsLinux
30-day downloads
2.4K
Likes
25
Pub points
130

Install package

flutter pub add flutter_map_geojson

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

flutter_map_geojson is a Dart package that enables parsing of GeoJSON spatial data and converting it into Flutter Map-compatible objects. It supports both default and custom creation functions, allowing developers to seamlessly integrate geographic data into their Flutter applications. The package works across all major platforms including Android, iOS, Web, macOS, Windows, and Linux, making it ideal for cross-platform geospatial visualization. It enhances the functionality of flutter_map by simplifying the integration of real-world geographic datasets.

Use cases

  • Integrating GeoJSON maps in mobile apps
  • Visualizing geographic data on web
  • Rendering custom map layers from GeoJSON
  • Building location-based dashboards
  • Displaying spatial data from APIs
  • Creating interactive maps with dynamic features

Key features

  • Supports GeoJSON parsing
  • Customizable object creation
  • Cross-platform compatibility
  • Works with flutter_map
  • Easy integration via pub
  • Extensible for custom geometries

Suitable for

  • Developers using flutter_map
  • Apps requiring GeoJSON support
  • Cross-platform map applications
  • Geospatial data visualization
  • Backend-driven map content

Considerations

  • Requires flutter_map to be installed
  • Custom creators need implementation
  • Large GeoJSON files may impact performance
  • Limited to geometry types supported by flutter_map
  • No built-in styling options beyond provided functions

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

GeoJson is becoming defacto standard for retrieving spatial data like points, lines and polygons. GeoJson Format specification is defined in RFC7964 - see https://www.rfc-editor.org/rfc/rfc7946 This package parses GeoJson data and creates spatial objects like [Marker]s, [Polyline]s and [Polygon]s, which are defined in [flutter_map] package.

The creation of these objects is done by default callback functions. However, one can and probably should write his own callback functions which are implementing the necessary customization of creating spatial objects by specifying the color, stroke, label text and other parameters.

Features

The GeoJson parser creates three (four) lists of spatial objects - separate lists of [Marker]s, [Polyline]s and [Polygon]s (and Circles) which are input data for creating layers in flutter_map. The parser supports parsing the following geometries:

  • Point - transformed into [Marker]s
  • Circle - transformed into [CircleMarker]s - not part of the spec, but handy to have. Specify radius in the properties.
  • Multipoint - transformed into multiple [Marker]s with same ID property
  • LineString - tranformed in [Polyline]
  • MultiLineString - transformed into multiple [Polyline]s
  • Polygon - transformed into [Polygon]
  • MultiPolygon - transformed into multiple [Polygon]s with same ID property

Getting started

Add the package in pubspec.yaml file:

flutter_map_geojson ^1.0.8

Import it in the code:

import 'package:flutter_map_geojson/flutter_map_geojson.dart';

Usage

 // initiate parser 
 GeoJsonParser myGeoJson = GeoJsonParser();
 
 // parse GeoJson data - GeoJson is stored as [String]
 myGeoJson.parseGeoJsonAsString(testGeoJson);

 // after parsing the results are stored in 
 // myGeoJson.markers -> List<Marker>
 // myGeoJson.polylines -> List<Polyline>
 // myGeoJson.ploygons -> List<Polygon>

 // now create flutter_map layers

 FlutterMap(
          mapController: MapController(),
          options: MapOptions(
            center: LatLng(45.993807, 14.483972),
            zoom: 14,
          ),
          children: [
            TileLayer(
                urlTemplate:
                    "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
                subdomains: const ['a', 'b', 'c']),
            PolygonLayer(polygons: myGeoJson.polygons),
            PolylineLayer(polylines: myGeoJson.polylines),
            MarkerLayer(markers: myGeoJson.markers)
          ],
        ));

The default [Marker], [Polyline] [CircleMarkers] and [Polygon] creation callback functions can be replaced with user-defined highly customized functions. A good starting point are default callback functions which can be custimized to the needs of the project. The default callback functions have only basic functionality to display the spatial objects on the map. The default callback functions support changing the colors, stroke and fill color and marker icon. All these can be defined in default constructor or via setters. One can also apply a filtering function which returns only spatial features that have certian propertis. The filtering function returns a boolean value. For more details see the example program.

For creating tappable polylines one can use package flutter_map_tappable_polyline.

Categories

Dependencies

Dependency list 2 items

Source repository

Projects using this package