maps 0.5.0 maps: ^0.5.0 copied to clipboard
A cross-platform geographic maps package. Supports Apple MapKit, Bing Maps, and Google Maps. Works in all platforms supported by Flutter, including browsers.
Overview #
Cross-platform geographic maps for Flutter applications.
This is an early version and lots of things are still missing or broken.
Pull requests are welcome! The package is licensed under the Apache License 2.0.
Links #
Getting started #
1.Add dependency #
In pubspec.yaml:
dependencies:
maps: ^0.5.0
Add the following in ios/Runner/Info.plist
:
<key>io.flutter.embedded_views_preview</key>
<true/>
2.Use #
Launching external application? #
MapLauncher launches map applications.
The following implementations are available:
- AppleMapsLauncher launches Apple Maps (native application - the user must have an iOS device)
- BingMapsLauncher launches Bing Maps (website)
- GoogleMapsLauncher launches Google Maps (native application or website)
- MapLauncher.platformSpecific allows you to specify launcher for each operating system.
import 'package:maps/maps.dart';
Future<void> main() async {
// Use default map app
await MapAppLauncher.defaultInstance.launch(
query: 'Paris',
);
}
Rendering a map? #
MapWidget shows a map. It fills all space available to it.
import 'package:flutter/material.dart';
import 'package:maps/maps.dart';
void main() {
// Set default adapter
MapAdapter.defaultInstance = MapAdapter.platformSpecific(
ios: AppleNativeAdapter(),
// Bing Maps iframe API does not necessarily require API credentials
// so we use it in the example.
otherwise: BingMapsIframeAdapter(),
);
// Construct a map widget
const parisMap = MapWidget(
location: MapLocation(
query: 'Paris',
),
markers: [
MapMarker(
query: 'Eiffel Tower',
),
],
);
// Run our example app
runApp(const MaterialApp(
home: Scaffold(
body: SafeArea(
child: parisMap, // Full-screen map of Paris
),
),
));
}
Assuming that you have enabled Flutter for Web, you can run:
flutter run -d chrome
Supported map providers #
Apple Maps APIs #
iOS #
- AppleMapsNativeAdapter enables you to use Apple MapKit. The current implementation depends on the Flutter package apple_maps_flutter, a package by a third-party developer.
- The adapter doesn't require API credentials.
- You need to edit
ios/Runner/Info.plist
.
Javascript #
- AppleMapsJsAdapter enables you to uses Apple MapKit JS.
- The adapter requires you to have API credentials (ECDSA P-256 key pair).
Images #
- AppleMapsStaticAdapter enables you to use Apple Maps Web Snapshots API.
- The adapter requires you to have API credentials (ECDSA P-256 key pair).
Bing Maps APIs #
Javascript #
- BingMapsJsAdapter enables you to use Bing Maps Javascript API.
- The adapter requires an API key, which you can get at Bing Maps API website.
Iframes #
- BingMapsIframeAdapter enables you to uses Bing Maps Custom Map URLs.
- Note that markers and many other features are unsupported by Bing Maps Custom Map URLs.
- The adapter does NOT necessarily require an API key.
Images #
- BingMapsStaticAdapter enables you to uses Bing Maps REST API for static maps.
- The adapter requires an API key, which you can get at Bing Maps API website.
Google Maps APIs #
Android / iOS native SDK #
Use the separate package maps_adapter_google_maps.
Javascript #
- GoogleMapsJsAdapter enables you to use Google Maps Javascript API.
- The adapter requires an API key, which you can get at Google Maps API website.
Iframes #
- GoogleMapsIframeAdapter enables you to use Google Maps Embed API.
- Note that markers and many other features are unsupported by Google Maps Embed API.
- The adapter requires an API key, which you can get at Google Maps API website.
Images #
- GoogleMapsStaticAdapter enables you to use Google Maps Static API.
- The adapter requires an API key, which you can get at Google Maps API website.
Contributing? #
- Pull requests are welcome.
- Please test your changes manually using the "example" application in the repository.