mapbox_geocoding 0.1.3 copy "mapbox_geocoding: ^0.1.3" to clipboard
mapbox_geocoding: ^0.1.3 copied to clipboard

Mapbox Geocoding API library in order to make forward and reverse geocoding.

Pub

Dart Mapbox Geocoding API (not official) #

A Flutter package Mapbox Geocoding API. Package is not official product of mapbox.

This project is a library to use Mapbox Geocoding API from dart scripts.

Table of Contents #

Documentation #

Library documentation is here.

Usage #

To use this library in your code:

  • add a dependency in your pubspec.yaml :

    dependencies:
      mapbox_geocoding: "^last_version"
    
  • add import in your dart code:

    import 'package:mapbox_geocoding/mapbox_geocoding.dart';
    

Please create/use Mapbox account to obtain Mapbox access token.

If you have Mapbox account, you can reach access token from Mapbox account dashboard.

A very simple example :

import 'package:mapbox_geocoding/mapbox_geocoding.dart';
import 'package:mapbox_geocoding/model/forward_geocoding.dart';

MapboxGeocoding geocoding = MapboxGeocoding('YOUR_ACCESS_TOKEN');

///Forward geocoding. Get latitude and longitude from place name.
getCoordinates(String city) async {
    try {
        ForwardGeocoding forwardModel = await geocoding.forwardModel(city);
        return forwardModel.features[0].center;
    } catch (Excepetion) {
        return 'Forward Geocoding Error';
    }
}
///Reverse geocoding. Get place name from latitude and longitude.
getCity(double lat, double lng, String apiKey) async {
    try {
        ReverseGeocoding reverseModel = await geocoding.reverseModel(lat, lng);
        return reverseModel.features[0].placeName;
    } catch (Excepetion) {
        return 'Reverse Geocoding Error';
    }
}

License #

MIT

8
likes
40
points
53
downloads

Publisher

unverified uploader

Weekly Downloads

Mapbox Geocoding API library in order to make forward and reverse geocoding.

Repository (GitHub)

License

MIT (license)

Dependencies

http

More

Packages that depend on mapbox_geocoding