Flutter plugin for forward and reverse geocoding

Overview

geocoder

Forward and reverse geocoding.

Usage

Import package:geocoder/geocoder.dart, and use the Geocoder.local to access geocoding services provided by the device system.

Example:

import 'package:geocoder/geocoder.dart';

// From a query
final query = "1600 Amphiteatre Parkway, Mountain View";
var addresses = await Geocoder.local.findAddressesFromQuery(query);
var first = addresses.first;
print("${first.featureName} : ${first.coordinates}");

// From coordinates
final coordinates = new Coordinates(1.10, 45.50);
addresses = await Geocoder.local.findAddressesFromCoordinates(coordinates);
first = addresses.first;
print("${first.featureName} : ${first.addressLine}");

You can alternatively use Geocoder.google member for requesting distant data from google services instead of native ones.

You will find links to the API docs on the pub page.

Getting Started

For help getting started with Flutter, view our online documentation.

For help on editing plugin code, view the documentation.

Comments
  • JavaRuntimeException

    JavaRuntimeException

    The line marked with asterik seems to be caused because of the geocoder plugin when used with flutter_google_places plugin

    Restarted application in 2,320ms.
    W/ResourceType(12219): No package identifier when getting name for resource number 0x00000000
    I/Google Maps Android API(12219): Google Play services package version: 17455021
    I/art     (12219): Do full code cache collection, code=506KB, data=486KB
    I/art     (12219): After code cache collection, code=490KB, data=447KB
    W/ResourceType(12219): No package identifier when getting name for resource number 0x00000000
    W/ResourceType(12219): No package identifier when getting name for resource number 0x00000000
    E/AndroidRuntime(12219): FATAL EXCEPTION: AsyncTask #2
    E/AndroidRuntime(12219): Process: com.example.memories, PID: 12219
    E/AndroidRuntime(12219): java.lang.RuntimeException: An error occurred while executing doInBackground()
    E/AndroidRuntime(12219): 	at android.os.AsyncTask$3.done(AsyncTask.java:318)
    E/AndroidRuntime(12219): 	at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
    E/AndroidRuntime(12219): 	at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
    E/AndroidRuntime(12219): 	at java.util.concurrent.FutureTask.run(FutureTask.java:242)
    E/AndroidRuntime(12219): 	at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:243)
    E/AndroidRuntime(12219): 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
    E/AndroidRuntime(12219): 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
    E/AndroidRuntime(12219): 	at java.lang.Thread.run(Thread.java:760)
    **E/AndroidRuntime(12219): Caused by: java.lang.RuntimeException: Methods marked with @UiThread must be executed on the main thread. Current thread: AsyncTask #2 **
    E/AndroidRuntime(12219): 	at io.flutter.embedding.engine.FlutterJNI.ensureRunningOnMainThread(FlutterJNI.java:605)
    E/AndroidRuntime(12219): 	at io.flutter.embedding.engine.FlutterJNI.invokePlatformMessageResponseCallback(FlutterJNI.java:556)
    E/AndroidRuntime(12219): 	at io.flutter.embedding.engine.dart.DartMessenger$Reply.reply(DartMessenger.java:131)
    E/AndroidRuntime(12219): 	at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler$1.success(MethodChannel.java:225)
    E/AndroidRuntime(12219): 	at com.aloisdeniel.geocoder.GeocoderPlugin$1.doInBackground(GeocoderPlugin.java:79)
    E/AndroidRuntime(12219): 	at com.aloisdeniel.geocoder.GeocoderPlugin$1.doInBackground(GeocoderPlugin.java:72)
    E/AndroidRuntime(12219): 	at android.os.AsyncTask$2.call(AsyncTask.java:304)
    E/AndroidRuntime(12219): 	at java.util.concurrent.FutureTask.run(FutureTask.java:237)
    E/AndroidRuntime(12219): 	... 4 more
    I/Process (12219): Sending signal. PID: 12219 SIG: 9
    Lost connection to device.
    Exited (sigterm)
    
    opened by pratik037 14
  • Calling function findAddressesFromCoordinates() throws MissingPluginException

    Calling function findAddressesFromCoordinates() throws MissingPluginException

    I came across this plugin to satisfy my need of getting a formatted address for my geo coordinates. Included package in my YAML file and wrote the sample code sending sample but authentic coordinates and I was given the following error when calling the function findAddressesFromCoordinates()

    MissingPluginException(No implementation found for method findAddressesFromCoordinates on channel github.com/aloisdeniel/geocoder) #0 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:278:7) E/flutter ( 9718): <asynchronous suspension> E/flutter ( 9718): #1 LocalGeocoding.findAddressesFromCoordinates (package:geocoder/services/local.dart:13:41) E/flutter ( 9718): <asynchronous suspension>

    I stopped debugging, and fresh started, but to no avail. Help!

    bug 
    opened by vijaykanta 12
  • Migration to AndroidX, add support for language in GoogleGeocoding and fix issue with @UiThread

    Migration to AndroidX, add support for language in GoogleGeocoding and fix issue with @UiThread

    Hello, I am migrating the code of my application to AndroidX, so this is a proposal for migration to AndroidX for flutter_geocoder. (https://github.com/aloisdeniel/flutter_geocoder/issues/14) I also removed buildToolsVersion, we don't need it anymore.

    Edit : I also propose the following changes:

    • add support for language in GoogleGeocoding
    • fix issue with "Methods marked with @UiThread must be executed on the main thread" (to support the latest flutter engine version, at least the version 1.6.0 of Flutter). I mean this allows to fix the issue https://github.com/aloisdeniel/flutter_geocoder/issues/18
    opened by Eimji 8
  • Not working on newer devices

    Not working on newer devices

    Hello, I'm using geocoder: ^0.2.1 this plugin. This is working fine on lower version devices but not working on the above version 9.0 devices. Please let me know the solution.

    opened by aTeamSolace 7
  • Geocoder.google not working

    Geocoder.google not working

    Hi, I have enable the Geocoding api on Google Cloud Platform in order to use it over Geocoder.Google. It looks everything working on the Google side but when i try to bring the data it shows error and doesn't return anything.

    ` final coordinates = new Coordinates(-12.0785151, -77.0557978);

    var addresses =
        await Geocoder.google(apikey)
            .findAddressesFromCoordinates(coordinates);
    var ad = addresses.first;
    print(ad.toMap());`
    

    I got this on my terminal

    Performing hot restart...
    Restarted application in 1,037ms. flutter: distrito [VERBOSE-2:ui_dart_state.cc(144)] Unhandled Exception: Bad state: No element #0 List.first (dart:core-patch/growable_array.dart:220:5) #1 _MyHomePageState.getDistrict (package:google_maps/main.dart:38:24) #2 _MyHomePageState.initState (package:google_maps/main.dart:54:5) #3 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4085:58) #4 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3936:5) #5 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3109:14) #6 Element.updateChild (package:flutter/src/widgets/framework.dart:2903:12) #7 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5165:14) #8 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3109:14) #9 Element.updateChild (package:flutter/src/widgets/framework.dart:2903:12) #10 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3978:16) #11 Ele<…> [C3.1 BF945B7C-A3F8-43B8-9922-CE812241D441 192.168.1.16:53918<->172.217.8.78:443] Connected Path: satisfied (Path is satisfied), interface: en0 Duration: 68.995s, DNS @0.000s took 1.039s, TCP @1.041s took 0.072s, TLS took 0.179s bytes in/out: 4659/1725, packets in/out: 14/12, rtt: 0.074s, retransmitted packets: 0, out-of-order packets: 0 [C4.1 C628BB9C-C2AF-4FFB-ADDB-57DCE7EE6F35 192.168.1.16:54192<->172.217.8.138:443] Connected Path: satisfied (Path is satisfied), interface: en0 Duration: 0.404s, DNS @0.000s took 0.019s, TCP @0.021s took 0.081s, TLS took 0.196s bytes in/out: 4844/1475, packets in/out: 10/9, rtt: 0.078s, retransmitted packets: 0, out-of-order packets: 0

    image

    opened by gabxap 7
  • flutter 1.7.8+hotfix.3 on stable channel | geocoder: 0.1.2

    flutter 1.7.8+hotfix.3 on stable channel | geocoder: 0.1.2

    I have updated flutter 1.7.8+hotfix.3 on stable channel

    Caused by: java.lang.RuntimeException: Methods marked with @UiThread must be executed on the main thread. Current thread: AsyncTask #2 E/AndroidRuntime(10984): at io.flutter.embedding.engine.FlutterJNI.ensureRunningOnMainThread(FlutterJNI.java:794) E/AndroidRuntime(10984): at io.flutter.embedding.engine.FlutterJNI.invokePlatformMessageResponseCallback(FlutterJNI.java:727) E/AndroidRuntime(10984): at io.flutter.embedding.engine.dart.DartMessenger$Reply.reply(DartMessenger.java:140) E/AndroidRuntime(10984): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler$1.success(MethodChannel.java:225) E/AndroidRuntime(10984): at com.aloisdeniel.geocoder.GeocoderPlugin$1.doInBackground(GeocoderPlugin.java:79) E/AndroidRuntime(10984): at com.aloisdeniel.geocoder.GeocoderPlugin$1.doInBackground(GeocoderPlugin.java:72) E/AndroidRuntime(10984): at android.os.AsyncTask$2.call(AsyncTask.java:333) E/AndroidRuntime(10984): at java.util.concurrent.FutureTask.run(FutureTask.java:266) E/AndroidRuntime(10984): ... 4 more

    How to fix this issue

    Thanks

    opened by ghost 6
  • PostalCode issue

    PostalCode issue

    Receiving null for postal code on Android devices. Works fine on IOS devices. The postal code shows in the address line but not when calling it on its own in Android.

    bug 
    opened by rlee1990 6
  • Throws exception when trying to run   Geocoder.local.findAddressesFromCoordinates(coordinates) only on Android

    Throws exception when trying to run Geocoder.local.findAddressesFromCoordinates(coordinates) only on Android

    E/AndroidRuntime(20142): java.lang.RuntimeException: An error occurred while executing doInBackground() E/AndroidRuntime(20142): at android.os.AsyncTask$3.done(AsyncTask.java:354) E/AndroidRuntime(20142): at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383) E/AndroidRuntime(20142): at java.util.concurrent.FutureTask.setException(FutureTask.java:252) E/AndroidRuntime(20142): at java.util.concurrent.FutureTask.run(FutureTask.java:271) E/AndroidRuntime(20142): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245) E/AndroidRuntime(20142): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) E/AndroidRuntime(20142): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) E/AndroidRuntime(20142): at java.lang.Thread.run(Thread.java:764) E/AndroidRuntime(20142): Caused by: java.lang.RuntimeException: Methods marked with @UiThread must be executed on the main thread. Current thread: AsyncTask #2 E/AndroidRuntime(20142): at io.flutter.embedding.engine.FlutterJNI.ensureRunningOnMainThread(FlutterJNI.java:794) E/AndroidRuntime(20142): at io.flutter.embedding.engine.FlutterJNI.invokePlatformMessageResponseCallback(FlutterJNI.java:727) E/AndroidRuntime(20142): at io.flutter.embedding.engine.dart.DartMessenger$Reply.reply(DartMessenger.java:140) E/AndroidRuntime(20142): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler$1.success(MethodChannel.java:225) E/AndroidRuntime(20142): at com.aloisdeniel.geocoder.GeocoderPlugin$2.doInBackground(GeocoderPlugin.java:109) E/AndroidRuntime(20142): at com.aloisdeniel.geocoder.GeocoderPlugin$2.doInBackground(GeocoderPlugin.java:102) E/AndroidRuntime(20142): at android.os.AsyncTask$2.call(AsyncTask.java:333) E/AndroidRuntime(20142): at java.util.concurrent.FutureTask.run(FutureTask.java:266) E/AndroidRuntime(20142): ... 4 more D/EGL_emulation(20142): eglMakeCurrent: 0xe8be2640: ver 3 0 (tinfo 0xe4c682b0) E/BufferQueueProducer(20142): [SurfaceTexture-0-20142-0] setAsyncMode: BufferQueue has been abandoned E/BufferQueueProducer(20142): [SurfaceTexture-0-20142-0] queueBuffer: BufferQueue has been abandoned E/BufferQueueProducer(20142): [SurfaceTexture-0-20142-0] dequeueBuffer: BufferQueue has been abandoned E/BufferQueueProducer(20142): [SurfaceTexture-0-20142-0] setAsyncMode: BufferQueue has been abandoned W/System (20142): A resource failed to call release.

    opened by spiderion 5
  • Runtime exception from flutter v 1.5

    Runtime exception from flutter v 1.5

    Encountering a fatal runtime exception after upgrading flutter to version 1.5, resulting in crash of app.

    java.lang.RuntimeException: An error occurred while executing doInBackground()
    E/AndroidRuntime(11970): 	at android.os.AsyncTask$3.done(AsyncTask.java:353)
    E/AndroidRuntime(11970): 	at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383)
    E/AndroidRuntime(11970): 	at java.util.concurrent.FutureTask.setException(FutureTask.java:252)
    E/AndroidRuntime(11970): 	at java.util.concurrent.FutureTask.run(FutureTask.java:271)
    E/AndroidRuntime(11970): 	at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245)
    E/AndroidRuntime(11970): 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
    E/AndroidRuntime(11970): 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
    E/AndroidRuntime(11970): 	at java.lang.Thread.run(Thread.java:764)
    E/AndroidRuntime(11970): Caused by: java.lang.RuntimeException: Methods marked with @UiThread must be executed on the main thread. Current thread: AsyncTask #2
    E/AndroidRuntime(11970): 	at io.flutter.embedding.engine.FlutterJNI.ensureRunningOnMainThread(FlutterJNI.java:605)
    E/AndroidRuntime(11970): 	at io.flutter.embedding.engine.FlutterJNI.invokePlatformMessageResponseCallback(FlutterJNI.java:556)
    E/AndroidRuntime(11970): 	at io.flutter.embedding.engine.dart.DartMessenger$Reply.reply(DartMessenger.java:129)
    E/AndroidRuntime(11970): 	at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler$1.success(MethodChannel.java:215)
    E/AndroidRuntime(11970): 	at com.aloisdeniel.geocoder.GeocoderPlugin$2.doInBackground(GeocoderPlugin.java:113)
    E/AndroidRuntime(11970): 	at com.aloisdeniel.geocoder.GeocoderPlugin$2.doInBackground(GeocoderPlugin.java:106)
    E/AndroidRuntime(11970): 	at android.os.AsyncTask$2.call(AsyncTask.java:333)
    E/AndroidRuntime(11970): 	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    E/AndroidRuntime(11970): 	... 4 more
    
    opened by harshapulikollu 5
  • Find Address From Query only gets one address

    Find Address From Query only gets one address

    Hi, Thanks for creating the useful library.

    I am currently trying to implement a method to get possible addresses from a string.

    Everything works as expected but i've noticed that 99% the findAddressesFromQuery function returns one address hit only. I've tried using broad queries to test it such as searching an area with multiple similar results but had no luck reproducing the expected results.

    Ex: UAE Abu Dhabi Batten Embassy (An area with 20+ embassies but I only get one hit)

    Google maps search:

    Screenshot 2021-02-12 at 15 16 20

    function used:

    String query = "UAE Abu Dhabi Batten Embassy";
    var addresses = await Geocoder.local.findAddressesFromQuery(query);
    

    I was hoping someone could give me pointers on how to get the desired results.

    Thanks,

    opened by madatr 4
  • Prepare for Uint8List SDK breaking change

    Prepare for Uint8List SDK breaking change

    A recent change to the Dart SDK updated HttpClientResponse to implement Stream<Uint8List> rather than implementing Stream<List<int>>.

    This forwards-compatible change updates calls to Stream.transform(StreamTransformer) to instead call the functionally equivalent StreamTransformer.bind(Stream) API, which puts the stream in a covariant position and thus causes the SDK change to be non-breaking.

    https://github.com/dart-lang/sdk/issues/36900

    opened by tvolkert 4
  • Exception: MissingPluginException(No implementation found for method findAddressesFromCoordinates on channel

    Exception: MissingPluginException(No implementation found for method findAddressesFromCoordinates on channel

    Exception: MissingPluginException(No implementation found for method findAddressesFromCoordinates on channel

    Dear team please help me this error in my ios and location also not runing

    opened by GouRav404 0
  • `flutter_geocoder` uses a deprecated version of the Android embedding.

    `flutter_geocoder` uses a deprecated version of the Android embedding.

    The plugin flutter_geocoder uses a deprecated version of the Android embedding. To avoid unexpected runtime failures, or future build failures, try to see if this plugin supports the Android V2 embedding. Otherwise, consider removing it since a future release of Flutter will remove these deprecated APIs.

    opened by KarimAbdo 5
  • Upgraded to new Android plugin APIs.

    Upgraded to new Android plugin APIs.

    I modified the package to use the new Android plugin APIs. I haven't tested on iOS, but apart from the pubspec, all the changes are for Android.

    I know you don't have much time at the moment, but would be great if you could update the repo as it gives warnings when building for Android.

    Thanks, Brent Kleineibst.

    opened by abisoft11 3
  • flutter_geocoder has been deprecated, need to update as per latest flutter version

    flutter_geocoder has been deprecated, need to update as per latest flutter version

    Getting below error in console panel:

    The plugins `flutter_geocoder` use a deprecated version of the Android embedding.
    To avoid unexpected runtime failures, or future build failures, try to see if these plugins support the Android V2 embedding. Otherwise, consider removing them since a future release of Flutter will remove these deprecated APIs.
    

    Need to update flutter_geocoder plugin as per latest flutter version. Thanks.

    opened by kamleshwebtech 19
Owner
Aloïs Deniel
Flutter & Firebase Consultant
Aloïs Deniel
flutter_map plugin to request and display the users location and heading on the map

The plugin is discontinued. Feel free to fork it or checkout similar plugins. Flutter Map – Location plugin A flutter_map plugin to request and displa

Fabian Rosenthal 19 Oct 11, 2022
Flutter geolocation plugin for Android and iOS.

geolocation Flutter geolocation plugin for Android API 16+ and iOS 9+. Features: Manual and automatic location permission management Current one-shot

Loup 222 Jan 2, 2023
Android and iOS Geolocation plugin for Flutter

Flutter geolocator plugin The Flutter geolocator plugin is build following the federated plugin architecture. A detailed explanation of the federated

Baseflow 1k Jan 5, 2023
Android and iOS Geolocation plugin for Flutter

Flutter geolocator plugin The Flutter geolocator plugin is build following the federated plugin architecture. A detailed explanation of the federated

Baseflow 891 Nov 14, 2021
A Flutter plugin to easily handle realtime location in iOS and Android. Provides settings for optimizing performance or battery.

Flutter Location Plugin This plugin for Flutter handles getting a location on Android and iOS. It also provides callbacks when the location is changed

Guillaume Bernos 953 Dec 22, 2022
Android and iOS Geolocation plugin for Flutter

Flutter geolocator plugin The Flutter geolocator plugin is build following the federated plugin architecture. A detailed explanation of the federated

Baseflow 1k Dec 27, 2022
A Flutter plugin for integrating Google Maps in iOS, Android and Web applications

flutter_google_maps A Flutter plugin for integrating Google Maps in iOS, Android and Web applications. It is a wrapper of google_maps_flutter for Mobi

MarchDev Toolkit 86 Sep 26, 2022
A new flutter plugin for mapbox. You can use it for your map backgrounds inside flutter applications

A new flutter plugin for mapbox. You can use it for your map backgrounds inside flutter applications

Boris Gautier 5 Sep 14, 2022
A flutter plugin for Google Maps

IMPORTANT: This plugin is no longer under development Why? We initially built this plugin to fill an early gap in flutter. Since then, Google has made

AppTree Software, Inc 415 Dec 29, 2022
Flutter plugin to display a simple flat world map with animated points in real time

Flutter Simple Map Flutter plugin to display a simple flat world map with animated points in real time. Can be used as a presentation of online users,

Vladyslav Korniienko 7 Dec 8, 2022
Apple Maps Plugin for Flutter

apple_maps_flutter A Flutter plugin that provides an Apple Maps widget. The plugin relies on Flutter's mechanism for embedding Android and iOS views.

Luis Thein 50 Dec 31, 2022
Flutter plugin for launching maps

Map Launcher Map Launcher is a flutter plugin to find available maps installed on a device and launch them with a marker or show directions. Marker Na

Alex Miller 189 Dec 20, 2022
A Flutter plugin for appodeal

flutter_appodeal A Flutter plugin for iOS and Android to use Appodeal SDK in your apps Getting Started For help getting started with Flutter, view our

null 14 Feb 19, 2022
A flutter plugin that's decodes encoded google poly line string into list of geo-coordinates suitable for showing route/polyline on maps

flutter_polyline_points A flutter plugin that decodes encoded google polyline string into list of geo-coordinates suitable for showing route/polyline

Adeyemo Adedamola 75 Oct 25, 2022
OpenStreetMap plugin for flutter

flutter_osm_plugin Platform Support Android iOS Web supported ✔️ supported ✔️ (min iOS supported : 12) under-development osm plugin for flutter apps c

hamza mohamed ali 125 Dec 30, 2022
A Flutter plugin which provides 'Picking Place' using Google Maps widget

Google Maps Places Picker Refractored This is a forked version of google_maps_place_picker package, with added custom styling and features.

Varun 5 Nov 13, 2022
A plugin that offers widgets for Wear OS by Google

Flutter Wear Plugin A plugin that offers Flutter support for Wear OS by Google (Android Wear). To use this plugin you must set your minSdkVersion to 2

Flutter Community 114 Dec 18, 2022
Plugin for 'flutter_map' providing advanced caching functionality, with ability to download map regions for offline use. Also includes useful prebuilt widgets.

flutter_map_tile_caching A plugin for the flutter_map library to provide an easy way to cache tiles and download map regions for offline use. Installa

Luka S 69 Jan 3, 2023
Flutter_map plugin to display geojson, vector tiles, clusters using sliced vectors

geojson_vector_slicer A flutter_map plugin to display fast geojson by slicing into tiles. Slicing based off https://github.com/mapbox/geojson-vt IMPOR

Ian 4 Oct 18, 2022