android中的谷歌地图集成不显示地图
我在android的谷歌地图集成方面遇到了一个问题, 当我创建一个地图活动,然后集成到google api时,会得到灰色背景,但当我创建一个新项目,然后将新项目集成到google地图时,它会完美地工作, 我的实际项目无法集成到谷歌地图,有人能帮我吗, 我是说地图上的问题关键在于如何解决它android中的谷歌地图集成不显示地图,android,google-maps-android-api-2,Android,Google Maps Android Api 2,我在android的谷歌地图集成方面遇到了一个问题, 当我创建一个地图活动,然后集成到google api时,会得到灰色背景,但当我创建一个新项目,然后将新项目集成到google地图时,它会完美地工作, 我的实际项目无法集成到谷歌地图,有人能帮我吗, 我是说地图上的问题关键在于如何解决它 public class MapViewActivity extends FragmentActivity implements OnMapReadyCallback{ private GoogleMap m
public class MapViewActivity extends FragmentActivity implements OnMapReadyCallback{
private GoogleMap mMap;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_map_view);
// Obtain the SupportMapFragment and get notified when the map is ready to be used.
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
}
/**
* Manipulates the map once available.
* This callback is triggered when the map is ready to be used.
* This is where we can add markers or lines, add listeners or move the camera. In this case,
* we just add a marker near Sydney, Australia.
* If Google Play services is not installed on the device, the user will be prompted to install
* it inside the SupportMapFragment. This method will only be triggered once the user has
* installed Google Play services and returned to the app.
*/
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
// Add a marker in Sydney and move the camera
LatLng sydney = new LatLng(-34, 151);
mMap.addMarker(new MarkerOptions().position(sydney).title("Marker in Sydney"));
mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney));
}
}
这是my
mapactivity
的代码,请确保在属性中设置了API密钥
此密钥在中检索
下面是应用程序的精确实现
可以访问完整的应用程序及其带有屏幕截图的代码
注意:
在MapsMarketivity的onCreate
中,我确实使用Geocoder来填充给定城市或默认城市的经度和纬度。在Android项目中有一个属性文件,您可以在其中指定API密钥。你配置了这个文件吗?此外,还需要从Google开发者控制台启用Android地图。你这么做了吗?是的,我启用了it@SharafudheenKannath-你有机会检查我的解决方案吗?