-
Notifications
You must be signed in to change notification settings - Fork 26.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[google_maps_flutter] My location blue dot doesn't point in the correct direction #98123
Comments
Hi @dat036, Thanks for filing the issue. I tried to reproduce this issue by running the below code sample, But I am not seeing the blue dot on Google maps even though the app has access to location permission. I am hitting this same issue again #93376. Also, it seems you are testing on an emulator Have you tried it on a real device? code sampleimport 'dart:async';
import 'package:flutter/material.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Google Maps Demo',
home: MapSample(),
);
}
}
class MapSample extends StatefulWidget {
@override
State<MapSample> createState() => MapSampleState();
}
class MapSampleState extends State<MapSample> {
Completer<GoogleMapController> _controller = Completer();
static final CameraPosition _kGooglePlex = CameraPosition(
target: LatLng(37.42796133580664, -122.085749655962),
zoom: 14.4746,
);
static final CameraPosition _kLake = CameraPosition(
bearing: 192.8334901395799,
target: LatLng(37.43296265331129, -122.08832357078792),
tilt: 59.440717697143555,
zoom: 19.151926040649414);
@override
Widget build(BuildContext context) {
return Scaffold(
body: GoogleMap(
// mapType: MapType.hybrid,
initialCameraPosition: _kGooglePlex,
myLocationEnabled: true,
myLocationButtonEnabled: true,
onMapCreated: (GoogleMapController controller) {
_controller.complete(controller);
},
),
// floatingActionButton: FloatingActionButton.extended(
// onPressed: _goToTheLake,
// label: const Text('To the lake!'),
// icon: const Icon(Icons.directions_boat),
// ),
);
}
Future<void> _goToTheLake() async {
final GoogleMapController controller = await _controller.future;
controller.animateCamera(CameraUpdate.newCameraPosition(_kLake));
}
}
flutter doctor -v
|
hi @maheshmnj . thanks for your attention.� I have tried your code sample and the locator function is still working properly. maybe you should check the location permission on your device. and my problem mentioned was on real device not �emulator. i have tried google pixel and Samsung device and both have the same problem. hope to get help from you soon. |
@dat036 I do have location permissions enabled, I did also try requesting permission using the third-party plugin. I searched a bit about this issue and this seems to be related to #34157 (my logs don't have the error as in the linked issue though) I do have these permission added to Androidmanifest and also the app settings shows the app has access to location.
Yet, I don't see the blue dot on the map neither on a real device (Redmi K20 Pro Android 11) nor on a emulator (Pixel 3a api 29). code sampleimport 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'package:location/location.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Google Maps Demo',
home: MapSample(),
);
}
}
class MapSample extends StatefulWidget {
@override
State<MapSample> createState() => MapSampleState();
}
class MapSampleState extends State<MapSample> {
final Completer<GoogleMapController> _controller = Completer();
static const CameraPosition _kGooglePlex = CameraPosition(
target: LatLng(37.42796133580664, -122.085749655962),
zoom: 14.4746,
);
static const CameraPosition _kLake = CameraPosition(
bearing: 192.8334901395799,
target: LatLng(37.43296265331129, -122.08832357078792),
tilt: 59.440717697143555,
zoom: 19.151926040649414);
getLocationPermission() async {
var location = Location();
try {
await location.requestPermission(); //to launch location permission popup
} on PlatformException catch (e) {
if (e.code == 'PERMISSION_DENIED') {
print('Permission denied');
}
}
}
@override
void initState() {
// TODO: implement initState
super.initState();
getLocationPermission();
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: GoogleMap(
// mapType: MapType.hybrid,
initialCameraPosition: _kGooglePlex,
myLocationEnabled: true,
myLocationButtonEnabled: true,
onMapCreated: (GoogleMapController controller) {
_controller.complete(controller);
},
),
// floatingActionButton: FloatingActionButton.extended(
// onPressed: _goToTheLake,
// label: const Text('To the lake!'),
// icon: const Icon(Icons.directions_boat),
// ),
);
}
Future<void> _goToTheLake() async {
final GoogleMapController controller = await _controller.future;
controller.animateCamera(CameraUpdate.newCameraPosition(_kLake));
}
}
flutter doctor -v
Let me know if I am missing anything. |
@maheshmnj mas I used the code sample you provided and it works fine. I don't understand what's wrong with your device either. If needed, I can build an apk file based on your code and send it to you |
Thanks for the info @dat036, Labeling this issue for further investigation.
Sure, please attach a zip file in the comment and I will take a look. |
We encounter this issue as well, it's working fine on iOS devices but on all Android phones the compass doesn't really work at all and is just pointing in random directions. |
@maheshmnj I was able to see the blue dot (location dot) after manually enabling location in settings. Go to Settings, Location, App location permissions, select demo app, grant location access for the demo app. To request permission at runtime, the permission_handler plugin can help. Otherwise, please follow https://developer.android.com/training/location/permissions#request-location-access-runtime. Also, note that |
For this bug, I'd strongly suggest to create a minimal repro in native only (starting with one of the sample apps https://developers.google.com/maps/documentation/android-sdk/overview?section=tutorials), and one using Flutter. I don't have a reason to believe (yet) that this plugin is doing something wrong. |
@blasten I don't think that the issue that the author is originally talking about is that the blue dot doesn't appear, but that this blue dot is not the same as on Google Maps. On GM there is this shadow of sight (as shown in the screenshots of the main issue) and is turning very smoothly along with the device turning, whereas in the google_maps_flutter plugin there is this blue dot with a simple arrow that's pointing very poorly in a seemingly random direction without even turning the device. |
@blasten @LevinGermann yes my problem is not with the blue dot appearing, blue dot with a simple arrow not working correctly when turning the phone in many directions |
Ok. Please help us by showing that this isn't a problem in a native app (using https://developers.google.com/maps/documentation/android-sdk/overview?section=tutorials to start with a clean app), and it's a problem when using this plugin. cc @GaryQian |
Without additional information, we are unfortunately not sure how to resolve this issue. We are therefore reluctantly going to close this bug for now. |
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of |
update question: I am facing a problem when using google map flutter. Normally in the google map application, the current position will be displayed with a blue dot and trimmed beam, but in google_maps_flutter, it will display a blue dot and an arrow indicating the direction of the compass. currently when i rotate my phone the beam on google maps app moves in the direction of the phone but the arrow on the app using google_maps_flutter doesn't move or moves very slow and wrong direction. everyone can test it with the example of google maps flutter below. Has anyone encountered this problem can give me advice or a keyword to solve. Thank you everyone for reading.
if anyone wants to try can pull directly from google_maps_flutter example. Install on device -> settings -> enable GPS permission -> open app -> user interface -> mylocation marker. tks
link git hub example:
https://github.com/flutter/plugins/tree/master/packages/google_maps_flutter/google_maps_flutter
blue dot and compass arrow in google_map_flutter
blue dot and the beam that indicates in Google Maps application
The text was updated successfully, but these errors were encountered: