'Using different than default location source in google maps flutter package
In every example of adding google maps to flutter mobile app I found on the internet, I see that people use either
- google maps with
myLocationEnabled
, which uses its ownFusedLocationProviderClient
behind the scenes, - use some location flutter plugin like geolocator, add the blue dot as standard marker and move it on location changes provided by plugin package.
The first solution does not provide way of customizing location accuracy, intervals etc, and the second just feels wrong, as with this solution, we lose movement direction arrow, center button and other functionalities related to myLocation
layer in google map.
Ok, time for some context. What am I trying to achieve? I would like to have one location source, be it geolocator plugin(it also uses FusedLocationProviderClient
under the hood), that allows me to fully customize location settings like accuracy, intervales etc, and feed that location data to google map to show my current location on map, and also feed location data to my backend server for other purposes.
My hopes went up when I came across setLocationSource
function of google map. It allows me to set external location source for myLocation
layer. It seems that this is exactly what I am looking for. Unfortunately, setLocationSource
is not supported in flutter google_maps plugin.
Has anyone an idea about how to solve that problem? Maybe I should try to extend google_maps plugin myself, or maybe there is other way to achieve my goals?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|