bd_offline_geocoder 0.1.2
bd_offline_geocoder: ^0.1.2 copied to clipboard
Offline reverse geocoder for Bangladesh. Convert GPS coordinates to division, district, upazila, union, and ward without Google Maps or any network call.
bd_offline_geocoder #
Offline Bangladesh reverse geocoder for Flutter.
GPS → Bangladesh address parts: house, road, area/village, union/ward, thana/upazila, district, division, postal code, city.
No API key. No network. Same data as Python and npm.
Keywords: Bangladesh geocoder, Flutter offline location, GPS to upazila, ward, thana, Dhaka street.
final geocoder = await BdOfflineGeocoder.fromBundledAssets();
final result = geocoder.reverse(latitude: 23.74015, longitude: 90.38286);
print(result.formatted);
// House 3, Road 3, Dhanmondi, Ward No-49, Dhanmondi Thana, Dhaka 1209, Bangladesh
print(result.toJson());
Features #
- Offline after install — no Maps SDK
- Bundled ADM1–ADM4 GeoJSON
- Dhaka named roads + house-number points (OSM)
Polygon/MultiPolygonwith holes- Bounding-box filter, then ray-casting
fromBundledAssets()loads layers in parallel- Web-safe:
fromFileis stubbed; use assets orfromString
Install #
dependencies:
bd_offline_geocoder: ^0.1.1
flutter pub add bd_offline_geocoder
Dart 3.4+ · Flutter 3.16+. Archive is large because the full boundary set is included.
Load the geocoder once (initState, Riverpod, GetIt) and reuse it.
Usage #
import 'package:bd_offline_geocoder/bd_offline_geocoder.dart';
final geocoder = await BdOfflineGeocoder.fromBundledAssets();
final result = geocoder.reverse(latitude: 23.74015, longitude: 90.38286);
result.houseNumber; // 3
result.roadNumber; // 3
result.roadName;
result.areaVillage; // Dhanmondi
result.unionWard; // Ward No-49
result.thanaUpazila; // Dhanmondi Thana
result.district; // Dhaka
result.division; // Dhaka
result.postalCode; // 1209
result.city; // Dhaka
result.toJson();
Outside Bangladesh: found == false and
This geocoder only supports locations inside Bangladesh.
Dart CLI / files #
final divisions = await GeoJsonBoundarySource.fromFile(
'assets/boundaries/bgd_admin1.geojson',
id: 'divisions',
type: GeocoderLayerType.division,
namePropertyCandidates: ['adm1_name'],
);
final geocoder = BdOfflineGeocoder(layers: [divisions]);
On web, fromFile throws. Use fromBundledAssets() or fromString.
Example app #
https://github.com/TasfiqulGhani/bd-offline-geocoder/tree/main/examples/flutter_app
cd examples/flutter_app && flutter pub get && flutter run
Limits #
- Nationwide: administrative polygons (ADM4 simplified).
- Road / house: central Dhaka OSM only; house numbers are sparse.
Links #
Author: Tasfiqul Ghani. MIT code; see notices.