Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot get com.huawei.hms.location.LocationServices for Huawei Map Kit in android studio

I am currently trying to migrate Google Maps to Huawei map kit in my android project.

It was easy to migrate google maps to Huawei map at first. They are provided all the methods and classes that Google Maps have but now I couldn't get LocationServises class from Huawei that I used in my google maps.

In the documentation they say that Huawei Map kit has com.huawei.hms.location package and LocationServises inside. But why I cannot get it???

The links and libs that I added to gradle below: I refer the Huawei Map Kit documentation

 1. maven {url 'https://developer.huawei.com/repo/'} 

 2. classpath 'com.huawei.agconnect:agcp:1.2.1.301'

 3. maven {url 'https://developer.huawei.com/repo/'} 

 4. implementation 'com.huawei.hms:maps:5.1.0.300'
like image 376
Aytaj Avatar asked Dec 01 '25 09:12

Aytaj


2 Answers

You can find the location services in the following artifactory

// Huawei implementation "com.huawei.hms:location:4.0.3.301"

And retrieve the location with: FusedLocationProviderClient

Retrieve the last location with the listener

private var fusedLocationProviderClient: FusedLocationProviderClient = LocationServices.getFusedLocationProviderClient(context)

fusedLocationProviderClient.lastLocation.addOnSuccessListener { location -> Log.d("Location", location)
}
like image 129
Capps99 Avatar answered Dec 04 '25 02:12

Capps99


  1. You are advised to use Huawei Location Kit because Map Kit involves only some of location functions. :)

I am migrating the Google maps to Huawei map and in the google version there is something like public static final Api API; variable inside LocationServises class and I need this variable in Huawei too. But there no variable like this :/ do you know where to get it?

Please kindly refer to the Location Kit References.

About public enum LocationType, please refer to docs here.

like image 39
zhangxaochen Avatar answered Dec 04 '25 01:12

zhangxaochen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!