我很困惑,我不确定我是否错过了什么。目前,我使用Nexus 5作为测试设备构建的应用程序运行良好。
我最近将其插入三星Galaxy Note 10.1,并且某些功能无法正常工作。
例如,我正在使用Google Maps API,在我的Nexus上,它将专注于您当前的位置。如果您未启用位置信息,则默认为设置的城市。这在Nexus上效果很好,但是平板电脑专注于太平洋中部。它在应该显示的位置显示蓝色小位置点,但在打开时没有聚焦在它上面?
另一个例子是YouTube网络视图。在Nexus上,YouTube视频通过WebView
播放。这在平板电脑上会发生变化,因为不会播放任何视频。它只显示一个灰色框。
有人有什么想法吗?
我将开始使用YouTube API并集成它来解决YouTube问题,但我不知道谷歌地图发生了什么。
提前感谢!
编辑:
private void setUpMap() {
// Enable MyLocation Layer of Google Map
googleMap.setMyLocationEnabled(true);
// Get LocationManager object from System Service LOCATION_SERVICE
LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
// Create a criteria object to retrieve provider
Criteria criteria = new Criteria();
// Get the name of the best provider
String provider = locationManager.getBestProvider(criteria, true);
// Get Current Location
Location myLocation = locationManager.getLastKnownLocation(provider);
googleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
if (myLocation == null) {
latitude = -36.916278;
longitude = 174.795372;
LatLng latLng = new LatLng(latitude, longitude);
googleMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
} else {
// Get latitude of the current location
latitude = myLocation.getLatitude();
// Get longitude of the current location
longitude = myLocation.getLongitude();
// Create a LatLng object for the current location
LatLng latLng = new LatLng(latitude, longitude);
// Show the current location in Google Map
googleMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
}
// Zoom in the Google Map
googleMap.animateCamera(CameraUpdateFactory.zoomTo(8));
}
这是应该在平板电脑上运行的地图设置代码。在Nexus 5上效果很好。
尝试使用 CameraUpdateFactory.newCameraPosition()
应该是这样的:
LatLng latLng;
if (myLocation == null) {
latitude = -36.916278;
longitude = 174.795372;
latLng = new LatLng(latitude, longitude);
} else {
// Get latitude of the current location
latitude = myLocation.getLatitude();
// Get longitude of the current location
longitude = myLocation.getLongitude();
// Create a LatLng object for the current location
latLng = new LatLng(latitude, longitude);
}
CameraPosition position = CameraPosition.fromLatLngZoom(latLng, 8)
// Zoom in the Google Map
googleMap.moveCamera(CameraUpdateFactory.newCameraPosition(position));