Git Product home page Git Product logo

geocode's Introduction

Geocode library

workflow name likes popularity pub points

Introduction

Package to make Geocode requests. It exposes two methods to translate coordinates into locations and addresses into coordinates.

It's a basic implementation of the most useful methods in the Dart language of the following API geocode.xyz.

It's free for one request per second quota. Register in the above site to get an API Key and increase the number of requests to 10 per second. These are paid plans that allow more requests per second. For more information, review the site.

Installation

dependecies:
  geocode: 1.0.3

Example

See example/main.dart

import 'package:geocode/geocode.dart';

void main() async {
  GeoCode geoCode = GeoCode();

  try {
    Coordinates coordinates = await geoCode.forwardGeocoding(
        address: "532 S Olive St, Los Angeles, CA 90013");

    print("Latitude: ${coordinates.latitude}");
    print("Longitude: ${coordinates.longitude}");
  } catch (e) {
    print(e);
  }
}

Methods

Constructor

Library GeoCode class constructor, includes an optional parameter to set the apiKey.

GeoCode({this.apiKey});

Reverse Geocode

Method to translate a pair of latitude and longitude coordinates into a real address.

Future<Address> reverseGeocoding({double latitude, double longitude})

Forward Geocode

Method to translate an address into a pair of latitude and longitudecoordinates.

Future<Coordinates> forwardGeocoding({String address})

Responses

Reverse Geocode

Attribute Type Description
elevation double The elevation in meters.
timezone String The timezone.
geoNumber int geocode is an alphanumeric string representing both latitude and longitude as one value. Nearby points will have similar geocodes.
streetNumber int The properly formated street address number to be returned.
streetAddress String The properly formated street address to be returned.
city String The properly formated city name to be returned.
countyCode String The properly formated country code to be returned.
countryName String The properly formated country name to be returned.
region String The properly formated region to be returned.
postal String The properly formated postal code to be returned.
distance double The distance of the result location from the input location.

Forward Geocode

Attribute Type Description
latitude double Latitude coordinate value.
longitude double Longitude coordinate value.

Exceptions

  • AccountOutOfCreditsException: auth has ran out of credits.
  • AuthTokenNotFoundException: authentication token: auth not found.
  • PostalCodeFormatException: postal Code is not in the proper Format.
  • RequestThrottledException: request Throttled.
  • InvalidQueryException: supply a valid query.
  • EmptyResultException: your request did not produce any results. Check your spelling and try again.
  • UnknownErrorException: unkown error.

Dependencies

http: '>=0.13.0 <2.0.0'

License

BSD 3-Clause License

geocode's People

Contributors

ahaaje avatar imvalient avatar uzzero avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

geocode's Issues

Custom user agent fails when running as a web application

The code in geocode_client.dart sets a custom User-Agent value of geocode (dart:io). I believe this was done to avoid [issues with requests being blocked by geocode.xyz])(#20).

When I build and run a web application using this package, an error occurs since Chrome won't send a custom User-Agent as part of an XMLHttpRequest call. Therefore, inside a web app, I believe calls to perform geocoding always fail.

Am I correct that the User-Agent header is needed to make the request be accepted by geocode.xyz? And if so, is there a work around to allow a web application to work?

Address search accuracy/confidence

Hi guys ! First of all, thank you very much to those who contributed to this package, it's really easy to use and a great way to get geocode working for the web or any platform !

I was wondering if maybe there could be a way to deal with the accuracy issues of https://geocode.xyz/, or if any developer had come out with an idea to prevent problematics such as mine : if I type, for example, "20 boulevard du Roi René, Aix-En-Provence" it finds the address properly, but if I type "20 boulevard du Roi René, Aix En Provence" (without the dashes), it takes me to a city in Thailand.

I don't know what the best solution could be, but maybe having access to the Confidence Score could already be a good start ? Or be able to change the "region" parameter (apparently it's possible to constraint the search to an area/country, but I'm not sure it's a free feature), what do you think ?

Thank you :)

PS: I'm a noob so I apologise in advance if some parts of my question sound senseless

fordwardGeocoding is returning the wrong coordinates

var coordinates = await geoCode.forwardGeocoding(address: prediction.description);

This line is returning 20.6847, -103.2189

The correct coordinates are 20.686010, -103.423210

This is an example but most of the addresses I'm trying return the wrong coordinates. What am I doing wrong? This used to work fine.

Unknown error

I get this error output,

flutter: [Error]: (-1) Unknown error. Try again.

What do i do please

Locale Identifier

The issue is, I'm receiving coordinates from a completely different country.
is there a way to specify the locale identifier?

geoCode.forwardGeocoding(address: street, locale: "nl_NL")

or

geoCode.reverseGeocoding(latitude: latitude, longitude: longitude, locale: "nl_NL");

Thanks in advance for any help

type '_InternalLinkedHashMap<String, dynamic>' is not a subtype of type 'String'

Hi, I was trying your library and ran into this error. I am not able to extract the data from reverseGeocoding if I try like this:

try{
      Address newAddress = await GeoCode().reverseGeocoding(latitude: latitude, longitude: longitude);
      print(newAddress.city);
    } catch (e) {
      print(e);
    }

Error : type '_InternalLinkedHashMap<String, dynamic>' is not a subtype of type 'String'

Request Throttled Issue

GeoCode(apiKey: kGoogleApiKey)
I added google map apikey but it shows

Unhandled Exception: [Error]: (006) Request Throttled. Over Rate limit: up to 2 per sec. See geocode.xyz/pricing

please help

forwardGeocoding does not work from iOS app

Description

  • I have created a flutter app and recents the forwardGeocoding function has stopped working as I would expect.
    • The body of the response received seems to be error code: 1020
    • I found this by setting a breakpoint on line 66 of geocode_client.dart
  • To verify, I am using the exact line of code specified in the pub.dev example, var response = await GeoCode().forwardGeocoding(address: locality);
  • I am not passing in any auth key, as I planned to use the free tier
  • I've found through my own research that running the following GET request does work from the browser, but it does not work when running from a mobile application. I'm not sure if that's pertinent here.

Misc

  • I'm not sure if this issue belongs in this repo, or with the actual owners of geocode.xyz

Request string is malformed

Hi,
I've seen a few instances using this plugin with the authkey sending the wrong GET request to the API.
Namely:
/36.7928505,-3.8995182&auth=authkey?geoit=json
instead of the correct one:
/36.7928505,-3.8995182?auth=authkey&geoit=json

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.