支持国产操作系统国产应用!

捉蛋网

一步步教你用Android Google Map(3)

时间:2011-03-12 17:27来源:未知 作者:捉蛋网 点击:
super.onCreate(savedInstanceState); setContentView(R.layout.main); mapView = (MapView) findViewById(R.id.map_view); mapView.setBuiltInZoomControls( true ); } @Override protected boolean isRouteDispla

        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        mapView = (MapView) findViewById(R.id.map_view);      
        mapView.setBuiltInZoomControls(
true);
        
    }

    @Override
    protected
boolean isRouteDisplayed() {
        return
false;
    }
    
}
  而相应的界面xml文件如下:
<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout
xmlns:android
="http://schemas.android.com/apk/res/android"
android:orientation
="vertical"
android:layout_width
="fill_parent"
android:layout_height
="fill_parent">

<com.google.android.maps.MapView
  xmlns:android
="http://schemas.android.com/apk/res/android"
  android:id
="@+id/map_view"
  android:layout_width
="fill_parent"
  android:layout_height
="fill_parent"
  android:clickable
="true"
  android:enabled
="true"
  android:apiKey
="API-KEY-HERE" />
  
</RelativeLayout>

 

  注意,其中要把你获得的Google Map的API KEY写到MapView控件中去。最后,记得在AndroidManifest.xml配置文件中,加上对Internet和Map的使用访问权限,其中由于Google Map的API是另外提供的API,因此也需要使用use-library (责任编辑:捉蛋网-刷机)

............................................................................................... ...............................................................................................

 

顶一下
(0)
0%
踩一下
(0)
0%
------分隔线----------------------------
栏目列表
推荐内容