thai_provinces_geo 0.1.1 copy "thai_provinces_geo: ^0.1.1" to clipboard
thai_provinces_geo: ^0.1.1 copied to clipboard

Offline GPS reverse-geocoding for Thailand: map a latitude/longitude to its province, district and subdistrict. Pure Dart, built on thai_provinces.

example/thai_provinces_geo_example.dart

// Run: dart run example/thai_provinces_geo_example.dart
import 'package:thai_provinces_geo/thai_provinces_geo.dart';

void main() {
  // A few coordinates (lat, lng) — you bring these from any GPS source.
  const points = [
    (13.7512, 100.4923), // Grand Palace, Bangkok
    (18.7880, 98.9850), // central Chiang Mai
    (7.8780, 98.3980), // Phuket town
  ];

  for (final (lat, lng) in points) {
    final match = nearestSubdistrict(lat, lng);
    if (match == null) {
      print('$lat, $lng -> no match');
      continue;
    }
    print('$lat, $lng -> ${match.subdistrict.nameTh}, '
        '${match.district?.nameTh}, ${match.province?.nameTh} '
        '${match.postcode} (~${match.distanceKm.toStringAsFixed(1)} km)');
  }

  // Or just the subdistrict, with an optional max distance:
  final sub = reverseGeocode(13.7512, 100.4923, maxKm: 50);
  print('reverseGeocode -> ${sub?.nameEn} / ${sub?.province?.nameEn}');
}
0
likes
160
points
159
downloads

Documentation

API reference

Publisher

verified publisher10v3n4m.cc

Weekly Downloads

Offline GPS reverse-geocoding for Thailand: map a latitude/longitude to its province, district and subdistrict. Pure Dart, built on thai_provinces.

Repository (GitHub)
View/report issues

Topics

#thailand #geocoding #gps #address #location

License

MIT (license)

Dependencies

thai_provinces

More

Packages that depend on thai_provinces_geo