Reputation: 129
I'm trying to create a huawei variant of a locator feature of a project that uses google maps. But my problem is that onMapReady() callback does not trigger at all after getMapAsync()
This is how i call getMapAsync:
val mapFragment = childFragmentManager.findFragmentById(R.id.fragment_huawei_map_container) as SupportMapFragment
mapFragment.getMapAsync(this@SampleMapsFragment)
This works fine when using google maps depedencies as onMapReady() is getting called.
But when using huawei map dependencies, onMapReady callback does not trigger at all after getMapAsync()
Upvotes: 3
Views: 868
Reputation: 2035
Since you are using the Huawei's map kit to do these please check the following: You have generated a sha256 key and integrated HMS core, you can use this link to find out how.
If you have done all the above, make sure that agconnect-services.json is in the right place. Then, check if in your manifest you have:
A final thing to check is that if you have done
I hope one of these will help as I was able to get onMapReady to trigger:
Upvotes: 2
Reputation: 34027
The onMapReady method needs to be reloaded. The following describes how to create a map instance using SupportMapFragment. For more details, see docs.
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
android:id="@+id/mapfragment_mapfragmentdemo"
class="com.huawei.hms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
map:cameraTargetLat="48.893478"
map:cameraTargetLng="2.334595"
map:cameraZoom="10" />
public class SupportMapDemoActivity extends AppCompatActivity implements OnMapReadyCallback {
...
}
private SupportMapFragment mSupportMapFragment;
mSupportMapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.mapfragment_mapfragmentdemo);
mSupportMapFragment.getMapAsync(this);
public void onMapReady(HuaweiMap huaweiMap) {
Log.d(TAG, "onMapReady: ");
hMap = huaweiMap;
}
Upvotes: 1