mapbox_gl_dart 0.2.1 copy "mapbox_gl_dart: ^0.2.1" to clipboard
mapbox_gl_dart: ^0.2.1 copied to clipboard

Platformweb

Mapbox-gl wrapper for Dart. Library to use Mapbox GL JS in your web Dart projects.

example/example.dart

import 'dart:convert';
import 'dart:html';

void main() {
  makeRequest();
}

Future<void> makeRequest() async {
  const path = 'examples.json';
  final httpRequest = HttpRequest();
  httpRequest
    ..open('GET', path)
    ..onLoadEnd.listen((e) => requestComplete(httpRequest))
    ..send('');
}

void requestComplete(HttpRequest request) {
  DivElement examples = querySelector('#examples') as DivElement;
  switch (request.status) {
    case 200:
      for (var obj in json.decode(request.responseText!)) {
        AnchorElement link = AnchorElement(href: '${obj['folder']}/index.html');
        link.text = obj['title'];
        link.className = 'list-group-item list-group-item-action';
        examples.children.add(link);
      }
      removeSpinner();
      return;
    default:
      final error = DivElement()
        ..text = 'Request failed, status=${request.status}'
        ..className = 'alert alert-danger';
      examples.children.add(error);
      removeSpinner();
  }
}

void removeSpinner() {
  DivElement spinner = querySelector('#spinner') as DivElement;
  spinner.remove();
}
7
likes
130
pub points
49%
popularity

Publisher

unverified uploader

Mapbox-gl wrapper for Dart. Library to use Mapbox GL JS in your web Dart projects.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

js

More

Packages that depend on mapbox_gl_dart