搜索插件、代码仓与 APP 分类

插件详情v1.0.8

flutter_map_geojson

该包解析 GeoJson 格式的空间数据,并使用默认或自定义定义的创建函数生成 Flutter 地图对象数组。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
2430
喜欢数
25
Pub 分数
130

安装插件

flutter pub add flutter_map_geojson

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

flutter_map_geojson 是一个 Dart 包,可解析 GeoJSON 空间数据并将其转换为 Flutter Map 兼容的对象。它支持默认和自定义创建函数,使开发者能够无缝地将地理数据集成到其 Flutter 应用程序中。该包可在 Android、iOS、Web、macOS、Windows 和 Linux 等所有主要平台上运行,非常适合跨平台地理空间可视化。它通过简化真实世界地理数据集的集成,增强了 flutter_map 的功能。

适合场景

  • 在移动应用中集成 GeoJSON 地图
  • 在网页上可视化地理数据
  • 从 GeoJSON 渲染自定义地图图层
  • 构建基于位置的仪表板
  • 从 API 显示空间数据
  • 创建具有动态功能的交互式地图

主要特点

  • 支持 GeoJSON 解析
  • 可自定义的对象创建
  • 跨平台兼容性
  • 与 flutter_map 兼容
  • 通过 pub 实现轻松集成
  • 可扩展以支持自定义几何形状

适合对象

  • 使用 flutter_map 的开发者
  • 需要 GeoJSON 支持的应用程序
  • 跨平台地图应用
  • 地理空间数据可视化
  • 后端驱动的地图内容

使用建议

  • 需要安装 flutter_map
  • 自定义创作者需要实现
  • 大型 GeoJSON 文件可能会影响性能
  • 仅限 flutter_map 支持的几何类型
  • 除了提供的函数外,没有内置的样式选项

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

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.

所属分类

依赖

依赖清单 2 项

源码仓库

使用此插件的项目