搜尋套件、儲存庫與 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 項

原始碼儲存庫

使用此套件的專案