获取高德地图

MainActivity:

package com.example.hugo.thistest;

import android.annotation.TargetApi;
import android.app.Activity;
import android.os.Build;
import android.os.Bundle;

import com.amap.api.maps.AMap;
import com.amap.api.maps.MapFragment;
import com.amap.api.maps.TextureMapFragment;
import com.example.hugo.thistest.R;

/**
* 基本地图(TextureMapFragment)实现
*/
public class BaseTextureMapFragmentActivity extends Activity {
private AMap mMap;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.basemap_texture_fragment_activity);
setUpMapIfNeeded();

setTitle("基本地图(TextureMapFragment)");
}

@Override
protected void onResume() {
super.onResume();
setUpMapIfNeeded();
}

@Override
protected void onDestroy(){
super.onDestroy();
}

/**
* 获取Amap 对象
*/
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private void setUpMapIfNeeded() {
if (mMap == null) {
mMap = ((TextureMapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
}
}

}
XML:


android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.amap.api.maps.TextureMapFragment" />

AndroidManifest:

package="com.example.hugo.thistest">
























android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
android:name="com.amap.api.v2.apikey"
android:value="014f639f92eb36a835297c46b9b52b0a">
























build.garder中dependencies添加:
compile 'com.jakewharton:butterknife:8.5.1'
//定位依赖
compile 'com.amap.api:location:latest.integration'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'
相关的包以及So文件加载方式

获取高德地图_第1张图片

 

你可能感兴趣的:(获取高德地图)