mirror of
https://github.com/Iconica-Development/flutter_google_track_and_trace.git
synced 2025-05-19 05:03:45 +02:00
feat: add optional parameter for calling directions api
This commit is contained in:
parent
d2e2a80566
commit
f1e30f1a15
1 changed files with 10 additions and 3 deletions
|
@ -28,6 +28,7 @@ class GoogleTrackTraceMap extends StatefulWidget {
|
||||||
this.buildingsEnabled = false,
|
this.buildingsEnabled = false,
|
||||||
this.indoorViewEnabled = false,
|
this.indoorViewEnabled = false,
|
||||||
this.trafficEnabled = false,
|
this.trafficEnabled = false,
|
||||||
|
this.retrieveDirections = true,
|
||||||
this.mapStylingTheme,
|
this.mapStylingTheme,
|
||||||
this.onTap,
|
this.onTap,
|
||||||
this.onArrived,
|
this.onArrived,
|
||||||
|
@ -62,6 +63,7 @@ class GoogleTrackTraceMap extends StatefulWidget {
|
||||||
final bool tiltGesturesEnabled;
|
final bool tiltGesturesEnabled;
|
||||||
final bool myLocationEnabled;
|
final bool myLocationEnabled;
|
||||||
final bool myLocationButtonEnabled;
|
final bool myLocationButtonEnabled;
|
||||||
|
final bool retrieveDirections;
|
||||||
final bool zoomControlsEnabled;
|
final bool zoomControlsEnabled;
|
||||||
final bool zoomGesturesEnabled;
|
final bool zoomGesturesEnabled;
|
||||||
final bool mapToolbarEnabled;
|
final bool mapToolbarEnabled;
|
||||||
|
@ -169,8 +171,10 @@ class _GoogleTrackTraceMapState extends State<GoogleTrackTraceMap> {
|
||||||
controller.mapController = ctr;
|
controller.mapController = ctr;
|
||||||
if (widget.mapStylingTheme != null) {
|
if (widget.mapStylingTheme != null) {
|
||||||
ctr.setMapStyle(widget.mapStylingTheme!.getJson()).onError(
|
ctr.setMapStyle(widget.mapStylingTheme!.getJson()).onError(
|
||||||
(error, stackTrace) =>
|
(error, stackTrace) async {
|
||||||
throw GoogleMapsException(error.toString()),
|
print(error);
|
||||||
|
throw GoogleMapsException(error.toString());
|
||||||
|
},
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
// No theme provided so switching to default
|
// No theme provided so switching to default
|
||||||
|
@ -228,6 +232,9 @@ class _GoogleTrackTraceMapState extends State<GoogleTrackTraceMap> {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> calculateRoute() async {
|
Future<void> calculateRoute() async {
|
||||||
|
if (!widget.retrieveDirections) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (controller.route == null || checkTargetMoved()) {
|
if (controller.route == null || checkTargetMoved()) {
|
||||||
var directions =
|
var directions =
|
||||||
await DirectionsRepository() // TODO(freek): refactor this away
|
await DirectionsRepository() // TODO(freek): refactor this away
|
||||||
|
|
Loading…
Reference in a new issue