Search code examples
androidhuawei-mobile-serviceshuawei-developershuawei-map-kit

Alternative for com.google.maps.android.SphericalUtil in HMS


Standard HMS converter does nothing to SphericalUtil.computeOffset (of com.google.maps.android:android-maps-utils). At the same time it depends on 'com.google.android.gms.maps.model.LatLng'. Is there an alternative in HMS world (for SphericalUtil, copy pasting from https://github.com/googlemaps/android-maps-utils does not count)?


Solution

  • In Huawei there is opensource for doing spherical map function:

    https://github.com/SupasinTatiyanupanwong/huawei-maps-utils

    in here we can do Spherical geometry — for example: computeDistance, computeHeading, computeArea

    dependencies {
        implementation 'me.tatiyanupanwong.supasin.android.libraries.huawei.maps:maps-utils:1.0.0-alpha02'
    } 
    

    and do

    double distance = SphericalUtil.computeDistanceBetween(mMarkerA.getPosition(), mMarkerB.getPosition());