1.高德地图的基本操作:最简单的莫过于第一次加载地图
布局文件:basic_map.xml,在下面的操作中,未作特别说明都采用此布局文件。
<?xml version="1.0" encoding="utf-8"?>
<com.amap.api.maps.MapView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</com.amap.api.maps.MapView>
基本操作:第一次加载地图。
package com.dragon.arnav.basicFuction.basic;
import android.app.Activity;
import android.os.Bundle;
import com.amap.api.maps.AMap;
import com.amap.api.maps.MapView;
import com.dragon.arnav.R;
/**
* This file created by dragon on 2016/7/28 21:26,belong to com.dragon.arnav.basicFuction.basic .
*/
public class basicMap extends Activity {
private MapView mapView;
private AMap aMap;
@Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.basic_map);
mapView = (MapView) findViewById(R.id.map);
mapView.onCreate(savedInstanceState);
init();
}
private void init(){
if(aMap == null){
aMap = mapView.getMap();
}
}
@Override
protected void onResume(){
super.onResume();
mapView.onResume();
}
@Override
protected void onPause() {
super.onPause();
mapView.onPause();
}
@Override
protected void onDestroy(){
super.onDestroy();
mapView.onDestroy();
}
@Override
public void onSaveInstanceState(Bundle outState){
super.onSaveInstanceState(outState);
mapView.onSaveInstanceState(outState);
}
}
2.camera视图实战,包括移动、动画视图、停止等,来自官方的demo
布局文件:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical" >
<Button
android:id="@+id/stop_animation"
android:layout_width="40dip"
android:layout_height="40dip"
android:text="@string/stop_animation" />
<ToggleButton
android:id="@+id/animate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:textOff="@string/animate"
android:textOn="@string/animate" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >