Using 'google_maps_flutter' tiles with 'flutter_map' #1158
Replies: 7 comments 7 replies
-
Looks interesting, could you make this a plugin? |
Beta Was this translation helpful? Give feedback.
-
@JaffaKetchup I tried using it in my app. Both are octa-core CPU with ARM Cortex-A53 cores. Vehicles are represented using MarkerLayerWidget from flutter_mapRedmi 4x (Snapdragon 435) android 11 Custom ROMscreen-20220127-150556.mp4Huawei G9 Lite (HiSilicon Kirin 650) android 6 EMUIvideo_2022-01-27_10-21-41.mp4And there are other ways for this to be implemented. 2- We can use googleMapController.takeSnapshot() which will return a Future<Uint8List?> representing the image bytes of the map. I think that is similar to how Leaflet handle google maps tiles, where it uses a google map instance to fetch tiles, and rip it from the DOM tree to use on Leaflet, hopefully this complies with Google's ToS. |
Beta Was this translation helpful? Give feedback.
-
Not sure about compliance with Google ToS, they probably aren't happy about using their tiles without their SDK? Either option seems good, ultimately it's your decision! If I had to pick, I would probably pick option 2, because it just feels nicer somehow, and less of a workaround. Thanks for sharing :) |
Beta Was this translation helpful? Give feedback.
-
As I "think" (haven't had chance to dig into it behind the scenes) this is kind of still using the Google Maps SDK, it may actually be fine with their ToS. |
Beta Was this translation helpful? Give feedback.
-
Does this still work? @Ahmed-gubara |
Beta Was this translation helpful? Give feedback.
-
@thomashrabe It doesn't perform well on android versions older than android 10 (SDK 29). So maybe make a fallback to open street map on older android versions. Widget myTileLayer() {
int androidSdk = getAndroidVersion(); // using device_info_plus
if (androidSdk >= 29) { // >= Android 10
return GoogleMapTileLayer(
mapType: MapType.hybrid,
);
}
else
{
return TileLayer(
urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
userAgentPackageName: 'com.example.app',
);
}
} I've updated the gist to the code that i'm currently using. The same code will work with apple_maps_flutter as the api is almost identical. GoogleMap -> AppleMap
GoogleMapController -> AppleMapController And it work very well on IOS devices . |
Beta Was this translation helpful? Give feedback.
-
Thank you for the update. However, I tried it and it seems now that your example is lagging behind. The source file does not contain GoogleMapTileLayerOptions anymore. I think they were in there before? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi
Just had some time to play with google_maps_flutter package.
I would like to share a code that worked for me to use GoogleMap Widget as a tile layer on flutter_map
For flutter_map >= 6.0.0: google_tile_layer_widget.dart (flutter_map v6)
For flutter_map < 6.0 : google_tile_layer_widget.dart (flutter_map v5)
usage:
There is a slight delay while panning, but it can be reduced greatly with
useAndroidViewSurface: true
Beta Was this translation helpful? Give feedback.
All reactions