为什么在高德地图评论删除手机APP上对某地进行点评以后,只有自己可以看见这条评论?

手机的定位功能关闭了,为什么高德地图里还能定位?_百度知道你们都不知道高德地图有多牛逼!我刚才步行导航,左边是条小河。。。。
&&首推于&07月27日 20:26
浏览(264)|回应(0)
你们都不知道高德地图有多牛逼!我刚才步行导航,左边是条小河,地图一直叫我左转,左转,我心想左边是条河啊,转你妈了个逼!结果往左边一看,我服了,这种路都找得到,高德你牛逼
(以上内容来自于网友投稿,如侵犯了您的相关权利,请点击
通知我们,我们将尽快予以删除。)
退出以后,该精选社将不会显示在您的首页
您发布的内容超过140字了,试试投稿功能吧
您发布的不能超过500字了!
您发布的内容已经超过500字了,您只能使用投稿功能发布
别忘了点击发布哦!
发布成功!
成功发布到审核区!
你为什么要举报此投稿?
举报说明:(可选)
成为小编才能给社长推荐哦!
我要当小编
举报成功!
收藏成功!
取消收藏成功!
您还没有认证为原创作者
若您先提交此文章,稍后认证,我们会将其自动添加到您的原创
先投稿稍后认证高德地图(语音导航)怎么样、高德地图(语音导航)好用么 使用心得 - 安软市场
安卓软件全免费 绿色安全有保障
手机访问 下载快更省流量||
关注安软微信
微信号:anruan666
使用微信「扫一扫」扫描二维码
> 软件评论
[软件评论]
高德地图是最好用的开车软件!
高德地图是我用过最好的开软件
高德地图大赞!我出门有时候为了找美食店,经常找不到路,用它最好,走路时,软件里的图标也会跟着动,知道自己和目的地的距离
开车语音导航我选择高德地图
这心台飞居卡
开车人士最好用的地图导航工具,高德地图
到古镇车站
到贞丰一中
不解释老司机专用,高德地图!
中山市大岭二手车市场
上一页首页1
三星:挺好的
四星:真不错
五星:太棒了
&& 或者 &&
深圳市艾秀信息技术有限公司
All Rights Reserved
&粤网文[号 &1447人阅读
高德地图开发记录(1)
高德开发记录:
请尊重原创,本原创博主为zs2538596--求知欲!!!
由于本人要做的APP是一个轨迹记录的一个应用,在最初的设计中没有考虑到手机在上锁休眠的时候会停止内部GPS和GPRS硬件,这样就不会获取坐标的信息,因此也就无法实时的进行绘制轨迹了。对于怎么简单的填充高德地图,怎么使用高德地图,在高德地图官网上有详细的说明哦!!
对于锁屏之后的一些状态的认识:
在手机锁屏状态下,基站信息是不会更新,位置信息不会发生变化。但是当解锁后,会重新请求定位,然后改变定位的位置。大家可以拿出自己的手机,看一下,当锁屏一段时间后,再打开手机解锁的时候可以看见手机信号从无变成了满BUFF~~.
对于Wifi或者GPRS这些东西,也可以观察到,当手机从休眠到-&锁屏界面再到-&解锁之后,那个Wifi信号会从无信号量转换到有信号,而那个GPRS信号图标也会从没有到有,而且会首先发送向上请求也就是获取基站的相关信息。
那么如何避免让这些硬件进行休眠呢?
1.如果对实时性要求不高,而且对耗电量要求较高的话建议使用 Alarm方式来定时唤醒,进行获取坐标,然后记录轨迹的操作。这种方法可以省些电量,而且每次Alarm间隔的时间越长那么则越省电。。。。
2.使用Andriod中的电源管理相关的API,这种方法可以让手机一直处于工作状态,这个技术做的“最好”的是微信!!!大家可以下载 Wakelock Detector APP观察一下自己的手机有多少应用是调用了相关的电源管理的API。用了之后你可以看到微信这个APP的始终名列前茅~~~,成为耗电量大老虎~~再此鄙视一下微信。当然我的小APP的应用也是采用了这种方法~~~但是程序关闭了之后就不会在后台继续工作~~只有在开启的过程中才会不让手机进入休眠状态。
因此本人用了一下的代码,这个代码可以轻松的在网络中找到~~获取电源管理的锁机制:
private WakeLock wakeLock =
private void acquireWakeLock() {
if (wakeLock == null) {
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
wakeLock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, this
.getClass().getCanonicalName());
wakeLock.acquire();
private void releaseWakeLock() {
if (wakeLock != null && wakeLock.isHeld()) {
wakeLock.release();
wakeLock =
}然后将获取锁机制放在Activity的onResume状态下,释放锁机制放在onPause状态下,让其成对出现,避免让该activity一直hold者不放~~
OK。。通过获取电源管理的方法解决了手机锁屏休眠的问题了,这样手机的GPS和GPRS就可以一直工作了~~~
如何解决实时定位的问题呢?由于Acitity有生命周期循环的限制,这样当用户进行一些操作的时候就会造成相应的Activity进入onPause等声明周期的状态,这样一些activiy相关的操作就不会进行了,所以最好采用Service的方法,即将定位的功能放在Service中来进行,然后让Activity与该Service进行通信即可。&
本人采用的方法为:Service绑定+Broadcast Reciver
1、绑定是为了可以让Activity获取到Service内部的一些操作方法
2、Broadcast Reciver方法是为了能够让Serivce中的信息能够实时的反馈到Acitvity的界面上,进行相关界面刷新的操作。
注:本APP中采用了科大讯飞的语音,代码中的XXX.playText为相关的语音操作~~~~
本人的Broadcast Reciver中进行了相关的轨迹记录和界面更新的操作,代码如下:
private IntentFilter filter = new IntentFilter(
StaticData.LOCATION_DATA_BRODCAST_INTENT);
private BroadcastReceiver receiver = new BroadcastReceiver() {
public void onReceive(Context context, Intent intent) {
provider = intent.getStringExtra(StaticData.PROVIDER);
if (latitude != intent.getDoubleExtra(StaticData.LATITUDE, 0)
&& longitude != intent.getDoubleExtra(StaticData.LONGITUDE,
if (start) {
latlng = new LatLng(latitude, longitude);
LatLng temp = new LatLng(intent.getDoubleExtra(
StaticData.LATITUDE, 0), intent.getDoubleExtra(
StaticData.LONGITUDE, 0));
float temp_distance = AMapUtils.calculateLineDistance(
latlng, temp);//计算行走的距离
if (provider.equals(&lbs&)) {//选择计算速度的方式
if (temp_distance &= 60) {
speed = temp_distance / 5 * 3.6;
totaldistance += temp_distance / 1000;
voice.playText(&当前速度为& + df.format(speed) + &千米每小时&);
speed = temp_distance / 5 * 3.6;
totaldistance += temp_distance / 1000;
voice.playText(&当前速度为& + df.format(speed)
+ &千米每小时,速度有些过快&);
} else if (provider.equals(&gps&)) {
speed = intent.getDoubleExtra(StaticData.SPEED, 0);
voice.playText(&当前速度为& + df.format(speed) + &千米每小时&);
if (speed &= maxspeed) {
maxspeed = (float)
speedtext.setText(&速度:& + df.format(speed) + &km/h&);//语音提示的相关操作
DrawRideTrace(latlng, temp);
latitude = intent.getDoubleExtra(StaticData.LATITUDE, 0);
longitude = intent.getDoubleExtra(StaticData.LONGITUDE, 0);
if (start) {
h = t / 3600;
m = t % 3600 / 60;
s = t % 3600 % 60;
timetext.setText(&时间:& + h + &h:& + m + &m:& + s + &s&);
if (m == 10) {
voice.playText(&您已经骑行& + df.format(totaldistance) + &千米&);
mlatitude = intent.getDoubleExtra(StaticData.LATITUDE, 0);
mlongitude = intent.getDoubleExtra(StaticData.LONGITUDE, 0);
if (closeinit && locationservice != null) {
duration++;
setLocationIcon();
if (duration == 6) {
duration = 0;
closeinit =
startup.setVisibility(View.GONE);
这个是我的相关后台的定位操作代码:
public class LocationService extends Service implements AMapLocationListener,
LocationSource {
private LocationManagerProxy mAMapLocationM
private Timer timer =
private TimerTask task =
private double latitude, longitude,
private Intent ServiceIntent =
private OnLocationChangedListener mL
private boolean change =
private AMapLocation mL
private VoiceS
private String provider =
// *****************定时发送Intent消息*******************
public void startTimer() {
if (timer == null) {
timer = new Timer();
task = new TimerTask() {
public void run() {
if (ServiceIntent == null) {
ServiceIntent = new Intent(
StaticData.LOCATION_DATA_BRODCAST_INTENT);
ServiceIntent.putExtra(StaticData.LATITUDE, latitude);
ServiceIntent.putExtra(StaticData.LONGITUDE, longitude);
ServiceIntent.putExtra(StaticData.SPEED, speed);
ServiceIntent.putExtra(StaticData.PROVIDER, provider);
sendBroadcast(ServiceIntent);
timer.schedule(task, );
public void stopTimer() {
if (timer != null) {
task.cancel();
timer.cancel();
public IBinder onBind(Intent intent) {
// TODO Auto-generated method stub
public final LocationServiceBinder servicebinder = new LocationServiceBinder();
public class LocationServiceBinder extends Binder {
public LocationService getLocationService() {
return LocationService.
public void onCreate() {
super.onCreate();
startTimer();
VoiceService VoiceManager = VoiceService.getInstance(this);// 语音初始化
VoiceManager.init();
voice = VoiceM
mAMapLocationManager = LocationManagerProxy.getInstance(this);
mAMapLocationManager.requestLocationData(
LocationProviderProxy.AMapNetwork, 5 * 1000, 10, this);
mAMapLocationManager.setGpsEnable(true);
public void onDestroy() {
stopTimer();
deactivate();
super.onDestroy();
// service重启需要进行的操作
public int onStartCommand(Intent intent, int flags, int startId) {
if (mAMapLocationManager != null) {
startTimer();
mAMapLocationManager.requestLocationData(
LocationProviderProxy.AMapNetwork, 5 * 1000, 10, this);
if (voice == null) {
VoiceService VoiceManager = VoiceService.getInstance(this);// 鍒濆?鍖栬?闊虫ā鍧?
VoiceManager.init();
voice = VoiceM
return START_STICKY;
// service内部变量获取函数
public OnLocationChangedListener getonLocationChanged() {
public AMapLocation getLocaion() {
public VoiceService getVoice() {
// **********************相关定位操作**********************
public void onLocationChanged(Location location) {
//已经废除,采用高德提供的函数接口
public void onStatusChanged(String provider, int status, Bundle extras) {
public void onProviderEnabled(String provider) {
public void onProviderDisabled(String provider) {
public void onLocationChanged(AMapLocation aLocation) {
if (mListener != null && aLocation != null
&& aLocation.getAMapException().getErrorCode() == 0) {
latitude = aLocation.getLatitude();
longitude = aLocation.getLongitude();
if (aLocation.getProvider().equals(&gps&)) {
speed = aLocation.getSpeed();
provider = &gps&;
} else if (aLocation.getProvider().equals(&lbs&)) {
provider = &lbs&;
mListener.onLocationChanged(aLocation);
//实现LocationSource接口必须实现的方法
public void activate(OnLocationChangedListener listener) {
mListener =
if (mAMapLocationManager == null) {
mAMapLocationManager = LocationManagerProxy.getInstance(this);
mAMapLocationManager.requestLocationData(
LocationProviderProxy.AMapNetwork, 5 * 1000, 10, this);
mAMapLocationManager.setGpsEnable(true);
public void deactivate() {
mListener =
if (mAMapLocationManager != null) {
mAMapLocationManager.setGpsEnable(false);
mAMapLocationManager.removeUpdates(this);
mAMapLocationManager.destory();
mAMapLocationManager =
&/pre&&p&&/p&&pre&这段代码是使用定位源的地方:
private void setLocationIcon() {
// 自定义系统定位小蓝点
MyLocationStyle myLocationStyle = new MyLocationStyle();
myLocationStyle.myLocationIcon(BitmapDescriptorFactory
.fromResource(R.drawable.location_marker));
myLocationStyle.strokeColor(Color.TRANSPARENT);// 设置圆形的边框颜色
myLocationStyle.radiusFillColor(Color.argb(100, 0, 0, 180));// 设置圆形的填充颜色
myLocationStyle.strokeWidth(0.1f);// 设置圆形的边框粗细
aMap.setMyLocationStyle(myLocationStyle);
aMap.setLocationSource(locationservice);//使用定位源的地方~~~~~~~~~~~~~~~~~~~~~~~~通过这个定位源就可以实时更细小蓝点的位置了
aMap.setMyLocationEnabled(true);
getMapMode();
这个是我的主体Acitivity代码:
public class MainMap extends Activity implements OnClickListener,
ServiceConnection {
private MapView mapV
private AMap aM
private UiSettings mUiS
private ImageButton btn_traffic_
// private ImageButton btn_ride_
private boolean select =
private LocationService locationservice =
private PopupWindow mPopupWindow =
private PopupWindow PopupWindowlayer =
private View vPop =
private View vPop_layer =
private Button btn_
private ImageButton btn_zoom_in, btn_zoom_out, btn_// btn_
private Button btn_begin_record, btn_clear_route, btn_personel_record,
btn_cancel, btn_map_normal, btn_map_satellite, btn_map_3d,
private RelativeL
private LinearLayout record_
private TextView speedtext,
private float totaldistance = 0;
private float maxspeed = 0;
private boolean start =
private boolean change =
private boolean layselect =
private long lastClickTime = 0;
private long h, m, s,
// *************************绑定service相关操作*****************
private Intent ServiceIntent =
private double latitude = 0;
private double longitude = 0;
private double mlatitude = 0;
private double mlongitude = 0;
private double speed = 0;
private LatL
private boolean closeinit =
private int mapmode = 0;
private DecimalFormat df = new DecimalFormat(&#0.00&);
private int duration = 0;
private VoiceService voice =
private String provider =
// *************************设置监听器********************
private IntentFilter filter = new IntentFilter(
StaticData.LOCATION_DATA_BRODCAST_INTENT);
private BroadcastReceiver receiver = new BroadcastReceiver() {//broadcast reciver接收器相关的操作
public void onReceive(Context context, Intent intent) {
provider = intent.getStringExtra(StaticData.PROVIDER);
if (latitude != intent.getDoubleExtra(StaticData.LATITUDE, 0)
&& longitude != intent.getDoubleExtra(StaticData.LONGITUDE,
if (start) {
latlng = new LatLng(latitude, longitude);
LatLng temp = new LatLng(intent.getDoubleExtra(
StaticData.LATITUDE, 0), intent.getDoubleExtra(
StaticData.LONGITUDE, 0));
float temp_distance = AMapUtils.calculateLineDistance(
latlng, temp);
if (provider.equals(&lbs&)) {
if (temp_distance &= 60) {
speed = temp_distance / 5 * 3.6;
totaldistance += temp_distance / 1000;
voice.playText(&当前速度为& + df.format(speed) + &千米每小时&);
speed = temp_distance / 5 * 3.6;
totaldistance += temp_distance / 1000;
voice.playText(&当前速度为& + df.format(speed)
+ &千米每小时,速度有些过快&);
} else if (provider.equals(&gps&)) {
speed = intent.getDoubleExtra(StaticData.SPEED, 0);
voice.playText(&当前速度为& + df.format(speed) + &千米每小时&);
if (speed &= maxspeed) {
maxspeed = (float)
speedtext.setText(&速度:& + df.format(speed) + &km/h&);
DrawRideTrace(latlng, temp);
latitude = intent.getDoubleExtra(StaticData.LATITUDE, 0);
longitude = intent.getDoubleExtra(StaticData.LONGITUDE, 0);
if (start) {
h = t / 3600;
m = t % 3600 / 60;
s = t % 3600 % 60;
timetext.setText(&时间:& + h + &h:& + m + &m:& + s + &s&);
if (m == 10) {
voice.playText(&您已经骑行& + df.format(totaldistance) + &千米&);
mlatitude = intent.getDoubleExtra(StaticData.LATITUDE, 0);
mlongitude = intent.getDoubleExtra(StaticData.LONGITUDE, 0);
if (closeinit && locationservice != null) {
duration++;
setLocationIcon();
if (duration == 6) {
duration = 0;
closeinit =
startup.setVisibility(View.GONE);
// **********************电源管理机制****************************
private WakeLock wakeLock =
private void acquireWakeLock() {
if (wakeLock == null) {
System.out.println(&Get lock&);
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
wakeLock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, this
.getClass().getCanonicalName());
wakeLock.acquire();
private void releaseWakeLock() {
if (wakeLock != null && wakeLock.isHeld()) {
System.out.println(&Release LOCK&);
wakeLock.release();
wakeLock =
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// R 需要引用包import com.amapv2.apis.R;
setContentView(R.layout.main_map);
mapView = (MapView) findViewById(R.id.map);
mapView.onCreate(savedInstanceState);// 必须要写
private void init() {
if (aMap == null) {
aMap = mapView.getMap();
setVolumeControlStream(AudioManager.STREAM_MUSIC);// 设置声音控制
initComponent();
setMapUi();
mstartService();
setTraffic();
getPopView();
getMaplayer();
private void mstartService() {
if (ServiceIntent == null) {
ServiceIntent = new Intent(MainMap.this, LocationService.class);
bindService(ServiceIntent, this, Context.BIND_AUTO_CREATE);
private void mstopService() {
unbindService(this);
ServiceIntent =
private void initComponent() {
startup = (RelativeLayout) findViewById(R.id.start_up_picture);
record_panel = (LinearLayout) findViewById(R.id.record_panel);
record_panel.setVisibility(View.GONE);
speedtext = (TextView) findViewById(R.id.speed_text);
timetext = (TextView) findViewById(R.id.time_text);
btn_traffic_condition = (ImageButton) findViewById(R.id.btn_traffic_condition);
btn_traffic_condition.setOnClickListener(this);
btn_clock = (Button) findViewById(R.id.btn_clock);
btn_clock.setOnClickListener(this);
btn_zoom_in = (ImageButton) findViewById(R.id.btn_zoom_in);
btn_zoom_in.setOnClickListener(this);
btn_zoom_out = (ImageButton) findViewById(R.id.btn_zoom_out);
btn_zoom_out.setOnClickListener(this);
btn_layer = (ImageButton) findViewById(R.id.btn_layer);
btn_layer.setOnClickListener(this);
btn_cancel = (Button) findViewById(R.id.btn_cancel);
btn_cancel.setOnClickListener(this);
btn_cancel.setVisibility(View.GONE);
btn_route = (Button) findViewById(R.id.btn_route);
btn_route.setOnClickListener(this);
// btn_box = (ImageButton) findViewById(R.id.btn_box);
// btn_box.setOnClickListener(this);
// 配置mapUI界面
private void setMapUi() {
mUiSettings = aMap.getUiSettings();
mUiSettings.setMyLocationButtonEnabled(false);
mUiSettings.setZoomControlsEnabled(false);
mUiSettings.setLogoPosition(AMapOptions.LOGO_POSITION_BOTTOM_LEFT);
mUiSettings.setMyLocationButtonEnabled(false);// 设置默认定位按钮是否显示
// 设置定位的类型为定位模式 ,可以由定位、跟随或地图根据面向方向旋转几种
private void setLocationIcon() {
// 自定义系统定位小蓝点
MyLocationStyle myLocationStyle = new MyLocationStyle();
myLocationStyle.myLocationIcon(BitmapDescriptorFactory
.fromResource(R.drawable.location_marker));
myLocationStyle.strokeColor(Color.TRANSPARENT);// 设置圆形的边框颜色
myLocationStyle.radiusFillColor(Color.argb(100, 0, 0, 180));// 设置圆形的填充颜色
myLocationStyle.strokeWidth(0.1f);// 设置圆形的边框粗细
aMap.setMyLocationStyle(myLocationStyle);
aMap.setLocationSource(locationservice);//设置定位源
aMap.setMyLocationEnabled(true);
getMapMode();
// 配置显示道路情况的一些设置
private void setTraffic() {
MyTrafficStyle myTrafficStyle = new MyTrafficStyle();
myTrafficStyle.setSeriousCongestedColor(0xff92000a);
myTrafficStyle.setCongestedColor(0xffea0312);
myTrafficStyle.setSlowColor(0xffff7508);
myTrafficStyle.setSmoothColor(0xff00a209);
aMap.setMyTrafficStyle(myTrafficStyle);
// ************************对于相关后台Service连接的操作*********************
public void onServiceConnected(ComponentName name, IBinder service) {
// 取得location service实例
locationservice = ((LocationService.LocationServiceBinder) service)
.getLocationService();//获取后台service内部变量的操作
voice = locationservice.getVoice();//获取语音提示功能
// ClearSQL();
// 在service崩溃时触发
public void onServiceDisconnected(ComponentName name) {
// TODO Auto-generated method stub
// ********************************popupwindow初始化************************
private void getPopView() {
LayoutInflater inflater = (LayoutInflater) this
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
vPop = inflater.inflate(R.layout.clock_list_menu, null, false);
vPop.setFocusable(true);
vPop.setFocusableInTouchMode(true);
btn_begin_record = (Button) vPop.findViewById(R.id.btn_begin_record);
btn_begin_record.setOnClickListener(this);
btn_clear_route = (Button) vPop.findViewById(R.id.btn_clear_route);
btn_clear_route.setOnClickListener(this);
btn_personel_record = (Button) vPop
.findViewById(R.id.btn_personel_record);
btn_personel_record.setOnClickListener(this);
mPopupWindow = new PopupWindow(vPop, LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT, true);
mPopupWindow.setAnimationStyle(R.style.popupstyle);
mPopupWindow.setFocusable(true);
vPop.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
if (mPopupWindow != null && mPopupWindow.isShowing()) {
btn_clock.setVisibility(View.VISIBLE);
btn_cancel.setVisibility(View.GONE);
mPopupWindow.dismiss();
vPop.setOnKeyListener(new View.OnKeyListener() {
public boolean onKey(View v, int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
if (mPopupWindow != null && mPopupWindow.isShowing()) {
btn_clock.setVisibility(View.VISIBLE);
btn_cancel.setVisibility(View.GONE);
mPopupWindow.dismiss();
&span style=&white-space:pre&& &/span&//popupwindow相关的操作
private void getMaplayer() {
LayoutInflater inflater = (LayoutInflater) this
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
vPop_layer = inflater.inflate(R.layout.map_layer_popup, null, false);
vPop_layer.setFocusable(true);
vPop_layer.setFocusableInTouchMode(true);
btn_map_normal = (Button) vPop_layer.findViewById(R.id.btn_map_normal);
btn_map_normal.setOnClickListener(this);
btn_map_satellite = (Button) vPop_layer
.findViewById(R.id.btn_map_satellite);
btn_map_satellite.setOnClickListener(this);
btn_map_3d = (Button) vPop_layer.findViewById(R.id.btn_map_3d);
btn_map_3d.setOnClickListener(this);
PopupWindowlayer = new PopupWindow(vPop_layer,
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, true);
PopupWindowlayer.setAnimationStyle(R.style.maplayerstyle);
PopupWindowlayer.setFocusable(true);
vPop_layer.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
if (PopupWindowlayer != null && PopupWindowlayer.isShowing()) {
PopupWindowlayer.dismiss();
layselect =
btn_layer.setImageDrawable(getResources().getDrawable(
R.drawable.btn_layer_48));
vPop_layer.setOnKeyListener(new View.OnKeyListener() {
public boolean onKey(View v, int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
if (PopupWindowlayer != null
&& PopupWindowlayer.isShowing()) {
layselect =
btn_layer.setImageDrawable(getResources().getDrawable(
R.drawable.btn_layer_48));
PopupWindowlayer.dismiss();
// **************************按键监听相关设置*****************************
public void onClick(View v) {
switch (v.getId()) {
case R.id.btn_layer:
PopupWindowlayer.showAsDropDown(btn_layer);
if (layselect == false) {
layselect =
btn_layer.setImageDrawable(getResources().getDrawable(
R.drawable.btn_cancel));
case R.id.btn_traffic_condition:
if (select) {
ToastShow(&实时路况已开启&);
btn_traffic_condition.setImageDrawable(getResources()
.getDrawable(R.drawable.main_roadcondition_on));
aMap.setTrafficEnabled(true);
ToastShow(&实时路况已关闭&);
btn_traffic_condition.setImageDrawable(getResources()
.getDrawable(R.drawable.main_roadcondition_off));
aMap.setTrafficEnabled(false);
case R.id.btn_zoom_in:
aMap.moveCamera(CameraUpdateFactory.zoomIn());
case R.id.btn_zoom_out:
aMap.moveCamera(CameraUpdateFactory.zoomOut());
case R.id.btn_clock:
int cy = btn_clock.getHeight();
if (change == false) {
btn_clock.setVisibility(View.GONE);
btn_cancel.setVisibility(View.VISIBLE);
mPopupWindow.showAtLocation(btn_clock, Gravity.BOTTOM
| Gravity.LEFT, 0, cy);
case R.id.btn_route:
Intent pathsearch = new Intent();
Bundle bn = new Bundle();
if (mlatitude != 0 && mlongitude != 0) {
bn.putDouble(StaticData.MLATITUDE, mlatitude);
bn.putDouble(StaticData.MLONGITUDE, mlongitude);
ToastShow(&现在无法进行路线查询,请检查网络&);
pathsearch.putExtras(bn);
pathsearch.setClass(MainMap.this, NavigationAty.class);
startActivityForResult(pathsearch, StaticData.REQUEST_PATH_SEARCH);
// case R.id.btn_box:
// Intent off = new Intent(MainMap.this, OffLineMap.class);
// startActivity(off);
case R.id.btn_begin_record:
if (start == false) {
btn_begin_record.setText(&停止记录&);
record_panel.setVisibility(View.VISIBLE);
saveRelatedData();
maxspeed = 0;
speed = 0;
totaldistance = 0;
btn_begin_record.setText(&开始记录&);
record_panel.setVisibility(View.GONE);
case R.id.btn_clear_route:
aMap.clear();
if (locationservice != null) {
setLocationIcon();
case R.id.btn_personel_record:
if (start)
saveRelatedData();
Intent perIntent = new Intent();
perIntent.setClass(MainMap.this, PersonelAty.class);
startActivityForResult(perIntent, StaticData.REQUEST_PERSON_RECORD);
case R.id.btn_map_normal:
selectMapLayer(R.id.btn_map_normal);
case R.id.btn_map_satellite:
selectMapLayer(R.id.btn_map_satellite);
case R.id.btn_map_3d:
selectMapLayer(R.id.btn_map_3d);
private void getMapMode() {
SharedPreferences pref = getSharedPreferences(
StaticData.SMALL_DOG_PREFERENCE, 0);
i = pref.getInt(StaticData.MAP_MODE, 0);
switch (i) {
aMap.setMyLocationType(AMap.LOCATION_TYPE_MAP_FOLLOW);
aMap.setMapType(AMap.MAP_TYPE_NORMAL);
btn_map_normal.setBackgroundColor(getResources().getColor(
R.color.orange));
btn_map_satellite.setBackgroundColor(R.drawable.btn_background);
btn_map_3d.setBackgroundColor(R.drawable.btn_background);
aMap.setMyLocationType(AMap.LOCATION_TYPE_MAP_FOLLOW);
aMap.setMapType(AMap.MAP_TYPE_SATELLITE);
btn_map_normal.setBackgroundColor(R.drawable.btn_background);
btn_map_satellite.setBackgroundColor(getResources().getColor(
R.color.orange));
btn_map_3d.setBackgroundColor(R.drawable.btn_background);
aMap.setMyLocationType(AMap.LOCATION_TYPE_MAP_ROTATE);
aMap.setMapType(AMap.MAP_TYPE_NORMAL);
btn_map_normal.setBackgroundColor(R.drawable.btn_background);
btn_map_satellite.setBackgroundColor(R.drawable.btn_background);
btn_map_3d.setBackgroundColor(getResources().getColor(
R.color.orange));
&span style=&white-space:pre&& &/span&//对一些界面设置的可持久化
private void selectMapLayer(int i) {
SharedPreferences pref = getSharedPreferences(
StaticData.SMALL_DOG_PREFERENCE, 0);
Editor pref_editor = pref.edit();
switch (i) {
case R.id.btn_map_normal:
mapmode = 0;
pref_editor.putInt(StaticData.MAP_MODE, mapmode);
aMap.setMyLocationType(AMap.LOCATION_TYPE_MAP_FOLLOW);
aMap.setMapType(AMap.MAP_TYPE_NORMAL);
btn_map_normal.setBackgroundColor(getResources().getColor(
R.color.orange));
btn_map_satellite.setBackgroundColor(R.drawable.btn_background);
btn_map_3d.setBackgroundColor(R.drawable.btn_background);
case R.id.btn_map_satellite:
mapmode = 1;
pref_editor.putInt(StaticData.MAP_MODE, mapmode);
aMap.setMyLocationType(AMap.LOCATION_TYPE_MAP_FOLLOW);
aMap.setMapType(AMap.MAP_TYPE_SATELLITE);
btn_map_normal.setBackgroundColor(R.drawable.btn_background);
btn_map_satellite.setBackgroundColor(getResources().getColor(
R.color.orange));
btn_map_3d.setBackgroundColor(R.drawable.btn_background);
case R.id.btn_map_3d:
mapmode = 2;
pref_editor.putInt(StaticData.MAP_MODE, mapmode);
aMap.setMyLocationType(AMap.LOCATION_TYPE_MAP_ROTATE);
aMap.setMapType(AMap.MAP_TYPE_NORMAL);
btn_map_normal.setBackgroundColor(R.drawable.btn_background);
btn_map_satellite.setBackgroundColor(R.drawable.btn_background);
btn_map_3d.setBackgroundColor(getResources().getColor(
R.color.orange));
private void ToastShow(String text) {
Toast.makeText(this, text, Toast.LENGTH_SHORT).show();
// *******************对后退按键的处理**********************
public void onBackPressed() {
if (lastClickTime &= 0) {
ToastShow(&再按一次后退键退出应用&);
lastClickTime = System.currentTimeMillis();
long currentClickTime = System.currentTimeMillis();
if (currentClickTime - lastClickTime & 1000) {
ToastShow(&再按一次后退键退出应用&);
lastClickTime = currentClickT
// ***********************生命周期处理*********************
protected void onResume() {
super.onResume();
acquireWakeLock();
registerReceiver(receiver, filter);
mapView.onResume();
protected void onPause() {
releaseWakeLock();
super.onPause();
mapView.onPause();
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
mapView.onSaveInstanceState(outState);
protected void onDestroy() {
System.out.println(&onDestroy&);
unregisterReceiver(receiver);
mstopService();
super.onDestroy();
mapView.onDestroy();
// **************************记录轨迹函数**********************
private void DrawRideTrace(LatLng point1, LatLng point2) {
if (aMap != null) {
aMap.addPolyline((new PolylineOptions()).add(point1, point2)
.geodesic(false).color(R.color.blueviolet));
&span style=&white-space:pre&& &/span&//路径规划好之后相关画线的操作
private void PlotBusRoute(LatLonPoint startpoint, LatLonPoint endpoint,
BusPath buspath) {
aMap.clear();// 清理地图上的所有覆盖物
setLocationIcon();
BusRouteOverlay routeOverlay = new BusRouteOverlay(this, aMap, buspath,
startpoint, endpoint);
routeOverlay.removeFromMap();
routeOverlay.addToMap();
routeOverlay.zoomToSpan();
private void PlotCarRoute(LatLonPoint startpoint, LatLonPoint endpoint,
DrivePath drivepath) {
aMap.clear();// 清理地图上的所有覆盖物
setLocationIcon();
DrivingRouteOverlay routeOverlay = new DrivingRouteOverlay(this, aMap,
drivepath, startpoint, endpoint);
routeOverlay.removeFromMap();
routeOverlay.addToMap();
routeOverlay.zoomToSpan();
private void PlotManRoute(LatLonPoint startpoint, LatLonPoint endpoint,
WalkPath walkpath) {
aMap.clear();// 清理地图上的所有覆盖物
setLocationIcon();
WalkRouteOverlay routeOverlay = new WalkRouteOverlay(this, aMap,
walkpath, startpoint, endpoint);
routeOverlay.removeFromMap();
routeOverlay.addToMap();
routeOverlay.zoomToSpan();
&span style=&white-space:pre&& &/span&//这个是对跳转activity相应的操作,作用完之后再主activity中进行画线操作~~
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
switch (requestCode) {
case StaticData.REQUEST_PATH_SEARCH:// 进行路线搜索
if (data != null) {
Bundle re_Budle = data.getExtras();
if (re_Budle != null) {
double endpoint_latitude = re_Budle
.getDouble(StaticData.END_LATITUDE);
double endpoint_longitude = re_Budle
.getDouble(StaticData.END_LONGITUDE);
double startpoint_latitude = re_Budle
.getDouble(StaticData.START_LATITUDE);
double startpoint_longitude = re_Budle
.getDouble(StaticData.START_LONGITUDE);
LatLonPoint startpoint = new LatLonPoint(
startpoint_latitude, startpoint_longitude);
LatLonPoint endpoint = new LatLonPoint(endpoint_latitude,
endpoint_longitude);
switch (resultCode) {
BusPath buspath = re_Budle
.getParcelable(StaticData.BUS_PATH);
PlotBusRoute(startpoint, endpoint, buspath);
DrivePath carpath = re_Budle
.getParcelable(StaticData.CAR_PATH);
PlotCarRoute(startpoint, endpoint, carpath);
WalkPath manpath = re_Budle
.getParcelable(StaticData.WALK_PATH);
PlotManRoute(startpoint, endpoint, manpath);
&span style=&white-space:pre&& &/span&//这个是存储一些常用变量的操作,由于参数较少,直接采用了sharedpreference的方式
private void saveRelatedData() {
SharedPreferences pre = getSharedPreferences(
StaticData.SMALL_DOG_PREFERENCE, 0);
Editor pre_edit = pre.edit();
pre_edit.putLong(StaticData.H, h);
pre_edit.putLong(StaticData.M, m);
pre_edit.putLong(StaticData.S, s);
pre_edit.putFloat(StaticData.TOTAL_DISTANCE, totaldistance);
pre_edit.putFloat(StaticData.MAX_SPEED, maxspeed);
如果无须看我讲解或者等不了的小伙伴们请自行下载我的源代码~~~~
源代码下载------------&&猛戳这里
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:30234次
积分:1116
积分:1116
排名:千里之外
原创:77篇
转载:34篇
(1)(1)(3)(6)(5)(18)(12)(24)(13)(30)}

我要回帖

更多关于 大众点评删除评论 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信