2016-06-01 5 views
0

私は、OSMdroidライブラリを使ってポリラインでオフラインマップを表示しようとしています。すべてがうまくいっていて、アンドロイド携帯のバージョンは何もありません。osmdroidが(サムスンS5のようなモバイルで)タイルを読み込んでいます。

しかし、Samsung s5またはLG g4でコードを実行するとコードの実行が停止し、オフラインマップのタイルがロードされないため、その半分だけを読み込みます。私が得る例外は:OutofmemoryErrorビットマップを読み込んでいる、タイルをロード中のエラー、メモリ不足例外などです。この問題を解決するのを手伝ってください。 私の英語は申し訳ありません!ありがとうございました! 私のコード:/ストレージ/ sdcard0/osmdroid /タイルにロードされたタイルをキャッシュosmdroid Androidデバイス上で

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 /」...

からファイルを削除する必要が

に残っenoughtスペースがない場合は

関連する問題