0

i have made a seekbar zoom controler for my map view as follows

myZoomBar = (SeekBar)findViewById(R.id.zoombar); SetZoomLevel(); myZoomBar.setOnSeekBarChangeListener(myZoomBarOnSeekBarChangeListener); 

and

private SeekBar.OnSeekBarChangeListener myZoomBarOnSeekBarChangeListener = new SeekBar.OnSeekBarChangeListener(){ public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { // TODO Auto-generated method stub SetZoomLevel(); } public void onStartTrackingTouch(SeekBar seekBar) { // TODO Auto-generated method stub } public void onStopTrackingTouch(SeekBar seekBar) { // TODO Auto-generated method stub } }; private void SetZoomLevel() { int myZoomLevel = myZoomBar.getProgress()+1; mc.setZoom(myZoomLevel); Toast.makeText(this, "Zoom Level : " + String.valueOf(myZoomLevel), Toast.LENGTH_LONG).show(); }; 

my question is how can i set the default view level to 15? As it is right now when the map opens it is zoomed out all the way.

2
  • are you asking how to set zoom to levele 15 when the map is displayed intially Commented May 11, 2011 at 4:58
  • yes so when you open the map the zoom is set at 15 and the slider can be moved from there if needed. Commented May 11, 2011 at 5:18

2 Answers 2

6

try below code

MaView mapView = (MapView)findViewById(R.id.my_map); MapController mapController = mapView.getController(); mapController.setZoom(15); 
Sign up to request clarification or add additional context in comments.

4 Comments

are you sure that your mapcontroller is fetched from Mapview
if i do this p = new GeoPoint((int) (latitude * 1000000), (int) (longitude * 1000000)); mc = mapView.getController(); mc.setCenter(p); myZoomBar = (SeekBar)findViewById(R.id.zoombar); SetZoomLevel(); myZoomBar.setOnSeekBarChangeListener(myZoomBarOnSeekBarChangeListener); mc.setZoom(15); it sets the view to 15 but the seekbar still shows 0 is there a way to set it at 15 as well?
what your problem zooming of mapview or seekbar position if later is the case post your xml for seekbar
Thanks for the hint added android:progress="15" to the XML and all works the way i need.
0

Use setZoom() method of MapController class in your MapActivity .

1 Comment

if i add mc.setZoom(15); it doesn't do anything

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.