I don't think it is possible w/out actually using a LocationProvider, but figured I would see if anyone had any thoughts.

Basically I have an app which has a PageView w/ a fragment which contains a the new MapView 2.0

I can easily pull the my Location by way of getMyLocation from the GoogleMap object.

I have had issues in past; across some devices, using both NetworkLocation & GpsLocation providers at the same time. Since I can just pull my location from the GoogleMap, I get a simple way to check my location.

My only issue is that I can watch for map panning to update the map by handling onCameraChanged, but it does not handle the location changing inside the map.

My current implementation is that I have a MapView and LocationProvider.. The location provider is in a service, and is set to update based on a user determined time (1,5,10,15,30,60 seconds). The activities connect to the service via AIDL, if there is >0 connected activities the locationProvider is enabled, if not, it turns off. This really has little bearing to the Google Map though, if we don't handle loss of GPS signal the same as Google maps, the location we get is different than the Google maps.

My first of 3 options: get a provider, and pass that in where I could get a callback on location change (did not really want to do this). This would involve be by way of LocationSource..

Second option get the current location provider that I am using in my current service, and each time it updates, just grab the location from the map. I suppose this would work, but seems a bit redundant, and still have issue of managing LocationProviders when screen is turned off etc.. (Don't have to do that w/ google map)

The other option would be to have a service that is passed an interface to the map object which can query the current location. And do so every x seconds that the user has indicated.. I can reuse most of the service for this, would just have to set it up to keep calling.

The other thing I was thinking of was maybe just using a passive provider to update the current location, from using the current MapView.

My only other consideration is Spoofing: I want to try and prevent location spoofing. I can make it so we don't allow Mock Locations. But that does not mean it can't be spoofed still.

So... Any thoughts would be greatly appreciated. Thanks.

有帮助吗?

解决方案

Google introduced the new LocationClient and associated LocationListener (the previously introduced OnMyLocationChangeListener interface is now deprecated).

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top