Repository: flutter
Issue: [google_maps_flutter] TileOverlay appears different on Android
Labels: platform-android,p: maps,package,has reproducible steps,P2,found in release: 3.10,found in release: 3.12,team-android,triaged-android

### Is there an existing issue for this?

- [X] I have searched the [existing issues](https://github.com/flutter/flutter/issues)
- [X] I have read the [guide to filing a bug](https://flutter.dev/docs/resources/bug-reports)

### Steps to reproduce

1. Create a Flutter project and add the google_maps_flutter
2. Put permissions and API_KEY in AndroidManifest.xml
3. Paste the code into main.dart
4. Run on Android

### Expected results

Display the same TileOverlay image on both platforms.

### Actual results

In my app, I'm inserting layers (TileOverlay) to display on Android and iOS. On iOS I have a perfect result, but on Android it opens completely misaligned. I checked the TileProvider and it is calling different values in x,y,z compared to iOS and Android.

### Code sample

<details><summary>Code sample</summary>

```main.dart
import 'dart:typed_data';

import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';

void main() {
  runApp(const MaterialApp(home: TileOverlayPage()));
}

class TileOverlayPage extends GoogleMapExampleAppPage {
  const TileOverlayPage({Key? key}) : super(const Icon(Icons.map), 'Tile overlay', key: key);

  @override
  Widget build(BuildContext context) {
    return const TileOverlayBody();
  }
}

class TileOverlayBody extends StatefulWidget {
  const TileOverlayBody({super.key});

  @override
  State<StatefulWidget> createState() => TileOverlayBodyState();
}

class TileOverlayBodyState extends State<TileOverlayBody> {
  TileOverlayBodyState();

  GoogleMapController? controller;
  TileOverlay? _tileOverlay;

  // ignore: use_setters_to_change_properties
  void _onMapCreated(GoogleMapController controller) {
    this.controller = controller;
  }

  @override
  void dispose() {
    super.dispose();
  }

  void _removeTileOverlay() {
    setState(() {
      _tileOverlay = null;
    });
  }

  void _addTileOverlay() {
    final TileOverlay tileOverlay = TileOverlay(
      tileOverlayId: const TileOverlayId('tile_overlay_1'),
      tileProvider: _DebugTileProvider(),
    );
    setState(() {
      _tileOverlay = tileOverlay;
    });
  }

  void _clearTileCache() {
    if (_tileOverlay != null && controller != null) {
      controller!.clearTileCache(_tileOverlay!.tileOverlayId);
    }
  }

  @override
  Widget build(BuildContext context) {
    final Set<TileOverlay> overlays = <TileOverlay>{
      if (_tileOverlay != null) _tileOverlay!,
    };
    return Column(
      mainAxisSize: MainAxisSize.min,
      mainAxisAlignment: MainAxisAlignment.spaceEvenly,
      crossAxisAlignment: CrossAxisAlignment.stretch,
      children: <Widget>[
        Center(
          child: SizedBox(
            width: 350.0,
            height: 300.0,
            child: GoogleMap(
              initialCameraPosition: const CameraPosition(
                target: LatLng(59.935460, 30.325177),
                zoom: 7.0,
              ),
              tileOverlays: overlays,
              onMapCreated: _onMapCreated,
            ),
          ),
        ),
        TextButton(
          onPressed: _addTileOverlay,
          child: const Text('Add tile overlay'),
        ),
        TextButton(
          onPressed: _removeTileOverlay,
          child: const Text('Remove tile overlay'),
        ),
        TextButton(
          onPressed: _clearTileCache,
          child: const Text('Clear tile cache'),
        ),
      ],
    );
  }
}

class _DebugTileProvider implements TileProvider {
  _DebugTileProvider();

  final Dio dio = Dio();

  @override
  Future<Tile> getTile(int x, int y, int? zoom) async {
    var baseUrl = 'https://bbox.urbit.com.br/tile/zoneamento/{z},{x},{y}.png?type=png'.replaceAll('{z},{x},{y}', '$zoom/$x/$y');
    final image = await dio.get(baseUrl, options: Options(responseType: ResponseType.bytes));
    if (image.statusCode == 200 && image.data is Uint8List) {
      return Tile(256, 256, image.data);
    } else {
      return Tile(256, 256, Uint8List(0));
    }
  }
}

abstract class GoogleMapExampleAppPage extends StatelessWidget {
  const GoogleMapExampleAppPage(this.leading, this.title, {super.key});

  final Widget leading;
  final String title;
}
```
</details>


### Screenshots or Video

<details>
<summary>Screenshots / Video demonstration</summary>

<a href="https://ibb.co/nLLQf14"><img src="https://i.ibb.co/nLLQf14/Captura-de-Tela-2023-06-09-s-19-36-32.png" alt="Captura-de-Tela-2023-06-09-s-19-36-32" border="0"></a>

</details>


### Logs

<details><summary>Logs</summary>

```console
[Paste your logs here]
```

</details>


### Flutter Doctor output

<details><summary>Doctor output</summary>

```console
[!] Flutter (Channel stable, 3.7.12, on macOS 13.4 22F66 darwin-arm64, locale
    pt-BR)
    • Flutter version 3.7.12 on channel stable at /Users/nicolas/Dev/FlutterSDK
    ! Warning: `dart` on your path resolves to
      /opt/homebrew/Cellar/dart-sdk/2.19.6/libexec/bin/dart, which is not inside
      your current Flutter SDK checkout at /Users/nicolas/Dev/FlutterSDK.
      Consider adding /Users/nicolas/Dev/FlutterSDK/bin to the front of your
      path.
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 4d9e56e694 (8 weeks ago), 2023-04-17 21:47:46 -0400
    • Engine revision 1a65d409c7
    • Dart version 2.19.6
    • DevTools version 2.20.1
    • If those were intentional, you can disregard the above warnings; however
      it is recommended to use "git" directly to perform update checks and
      upgrades.

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
    • Android SDK at /Users/nicolas/Library/Android/sdk
    • Platform android-33, build-tools 33.0.2
    • Java binary at: /Applications/Android
      Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build
      17.0.6+0-17.0.6b802.4-9586694)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.3.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14E300c
    • CocoaPods version 1.12.1

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2022.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build
      17.0.6+0-17.0.6b802.4-9586694)

[✓] VS Code (version 1.78.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.66.0

[✓] Connected device (3 available)
    • sdk gphone64 arm64 (mobile) • emulator-5554 • android-arm64  • Android 13
      (API 33) (emulator)
    • macOS (desktop)             • macos         • darwin-arm64   • macOS 13.4
      22F66 darwin-arm64
    • Chrome (web)                • chrome        • web-javascript • Google
      Chrome 114.0.5735.106

[✓] HTTP Host Availability
    • All required HTTP hosts are available

! Doctor found issues in 1 category.
```

</details>