很遗憾,我还没有找到将Google地图存储在SO中的任何答案。
我目前正在使用地图应用程序,该应用程序将显示用户的朋友位置。但是,当我点击新朋友时,它会再次加载地图并消耗资源。
有没有办法在加载后存储地图,而不是在需要时再次转到地图服务器。所以我可以在需要时放置新的位置值,它将使用存储的地图来显示。
我按照以下方式加载地图:
switch (GooglePlayServicesUtil
.isGooglePlayServicesAvailable(getActivity())) {
case ConnectionResult.SUCCESS:
mapView = (MapView) view.findViewById(R.id.map);
mapView.onCreate(savedInstanceState);
if (mapView != null) {
map = mapView.getMap();
map.getUiSettings().setMyLocationButtonEnabled(false);
map.setMyLocationEnabled(true);
CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngZoom(new LatLng(latitude, longitude), 15);
map.animateCamera(cameraUpdate);
}
break;
case ConnectionResult.SERVICE_MISSING:
break;
case ConnectionResult.SERVICE_VERSION_UPDATE_REQUIRED:
break;
编辑:Or Is there any way to prevent the map to loads again and again?
答案 0 :(得分:3)
Google地图视图应该已经缓存了地图图块,因此如果您看到延迟,请确保在显示地图之前没有做任何不必要的工作。
如果您想要单个坐标的静态地图,请查看Google Maps Static Maps API。您的应用可以获取图像一次,自行缓存,然后在用户必须看到它时显示它。当用户改变他们的位置时(我假设它不经常),然后重新获取静态地图。
截至2017年1月,该链接应为https://developers.google.com/maps/documentation/static-maps/intro