【发布时间】:2020-11-06 00:45:49
【问题描述】:
我正在测试华为的地图套件。
应用程序已在 App Gallery Connect 中创建,我完成了所有步骤。 其他 HMS 服务运行良好。 我所有的依赖都是正确的。
所以,我使用视图来表示地图。
onMapReady 被调用,查看加载,我可以与地图交互,添加图钉,找到我的位置等。
但我看不到地图,只有空白图块。
我没有收到错误,onMapReady 被调用就好了。
我也试过华为Github上的demo,结果是一样的。 我也试过fragment,结果一样。
我的mapView
<com.huawei.hms.maps.MapView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
android:id="@+id/mapView"
android:layout_width="match_parent"
android:layout_height="match_parent"
map:cameraTargetLat="48.893478"
map:cameraTargetLng="2.334595"
map:cameraZoom="8.5"/>
我的onCreate
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_huawei_map_test);
Log.d(TAG, "yo: ");
if (!hasPermissions(this, RUNTIME_PERMISSIONS)) {
ActivityCompat.requestPermissions(this, RUNTIME_PERMISSIONS, 100);
}
mMapView = findViewById(R.id.mapView);
Bundle mapViewBundle = null;
if (savedInstanceState != null) {
mapViewBundle = savedInstanceState.getBundle(MAPVIEW_BUNDLE_KEY);
}
MapsInitializer.setApiKey("");//my key
mMapView.getMapAsync(this);
mMapView.onCreate(mapViewBundle);
我的onMapReady
@Override
public void onMapReady(HuaweiMap map) {
//get map instance in a callback method
Log.d(TAG, "onMapReady: ");
hMap = map;
//hMap.setMapType(HuaweiMap.MAP_TYPE_TERRAIN);
hMap.setMyLocationEnabled(true);
hMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(48.893478, 2.334595), 10));
Marker mMarker = hMap.addMarker(new MarkerOptions().position(new LatLng(48.893478, 2.334595)));
mMarker.showInfoWindow();
}
结果:
【问题讨论】:
标签: java android huawei-mobile-services huawei-developers