Hey when adding GoogleMaps to my project, it seems that anytime the map is dragged or the camera is moved there is a spam of logs for
I/Counters( 4961): exceeded sample count in FrameTime
This seems to be a common issue with GoogleMaps in flutter reported here.
Here and Here
P.S. Setting myLocationEnabled: false, will not solve the issue as this still occurs when manually moving the map
class MyMap extends StatelessWidget {
const MyMap({
Key? key,
}) : super(key: key);
#override
Widget build(BuildContext context) {
return GoogleMap(
initialCameraPosition: CameraPosition(
target: state.location ?? const LatLng(0, 0),
zoom: 15.0,
),
mapType: MapType.normal,
myLocationEnabled: false,
zoomGesturesEnabled: true,
scrollGesturesEnabled: true,
tiltGesturesEnabled: false,
rotateGesturesEnabled: true,
zoomControlsEnabled: false,
);
}
}
Does anyone know if there is an update on the best way to fix this?
Thanks
delete some layers from widget google maps flutter
myLocationEnabled: false,
zoomGesturesEnabled: true,
scrollGesturesEnabled: true,
tiltGesturesEnabled: false,
rotateGesturesEnabled: true,
zoomControlsEnabled: false,
Related
please help me I am new in the flutter
GoogleMap(
padding: EdgeInsets.only(
top: mapBottomPadding,
),
initialCameraPosition: _kGoogle,
mapToolbarEnabled: true,
buildingsEnabled: true,
myLocationButtonEnabled: true,
myLocationEnabled: true,
mapType: MapType.terrain,
markers: markers,
trafficEnabled: true,
// on below line setting compass enabled.
compassEnabled: true,
onMapCreated: onMapcreated,
zoomControlsEnabled: true,
),
i also shared my google maps code
You can use this code snippet for google maps change moving location iconhttps://gist.github.com/samuchakraborty/243842a1a93956e64dc8781d0f9fb313
I am using Google maps in my flutter application and needed to integrate Huawei maps too. So every code related to the maps now is duplicated like:
Map<MarkerId, Marker> googleMarkers = <MarkerId, Marker>{};
Map<huawei.MarkerId, huawei.Marker> huaweiMarkers = <huawei.MarkerId, huawei.Marker>{};
void _onHuaweiMapCreated(huawei.HuaweiMapController controller) =>
_huaweiMapController = controller;
void _onGoogleMapCreated(GoogleMapController controller) => _googleMapController = controller;
GooglePlayServicesHelper.googlePlayServicesAvailable
? GoogleMap(
initialCameraPosition: CameraPosition(
target: LatLng(30.0, 40.0),
zoom: 11.0,
),
onMapCreated: _onGoogleMapCreated,
myLocationButtonEnabled: false,
zoomControlsEnabled: false,
markers: Set<Marker>.of(googleMarkers.values),
)
: huawei.HuaweiMap(
initialCameraPosition: huawei.CameraPosition(
target: huawei.LatLng(30.0, 40.0),
zoom: 11.0,
),
onMapCreated: _onHuaweiMapCreated,
myLocationButtonEnabled: false,
zoomControlsEnabled: false,
markers: Set<huawei.Marker>.of(huaweiMarkers.values),
),
and so on...
My question is if there is any way I can use generic or abstract classes (interface concept) instead of all these conditions and duplicated code? Especially if I wanted to integrate another type of maps in the future in order to achieve open-closed principle.
I am doing a project that allows a user to upload a geojson file and add the polygons/polylines to the Google Map as a layer.
To be clear I'm using google_maps_flutter package: https://pub.dev/packages/google_maps_flutter
GoogleMap(
myLocationButtonEnabled: true,
mapType: _currentMapType,
zoomGesturesEnabled: true,
compassEnabled: true,
myLocationEnabled: true,
gestureRecognizers: Set()
..add(Factory<EagerGestureRecognizer>(
() => EagerGestureRecognizer())),
zoomControlsEnabled: true,
initialCameraPosition: cameraPosition ?? _defaultCameraPosition,
onMapCreated: (controller) {
_controllerGoogleMap.complete(controller);
_googleMapController = controller;
_determinePosition();
},
markers: _markers),
However, while trying to implement this, I did not find a clear way to implement this. What ways can I use to do this?
Any help will be appreciated. Thanks
I am using the google_maps_flutter package and the Zoom level for the myLocationButton, when pressed, is set to my last zoom level. I would like to reset the Zoom level when the myLocationButton is pressed.
This is the code for the Google Maps;
GoogleMap(
padding: EdgeInsets.only(bottom: _mapBottomPadding),
mapType: MapType.normal,
initialCameraPosition: _baseLocation,
myLocationButtonEnabled: true,
myLocationEnabled: true,
zoomControlsEnabled: true,
zoomGesturesEnabled: true,
// minMaxZoomPreference: const MinMaxZoomPreference(12, 14),
polylines: _polylineSet,
markers: _markersSet,
onMapCreated: (GoogleMapController controller) async {
if (!_controller.isCompleted) {
//first calling is false
//call "completer()"
_controller.complete(controller);
// setState(() {});
} else {
//other calling, later is true,
//don't call again completer()
}
// _controller.complete(controller);
_googleMapController = controller;
// Set Initial Camera Position
setCameraPosition(
position: locationData.getCurrentAddress.position
as Position);
setMapBounds();
setState(() {});
},
),
The zoom is stuck on the last zoom level when setting camera position previously and I would like to rest it when I click the myLocationButton.
The setMapBounds(); method call sets the zoom which depends on map bounds and calls the code below which can result in a high zoom level and the zoom level persists after the call, when I click the myLocationButton.
_googleMapController!
.animateCamera(CameraUpdate.newLatLngBounds(latLngBounds, 70));
How can I reset the zoom level after animating the camera?
Can you please try this one if it helps.try to setState zoomValue
double zoomValue=14.0;
LatLng mapCenter = new LatLng("your latitude", "your longitude");
initialCameraPosition: CameraPosition(
target: mapCenter,
zoom: zoomValue,
),
Try this
GoogleMap(
zoomGesturesEnabled: true,
tiltGesturesEnabled: false,
onCameraMove:(CameraPosition cameraPosition){
print(cameraPosition.zoom);
},
i am new in flutter and i'm build a simple app with google_map_flutter package.
I understand that the first time the location button is not showed due to location permission. I would like to update the state of the location button to true once the user grant the permission. below the code.
children: [
GoogleMap(
padding: EdgeInsets.only(bottom: _bottomPaddingOfMap, top: 32),
mapType: MapType.normal,
myLocationButtonEnabled: _myLocationButtonEnabled,
initialCameraPosition: _kGooglePlex,
myLocationEnabled: true,
zoomGesturesEnabled: true,
zoomControlsEnabled: true,
onMapCreated: (GoogleMapController controller) {
_controllerGoogleMap.complete(controller);
newGoogleMapController = controller;
setState(() {
//..... update _myLocationButtonEnabled??
_bottomPaddingOfMap = 280.0;
});
locatePosition();
},
),....
I'm using a permission_handler package but not sure about how to use it. I guess I've to update the _myLocationButtonEnabled variable to true once user granted permission.
How can I do this?
Any help will be appreciated.
Thanks guys.