mapbox_gl_dart 0.1.0

Mapbox-gl wrapper for Dart #

Library to use Mapbox GL JS from Dart. Working examples here: https://andrea689.github.io/mapbox-gl-dart/

Using this package #

You must include Mapbox GL JS into your .html file to be able to use this package.

<script src='https://api.tiles.mapbox.com/mapbox-gl-js/v1.5.0/mapbox-gl.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v1.5.0/mapbox-gl.css' rel='stylesheet'/>

In the body add a container for the map.

<body>
    <div id='map'></div>
</body>

In the dart file initialize the map.

import 'package:mapbox_gl_dart/mapbox_gl_dart.dart' as mapboxgl;

void main() {
  Mapbox.accessToken = 'YOUR_TOKEN_HERE';

  var map = MapboxMap(
    MapOptions(
      container: 'map',
      style: 'mapbox://styles/mapbox/dark-v10',
      center: LngLat(7.68227, 45.06755),
      zoom: 12,
    ),
  );
}

Examples #

You can find many examples in the example folder.

Run example #

webdev serve example:8081

Open browser to localhost:8081

Changelog #

0.1.0 (2020-02-11) #

  • First public version.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  mapbox_gl_dart: ^0.1.0

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:mapbox_gl_dart/mapbox_gl_dart.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
75
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
80
Overall:
Weighted score of the above. [more]
39
Learn more about scoring.

We analyzed this package on Feb 11, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.5

Health suggestions

Fix lib/src/interop/style/layers/symbol_layer_interop.dart. (-24.47 points)

Analysis of lib/src/interop/style/layers/symbol_layer_interop.dart reported 56 hints, including:

line 16 col 7: DO use curly braces for all flow control structures.

line 20 col 7: DO use curly braces for all flow control structures.

line 36 col 7: DO use curly braces for all flow control structures.

line 38 col 7: DO use curly braces for all flow control structures.

line 40 col 7: DO use curly braces for all flow control structures.

Fix lib/src/interop/style/layers/line_layer_interop.dart. (-6.78 points)

Analysis of lib/src/interop/style/layers/line_layer_interop.dart reported 14 hints, including:

line 15 col 7: DO use curly braces for all flow control structures.

line 18 col 7: DO use curly braces for all flow control structures.

line 32 col 7: DO use curly braces for all flow control structures.

line 35 col 7: DO use curly braces for all flow control structures.

line 37 col 7: DO use curly braces for all flow control structures.

Fix lib/src/interop/style/layers/circle_layer_interop.dart. (-1.99 points)

Analysis of lib/src/interop/style/layers/circle_layer_interop.dart reported 4 hints:

line 15 col 7: DO use curly braces for all flow control structures.

line 19 col 7: DO use curly braces for all flow control structures.

line 31 col 7: DO use curly braces for all flow control structures.

line 33 col 7: DO use curly braces for all flow control structures.

Fix lib/src/style/sources/vector_source.dart. (-0.50 points)

Analysis of lib/src/style/sources/vector_source.dart reported 1 hint:

line 15 col 7: DO use curly braces for all flow control structures.

Fix lib/src/ui/popup.dart. (-0.50 points)

Analysis of lib/src/ui/popup.dart reported 1 hint:

line 58 col 7: DO use curly braces for all flow control structures.

Maintenance suggestions

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.7.0-dev <3.0.0
js ^0.6.1 0.6.1+1
meta ^1.1.8 1.1.8
Dev dependencies
build_runner >=1.6.2 <2.0.0
build_web_compilers >=2.0.0 <3.0.0