maps 0.1.1 maps: ^0.1.1 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 #
Geographic maps for Flutter applications.
This package is:
- Cross-platform. Browser, Android, iOS, Windows, etc.
- Multi-vendor. Supports all major map vendors (Apple, Bing, Google).
This is an early-stage version and lots of things are still missing or broken. Pull requests are welcome!
Links #
Getting started #
1.Add dependency #
dependencies:
maps: ^0.1.1
2.Define configuration #
We recommend that you set a default MapAdapter
in the main
function of your application. This is more convenient than setting a MapAdapter for
each widget separately.
Your main function should look something like this:
void main() {
MapAdapter.defaultInstance = const MapAdapter.platformSpecific(
android: GoogleMapsNativeAdapter(apiKey:'GOOGLE MAPS API KEY'),
browser: BingMapsIframeDapter(),
ios: AppleMapsNativeAdapter(),
otherwise: GoogleMapsStaticAdapter(apiKey:'GOOGLE MAPS API KEY'),
);
// ...
runApp(MyApp());
}
3.Use #
MapWidget #
MapWidget is a Flutter widget that uses the map engine you chose:
import 'package:flutter/widgets.dart';
import 'package:maps/maps.dart';
final widget = MapWidget(
size: Size(300, 500),
query: 'Paris',
markers: [
MapMarker(
query: 'Eiffel Tower',
),
],
);
MapAppLauncher #
MapAppLauncher launches either:
- A map website (such as Google Maps website)
- A map application in the device (such as Google Maps for Android/iOS)
import 'package:maps/maps.dart';
Future<void> main() async {
// Use default app
await MapAppLauncher.defaultInstance.launch(query:'Eiffel Tower');
// Use Google Maps
await MapAppLauncher.googleMaps.launch(query:'Louvre Museum');
}
Supported map providers #
Apple Maps #
Available implementations:
- AppleMapsNativeAdapter (iOS)
- Uses Apple MapKit. Currently depends on the Flutter package apple_maps_flutter (by a third-party developer).
- AppleMapsJsAdapter (browsers)
- Uses Apple MapKit JS.
- AppleMapsStaticAdapter (all platforms)
The iOS API does not require API credentials. For using other APIs you need to obtain API credentials from Apple. API requests are signed with your ECDSA P-256 key pair.
Bing Maps #
Available implementations:
- BingMapsIframeAdapter (browsers)
- Uses Bing Maps Custom Map URLs.
- Note that markers and many other features are unsupported.
- BingMapsJsAdapter (browsers)
- Uses Bing Maps Javascript API.
- BingMapsStaticAdapter (all platforms)
Bing Maps may allow you to use the iframe API without API credentials. For using other APIs, you need to obtain API credentials from Microsoft. You can do that in the Bing Maps API website.
Google Maps #
Available implementations:
- GoogleMapsIframeAdapter (browsers)
- Uses Google Maps Embed API.
- Note that markers and many other features are unsupported.
- GoogleMapsJsAdapter (browsers)
- GoogleMapsNativeAdapter (Android, iOS)
- Uses Google Maps Android / iOS SDK. Depends on google_maps_flutter. which is the official package maintained by Google. You need to edit your configuration files. See documentation for google_maps_flutter.
- GoogleMapsStaticAdapter (all platforms)
- Uses Google Maps Static API.
You need to obtain API credentials from Google. You can do that in the Google Maps API website.