android studio api25中高德地图api定位小蓝点怎么设置

云栖社区()为您免费提供高德地图小篮点不显示相关的问答和话题,同时为你提供高德地图不显示小蓝点,高德地图显示大小,高德地图定位点小图标,高德地图获取小区边界,小米高德地图导航不走等,云栖社区以分享专业、优质、高效的技术为己任,帮助技术人快速成长与发展!您好!AMap.clear()方法,将地图上全部的覆盖物都清除,包括定位的小蓝点。如果不想清除定位的图标,有两种方法:方法一:将自定以的marker存好,清除时,调用marker.remove()方法,删除指定的marker。方法二:不使用locationsource,自己实现在定位回调中自己绘制定位的marker和精度圈。
阅读(...) 评论()Android之高德地图SDK配置及简单使用详解 - 博客频道 - CSDN.NET
ygd1994的专栏
分类:安卓学习
需要用到的东西请去下载
本次教程是对比着高德官网的demo一步步添加东西,所以需要有一份demo就够了。
1.打开高德地图的demo(AMap3DDemo),同时新建一个项目
2.将demo中的带Amap的三个jar包复制到新建项目的lib目录下,同时添加依赖项
3.在app下新建个directory—&jniLibs,然后在下面新建四个目录,如下:
4.然后拖到main方法中,在android下就可以看到
5.然后再demo下的so文件都放在四个目录下(四个目录放的东西一样)
6.将demo里面的权限复制到相应位置
7.将meta标签复制到相应位置同时去高德API官网申请个key填到相应位置
8.将下面服务那句也复制到相应位置
9.在布局中添加个MapView
10.将主函数中location文件夹下的LocationModeSourceActivity.java中有用的东西复制到主函数中
以上,就可以实现最简单的定位
清单文件:
&?xml version="1.0" encoding="utf-8"?&
xmlns:android="/apk/res/android"
package="com.example.ygd.myamap"&
android:name="android.permission.INTERNET" /&
android:name="android.permission.WRITE_EXTERNAL_STORAGE" /&
android:name="android.permission.ACCESS_COARSE_LOCATION" /&
android:name="android.permission.ACCESS_NETWORK_STATE" /&
android:name="android.permission.ACCESS_FINE_LOCATION" /&
android:name="android.permission.READ_PHONE_STATE" /&
android:name="android.permission.CHANGE_WIFI_STATE" /&
android:name="android.permission.ACCESS_WIFI_STATE" /&
android:name="android.permission.CHANGE_CONFIGURATION" /&
android:name="android.permission.WAKE_LOCK" /&
android:name="android.permission.WRITE_SETTINGS" /&
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme"&
android:name="com.amap.api.v2.apikey"
android:value="50bde4dbfa4ee6bd79756fc" /&
android:name=".MainActivity"&
android:name="android.intent.action.MAIN" /&
android:name="android.intent.category.LAUNCHER" /&
android:name="com.amap.api.location.APSService" &
public class MainActivity extends AppCompatActivity implements LocationSource,
AMapLocationListener {
private MapView mapV
private AMap aM
private AMapLocationClient mlocationC
private OnLocationChangedListener mL
private AMapLocationClientOption mLocationO
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mapView= (MapView) findViewById(R.id.map);
mapView.onCreate(savedInstanceState);
private void init() {
if (aMap == null) {
aMap = mapView.getMap();
setUpMap();
* 设置一些amap的属性
private void setUpMap() {
aMap.setLocationSource(this);
aMap.getUiSettings().setMyLocationButtonEnabled(true);
aMap.setMyLocationEnabled(true);
aMap.setMyLocationType(AMap.LOCATION_TYPE_LOCATE);
* 定位成功后回调函数
public void onLocationChanged(AMapLocation amapLocation) {
if (mListener != null && amapLocation != null) {
if (amapLocation != null
&& amapLocation.getErrorCode() == 0) {
Log.d("===经度:",""+amapLocation.getLongitude());
Log.d("===纬度:",""+amapLocation.getLatitude());
mListener.onLocationChanged(amapLocation);
String errText = "定位失败," + amapLocation.getErrorCode()+ ": " + amapLocation.getErrorInfo();
Log.e("AmapErr",errText);
* 激活定位
public void activate(OnLocationChangedListener listener) {
mListener =
if (mlocationClient == null) {
mlocationClient = new AMapLocationClient(this);
mLocationOption = new AMapLocationClientOption();
mlocationClient.setLocationListener(this);
mLocationOption.setLocationMode(AMapLocationClientOption.AMapLocationMode.Hight_Accuracy);
mlocationClient.setLocationOption(mLocationOption);
mlocationClient.startLocation();
* 停止定位
public void deactivate() {
mListener = null;
if (mlocationClient != null) {
mlocationClient.stopLocation();
mlocationClient.onDestroy();
mlocationClient = null;
* 方法必须重写
protected void onResume() {
super.onResume();
mapView.onResume();
* 方法必须重写
protected void onPause() {
super.onPause();
mapView.onPause();
deactivate();
* 方法必须重写
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
mapView.onSaveInstanceState(outState);
* 方法必须重写
protected void onDestroy() {
super.onDestroy();
mapView.onDestroy();
if(null != mlocationClient){
mlocationClient.onDestroy();
布局文件中添加一个MapView即可
&com.amap.api.maps.MapView
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent" &
&/com.amap.api.maps.MapView&
遇到的错误:(下面这句报错)
mapView.onCreate(savedInstanceState)
错误类型:java.lang.UnsatisfiedLinkError: Native method not found: com.autonavi.amap.mapcore.MapCore.nativeNewInstance:(Ljava/lang/SLjava/lang/S)J
解决方法:将主函数中继承的v7包的AppCompatActivity改为Activity即可。
排名:千里之外
(4)(45)(9)简单的demo:https://my.oschina.net/zhangqie/blog/845488
SHA1值的获取:参考高德官网:/faq/top/hot-questions/253/
publicstatic String sHA1(Context context) {
PackageInfo info = context.getPackageManager().getPackageInfo(
context.getPackageName(), PackageManager.GET_SIGNATURES);
byte[] cert = info.signatures[0].toByteArray();
MessageDigest md = MessageDigest.getInstance(&SHA1&);
byte[] publicKey = md.digest(cert);
StringBuffer hexString = new StringBuffer();
for (int i = 0; i & publicKey. i++) {
String appendString = Integer.toHexString(0xFF & publicKey[i])
.toUpperCase(Locale.US);
if (appendString.length() == 1)
hexString.append(&0&);
hexString.append(appendString);
hexString.append(&:&);
String result = hexString.toString();
return result.substring(0, result.length()-1);
} catch (NameNotFoundException e) {
e.printStackTrace();
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
注意要去掉得到的result的最后的:
&&相关文章推荐
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:1281次
排名:千里之外
原创:11篇
转载:13篇
(1)(11)(6)(6)

我要回帖

更多关于 android studio api 的文章

 

随机推荐