google_maps 8.1.1 google_maps: ^8.1.1 copied to clipboard
With that package you will be able to use Google Maps JavaScript API from Dart scripts.
To use this library in your code:
-
add a dependency in your
pubspec.yaml
:dependencies: google_maps:
-
add import in your
dart
code:import 'package:google_maps/google_maps.dart';
-
Include the Maps API JavaScript using a
script
tag before your dart script.<script src="https://maps.googleapis.com/maps/api/js?key=API_KEY"></script>
Please see the Google Maps JavaScript API v3 Getting Started guide for information about obtaining an API Key.
A very simple example :
import 'package:google_maps/google_maps.dart';
import 'package:web/web.dart';
void main() {
final mapOptions = MapOptions()
..zoom = 8
..center = LatLng(-34.397, 150.644);
GMap(document.getElementById('map-canvas') as HTMLElement, mapOptions);
}
For other examples take a look at example folder on the repository.