我在我的应用程序中使用华为地图套件,我正在按照他们文档中提到的步骤进行操作。地图加载并且每次都将我移动到象牙海岸。我不明白为什么
我的代码
private HuaweiMap hMap;
private MapView mMapView;
double lat;
double lng;
private static final String MAPVIEW_BUNDLE_KEY = "MapViewBundleKey";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_map);
Log.i("TAG", "onCreate");
Intent i=getIntent();
double lat=i.getExtras().getDouble("lat");
double lng=i.getExtras().getDouble("lng");
mMapView = findViewById(R.id.mapView);
Bundle mapViewBundle = null;
if (savedInstanceState != null) {
mapViewBundle = savedInstanceState.getBundle(MAPVIEW_BUNDLE_KEY);
}
MapsInitializer.setApiKey("the api key");
mMapView.onCreate(mapViewBundle);
//get map instance
mMapView.getMapAsync(this);
}
@Override
public void onMapReady(HuaweiMap map) {
//get map instance in a callback method
Log.d("TAG", "onMapReady: ");
hMap = map;
hMap.getUiSettings().setZoomControlsEnabled(true);
hMap.getUiSettings().setZoomGesturesEnabled(true);
hMap.getUiSettings().setMyLocationButtonEnabled(true); //this button doesn't show on screen either
LatLng location = new LatLng(lat, lng);
hMap.addMarker(new MarkerOptions().position(location));
CameraPosition cameraPosition = new CameraPosition(location,8,2.2f,31.5f);
hMap.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
hMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
}
我在同一个应用程序中使用谷歌地图(对于使用 gms 的手机)并使用几乎相同的方法,并且在谷歌地图上一切正常..请帮助