开发者

set default zoom level on mapView

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 =
 开发者_如何学Python          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.


try below code

MaView mapView = (MapView)findViewById(R.id.my_map);
MapController mapController = mapView.getController();
mapController.setZoom(15);  


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜