Sorry. My solution is useless. I misunderstood the processes of DDMS and maps library.
You don't have to inherit MapView class and override some methods of that class. Transfering image file from an emulator or a phone to my dev computer using DDMS takes long time, about one more minute. So, I thought that the image file creating was faild at that time.... The codes that palce on top of this thread is no problem programmatically. Just attach one button or menu and move the saving codes from onCreate method to other method which would be called by EventLister of the button or menu. On Aug 24, 3:57 pm, idoun <[email protected]> wrote: > I solved this problem. > > The main issue of this problem is that theMapViewclass extends View > class has "0" value of width and height. (I think every View classes > have this issue...) > > To set the right size what I want, I extended theMapViewto MyMapView > and overrided protected onSizeChanged method into MyMapView. > > And I called that method before saving the map. > > Then It works! > > Additionally, I should attach menu button to my app. for saving the > map because the loading method of the map is asynchronous as you > know.... > Saving process is ended before loading the map if the process is in > the onCreate method. :) > > On Aug 21, 9:10 pm, idoun <[email protected]> wrote: > > > Dear Developers! > > > I'm trying to develop a map application which can save some part of > > map inside a phone. > > > So, refering to the example of google developer site, I created my > > activity that using theMapViewclass to display the location what I > > want to see. It works. > > > And I attached some code to save that view into png format file using > > Bitmap and Canvas classes. But it didn't work. > > > One image file was created but it didn't contain any information of > > the map. I don't know the reason why those codes didn't work and > > couldn't find any related information on the Web... > > > code is... > > > public class AndroidTest extends MapActivity { > > > MapViewmapView; > > List<Overlay> mapOverlays; > > Drawable drawable; > > HelloItemizedOverlay itemizedOverlay; > > > /** Called when the activity is first created. */ > > @Override > > public void onCreate(Bundle savedInstanceState) { > > super.onCreate(savedInstanceState); > > setContentView(R.layout.main); > > > // build map and mark point > > mapView= (MapView) findViewById(R.id.mapview); > > mapView.setBuiltInZoomControls(true); > > > mapOverlays =mapView.getOverlays(); > > drawable = this.getResources().getDrawable > > (R.drawable.androidmarker); > > itemizedOverlay = new HelloItemizedOverlay(drawable); > > > GeoPoint point = new GeoPoint(19240000, -99120000); > > OverlayItem overlayitem = new OverlayItem(point, "", ""); > > > itemizedOverlay.addOverlay(overlayitem); > > mapOverlays.add(itemizedOverlay); > > > // copyMapViewto canvas > > Bitmap bitmap = Bitmap.createBitmap(400, 800, > > Bitmap.Config.ARGB_8888); > > Canvas canvas = new Canvas(bitmap); > > mapView.draw(canvas); > > > // save it! > > FileOutputStream fo = null; > > > try { > > fo = this.openFileOutput("test.png", > > Context.MODE_WORLD_WRITEABLE); > > } catch (FileNotFoundException e) { > > e.printStackTrace(); > > } > > > bitmap.compress(CompressFormat.PNG, 100, fo); > > > try { > > fo.flush(); > > } catch (IOException e) { > > e.printStackTrace(); > > } > > > try { > > fo.close(); > > } catch (IOException e) { > > e.printStackTrace(); > > } > > } > > > Please, help! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---

