安卓开发

android高德地图开发

使用 keytool(jdk自带工具)获取SHA1

,按照如下步骤进行操作:

2.在弹出的控制台窗口中输入 cd .android 定位到 .android 文件夹。

3.继续在控制台输入命令。

debug.keystore:命令为:keytool -list -v -keystore debug.keystore

自定义的 keystore:命令为:keytool -list -v -keystore apk的keystore

提示输入密钥库密码,编译器提供的debug keystore默认密码是 android,自定义签名文件的密码请自行填写。输入密钥后回车(如果没设置密码,可直接回车),此时可在控制台显示的信息中获取 SHA1 值,如下图所示:

说明:keystore 文件为 Android 签名证书文件。

例子1:package com.example.lenovo.mydemoapp;import android.content.Intent;import android.graphics.Point;import android.os.PersistableBundle;import android.support.annotation.Nullable;import android.support.v7.app.AppCompatActivity;import android.os.Bundle;import android.util.Log;import android.view.View;import android.view.ViewGroup;import android.widget.SeekBar;import android.widget.TextView;import android.widget.Toast;import com.amap.api.location.AMapLocation;import com.amap.api.location.AMapLocationClient;import com.amap.api.location.AMapLocationClientOption;import com.amap.api.location.AMapLocationListener;import com.amap.api.maps.AMap;import com.amap.api.maps.AMapUtils;import com.amap.api.maps.CameraUpdateFactory;import com.amap.api.maps.LocationSource;import com.amap.api.maps.MapView;import com.amap.api.maps.UiSettings;import com.amap.api.maps.model.CameraPosition;import com.amap.api.maps.model.LatLng;import java.text.SimpleDateFormat;import java.util.Date;/*name:编辑安全区time:2018-06-09 11:32:22Can Enter:1.安全区信息确认 SafeAreaConfirmationreturn:1.高德地图的经纬度坐标值 2.围栏的半径大小returnActivity:1.安全区*/// LocationSource 定位按键的监听接口public class EditSafeArea extends AppCompatActivity implements LocationSource,AMap.OnCameraChangeListener,AMapLocationListener {private SeekBar mSeekBar ;//半径显示的文本Viewprivate TextView mRadiusValue;private View mEditSafeAreaMapFence;//下一步private TextView mEditSafeAreaTheNextStepText;//aMap 地图对象private AMap aMap;//地图视图private MapView mapView;//声明AMapLocationClient 地图位置客户端 对象,定位发起端private AMapLocationClient mLocationClient = null;//声明mLocationOption 地图位置客户端选项 对象,定位参数 `public AMapLocationClientOption mLocationOption = null;//声明mListener对象,定位监听器private OnLocationChangedListener mListener = null;//标识,用于判断是否只显示一次定位信息和用户重新定位private boolean isFirstLoc = true;private AMapLocation aMapLocation ;private int mRadius;private LatLng mLatlng;private final String LATITUDE_KEY = “latitude_value”;private final String LONGITUDE_KEY = “longitude_value”;private final String RADIUS_KEY = “radius_value”;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.edit_safe_area);//围栏mEditSafeAreaMapFence = (View)findViewById(R.id.EditSafeArea_MapFence);//拖动条mSeekBar = (SeekBar)findViewById(R.id.EditSafeArea_SeekBar);//半径显示文本mRadiusValue = (TextView)findViewById(R.id.EditSafeArea_radius_value);//下一步mEditSafeAreaTheNextStepText = (TextView)findViewById(R.id.EditSafeArea_TheNextStep_text);//获取地图控件mapView = (MapView)findViewById(R.id.EditSafeArea_MapView);//在activity执行onCreate时执行mMapView.onCreate(savedInstanceState),实现地图生命周期管理mapView.onCreate(savedInstanceState);if(aMap == null){//创建地图对象aMap = mapView.getMap();//创建UI设置器UiSettings settings = aMap.getUiSettings();//地点变化监听器aMap.setLocationSource(this);//当前镜头变化监听器aMap.setOnCameraChangeListener(this);// 是否显示定位按钮settings.setMyLocationButtonEnabled(true);//定位图标是否可以点击aMap.setMyLocationEnabled(true);}//开始定位location();//设置拖动条默认值mSeekBar.setProgress(0);//设置拖动条默认值的显示 ,因为默认是400 所以这里添加400mRadiusValue.setText(Integer.toString(mSeekBar.getProgress()+400));//显示默认围栏的大小mEditSafeAreaMapFence.setLayoutParams(setFence());//拖动条监听mSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {@Overridepublic void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {//拖动条拖动后更新文本值mRadiusValue.setText(Integer.toString(progress+400));//更新围栏的范围mEditSafeAreaMapFence.setLayoutParams(setFence());}@Overridepublic

Similar Posts

发表评论

邮箱地址不会被公开。 必填项已用*标注