dart_mapbox_search 2.0.0 copy "dart_mapbox_search: ^2.0.0" to clipboard
dart_mapbox_search: ^2.0.0 copied to clipboard

A production-ready Dart SDK for the Mapbox Search Box, Geocoding, and Places APIs.

example/main.dart

import 'dart:io';

import 'package:dart_mapbox_search/dart_mapbox_search.dart';

/// Runs a one-off Search Box query using `MAPBOX_ACCESS_TOKEN`.
Future<void> main() async {
  final String? accessToken = Platform.environment['MAPBOX_ACCESS_TOKEN'];
  if (accessToken == null || accessToken.isEmpty) {
    stderr.writeln('Set MAPBOX_ACCESS_TOKEN before running this example.');
    exitCode = 64;
    return;
  }

  final MapboxSearch mapbox = MapboxSearch(accessToken: accessToken);
  try {
    final MapboxResponse<SearchBoxFeatureCollection> response = await mapbox
        .searchBox
        .forward(
          'coffee',
          options: SearchBoxForwardOptions(
            proximity: MapboxCoordinateProximity(
              MapboxPoint(longitude: 13.405, latitude: 52.52),
            ),
            limit: 5,
          ),
        );
    for (final SearchBoxFeature feature in response.data.features) {
      stdout.writeln('${feature.properties.name}: ${feature.geometry.point}');
    }
  } on MapboxApiException catch (error) {
    stderr.writeln(
      'Mapbox rejected the request: ${error.message} '
      '(request ${error.requestId ?? 'unknown'}).',
    );
  } finally {
    mapbox.close();
  }
}
1
likes
160
points
30
downloads

Documentation

API reference

Publisher

verified publishercoderave.dev

Weekly Downloads

A production-ready Dart SDK for the Mapbox Search Box, Geocoding, and Places APIs.

Repository (GitHub)
View/report issues
Contributing

Topics

#mapbox #search #geocoding #places #sdk

License

GPL-3.0 (license)

Dependencies

http, uuid

More

Packages that depend on dart_mapbox_search