2016-06-01 2 views
0

OSMdroid 라이브러리를 사용하여 폴리 라인이있는 오프라인지도를 표시하려고합니다. 모든 것이 잘되고, 안드로이드 모바일의 버전이 없습니다.osmdroid가 (삼성 S5와 같은 모바일에서) 타일 로딩 중 오류가 발생했습니다.

그러나 삼성 s5 또는 LG g4에서 코드를 실행하면 코드 실행이 중단되고 오프라인지도 타일이로드되지 않고 절반 만로드됩니다. 내가 얻을 수있는 예외는 : OutofmemoryError로드 비트 맵, 타일 로딩 오류, 메모리 부족 예외 등입니다. 제발이 문제를 해결하는 데 도움이됩니다. 영어로 유감입니다! 고맙습니다! 내 코드 :/저장/sdcard0/osmdroid/타일에로드 된 타일을 캐시 osmdroid 내 안드로이드 장치에

try{ 

    NameofJsonFile = ((MainFragmentActivityRoutes)getActivity()).getNameofJsonFile(); 



//android:layerType="" 

      mMapView = (MapView) v.findViewById(R.id.mapview2); 
      mMapView.setTileSource(TileSourceFactory.MAPNIK); 
      mMapView.setBuiltInZoomControls(true); 
      mMapView.setUseDataConnection(false); 

      mMapView.setMinZoomLevel(minZoom); 
      mMapView.setMaxZoomLevel(maxZoom); 
      mMapController = (MapController) mMapView.getController(); 
      mMapController.setZoom(minZoom); 


     if(cordinates==null){ 
       Log.e("", "edooooooo!!!"); 
       cordinates= new myasinc().execute(NameofJsonFile).get(); 

     } 


     //almopia prosoxi edo o xartis einai etoimos  
     GeoPoint locationStart = new GeoPoint((double) ((ArrayList<?>)cordinates.getFeatures().get(0).getGeometry().getCoordinates().get(0)).get(1), (double)((ArrayList<?>)cordinates.getFeatures().get(0).getGeometry().getCoordinates().get(0)).get(0)); 
     GeoPoint locationEnd = new GeoPoint(new GeoPoint((double) ((ArrayList<?>)cordinates.getFeatures().get(0).getGeometry().getCoordinates().get(cordinates.getFeatures().get(0).getGeometry().getCoordinates().size()-1)).get(1), (double)((ArrayList<?>)cordinates.getFeatures().get(0).getGeometry().getCoordinates().get(cordinates.getFeatures().get(0).getGeometry().getCoordinates().size()-1)).get(0))); 
     // 

     mMapController.setCenter(locationStart); 
     mMapController.animateTo(locationStart); 
     anotherOverlayItemArray = new ArrayList<OverlayItem>(); 

     OverlayItem item = new OverlayItem("0, 0", "0, 0",locationStart); 
     sample = ResourcesCompat.getDrawable(getResources(), R.drawable.start, null); 
     marker = new BitmapDrawable(getResources(), Bitmap.createScaledBitmap(((BitmapDrawable) sample).getBitmap(), 60, 60, true)); 
     item.setMarker(marker); 
     anotherOverlayItemArray.add(item); 


     item = new OverlayItem("0, 0", "0, 0",locationEnd); 
     sample = ResourcesCompat.getDrawable(getResources(), R.drawable.end, null); 
     marker = new BitmapDrawable(getResources(), Bitmap.createScaledBitmap(((BitmapDrawable) sample).getBitmap(), 60, 60, true)); 
     item.setMarker(marker); 
     anotherOverlayItemArray.add(item); 


     resourceProxy = new DefaultResourceProxyImpl(getActivity()); 
     anotherItemizedIconOverlay= new ItemizedIconOverlay<OverlayItem>(anotherOverlayItemArray, marker, null, resourceProxy); 
     mMapView.getOverlays().add(anotherItemizedIconOverlay); 


     Polyline line = new Polyline(getActivity()); 
     line.setSubDescription(Polyline.class.getCanonicalName()); 
     line.setWidth(2f); 
     ArrayList<GeoPoint> pts = new ArrayList<>(); 
     //here, we create a polygon, note that you need 5 points in order to make a closed polygon (rectangle) 

     mMapView.getOverlayManager().add(line); 

      for(int i=0; i<cordinates.getFeatures().get(0).getGeometry().getCoordinates().size(); i++){ 

        if(i%2==0){ 
         pts.add(new GeoPoint((double) ((ArrayList<?>)cordinates.getFeatures().get(0).getGeometry().getCoordinates().get(i)).get(1), (double)((ArrayList<?>)cordinates.getFeatures().get(0).getGeometry().getCoordinates().get(i)).get(0))); 

        } 

       } 


    line.setPoints(pts); 
    line.setGeodesic(true); 

     Iterator<Overlay> iterator = mMapView.getOverlays().iterator(); 
    while(iterator.hasNext()){ 
     Overlay next = iterator.next(); 
     if (next instanceof TilesOverlay){ 
      TilesOverlay x = (TilesOverlay)next; 
      x.setOvershootTileCache(x.getOvershootTileCache() * 2); 
      Toast.makeText(getActivity(), "Tiles overlay cache set to " + x.getOvershootTileCache(), Toast.LENGTH_LONG).show(); 
      break; 
     } 
    } 

} catch(Exception e){ 

} 

답변

0

......

/저장/sdcard0/당신이 얻을 "메모리 부족 예외"당신이 "/ 저장/sdcard0 /"...

에서 파일을 제거해야

에 남아있는 한 정도로 공간이없는 경우

관련 문제