android – Overriding user location in osmdroid library-ThrowExceptions

Exception or error:

I need to override my user location for using Kalman filter and manipulating raw data or I want to restrict the longitudinal motion with my static value.

How can I override lat/long value?

I implement IMyLocationProvider in my created class and override this function:

class iiMyLocationProvider : IMyLocationProvider
{
    override fun destroy() { }

    override fun startLocationProvider(myLocationConsumer: IMyLocationConsumer?): Boolean {
       Todo()
     }

    override fun stopLocationProvider() { }

    override fun getLastKnownLocation(): Location? {
        val loc:Location?=null
        loc?.latitude=35.78775487
        loc?.longitude=51.47342972
        return loc
    }
}

and pass it in my mapactivity:

    val iMyLocationProvider=iiMyLocationProvider()
    var ifake = MyLocationNewOverlay(iMyLocationProvider,map)
    map?.getOverlays()?.add(ifake)

But it is not working. I think there must be an easier way.

I also saw this topic but it didn’t help either or I can’t find out:
Overriding location-tracking in OSMdroid

How to solve:

Leave a Reply

Your email address will not be published. Required fields are marked *