my location(手机定位显示my location是谁的位置)

本文目录
手机定位显示my location是谁的位置
是你自己的位置 。。。
My location 的英文翻译过来就是 我的位置
android 手机 地图 定位 编程 如何获取 定位的地点 的图片 和 文字 信息
最近开发中使用的是百度地图android SDK:
1、初始化地图
2、注册定位**器,初始化Location模块
3、初始化定位图层;启用定位,启用指南针,最后把定位图层添加到地图中。附简单代码:
//mMapView = (MapView) findViewById(R.id.bmapsView);
mMapView = new MapView(this); //初始化一个mapView 存放Map
mMapView.setBuiltInZoomControls(true);// 设置启用默认的缩放控件
locationManager = mBMapMan.getLocationManager();
/*
* 由于LocationListener获取第一个位置修正的时间会很长,为了避免用户等待,
* 在LocationListener获取第一个更精确的位置之前,应当使用getLocationInfo() 获取一个缓存的位置
*/
Location location = locationManager.getLocationInfo();
locationManager.requestLocationUpdates(this);
mMapController = mMapView.getController();// 得到mMapView的控制权,可以用它控制和驱动平移和缩放
if (location != null) {
mMapController.setCenter(new GeoPoint(
(int) (location.getLatitude() * 1E6), (int) (location
.getLongitude() * 1E6)));
}
mMapController.setZoom(12);// 设置地图zoom级别
MyLocationOverlay mylocTest = new MyLocationOverlay(this, mMapView);
mylocTest.enableMyLocation();
mylocTest.enableCompass();
mMapView.getOverlays().add(mylocTest);
@Override
public void onLocationChanged(Location location) {
// TODO Auto-generated method stub
if (location != null) {
mMapController.animateTo(new GeoPoint(
(int) (location.getLatitude() * 1E6), (int) (location
.getLongitude() * 1E6)));
}
}
如果你想点击定位地点,显示信息,你需要去扩展MyLocationOverlay图层,它里面有个public boolean onTap(GeoPoint p, MapView map) {}方法,是处理点击事件的。
有问题,可以与我联系,共同探讨。
android地图,怎么添加自定义InfoWindow
安卓地图添加自定义InfoWindow的方法如下:
需要先下载地图的 Android SDK和 Android 定位SDK :
( htt p):// code.(autonavi).(com/index)【输出时去掉括号】
package com.fproject.DXCBuy;
import com.amap.api.location.AMapLocation;
import com.amap.api.location.AMapLocationListener;
import com.amap.api.location.LocationManagerProxy;
import com.amap.api.location.LocationProviderProxy;
import com.amap.api.maps.AMap;
import com.amap.api.maps.AMap.InfoWindowAdapter;
import com.amap.api.maps.AMap.OnInfoWindowClickListener;
import com.amap.api.maps.AMap.OnMarkerClickListener;
import com.amap.api.maps.CameraUpdate;
import com.amap.api.maps.CameraUpdateFactory;
import com.amap.api.maps.LocationSource;
import com.amap.api.maps.MapView;
import com.amap.api.maps.model.BitmapDescriptorFactory;
import com.amap.api.maps.model.LatLng;
import com.amap.api.maps.model.Marker;
import com.amap.api.maps.model.MarkerOpti***;
import com.amap.api.maps.model.MyLocationStyle;
import android.location.Location;
import android.os.Bundle;
import android.text.SpannableString;
import android.text.style.ForegroundColorSpan;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import android.app.Activity;
import android.graphics.Color;
public class ShopMapActivity extends Activity implements LocationSource,
AMapLocationListener, OnInfoWindowClickListener, InfoWindowAdapter,
OnMarkerClickListener{
private PublicData pd;
private MapView mapView;
private AMap aMap;
private OnLocationChangedListener mListener;
private LocationManagerProxy mAMapLocationManager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_shopmap);
mapView = (MapView) findViewById(R.id.map);
mapView.onCreate(savedInstanceState);
init();
pd = PublicData.getInstance();
}
/**
* 初始化AMap对象
*/
private void init() {
if (aMap == null) {
aMap = mapView.getMap();
setUpMap();
}
}
Marker MEIYIDUO;
Marker BOLIAN;
Marker CUNZHIHUA;
private void setUpMap() {
// 自定义系统定位小蓝点
MyLocationStyle myLocationStyle = new MyLocationStyle();
myLocationStyle.myLocationIcon(BitmapDescriptorFactory.fromResource(R.drawable.gps));
myLocationStyle.strokeColor(Color.BLACK);
myLocationStyle.strokeWidth(5);
aMap.setMyLocationStyle(myLocationStyle);
// 设置定位资源
aMap.setLocationSource(this);
// 设置为true表示系统定位按钮显示并响应点击,false表示隐藏,默认是false
aMap.setMyLocationEnabled(true);
CameraUpdate update = CameraUpdateFactory.newLatLngZoom(new
LatLng(23.041725,113.373472), 17);
aMap.moveCamera(update);
//添加标记
LatLng ll_meiyijia = new LatLng(23.041425,113.37536);
LatLng ll_bolian = new LatLng(23.041725,113.373472);
LatLng ll_cunzhihua = new LatLng(23.041337,113.372602);
MEIYIDUO = aMap.addMarker(new MarkerOpti***()
.position(ll_meiyijia)
.title("美事多超市")
.icon(BitmapDescriptorFactory.fromResource(R.drawable.cart_alt)).perspective(true)
.draggable(true));// 设置远小近大效果,2.1.0版本新增
BOLIAN = aMap.addMarker(new MarkerOpti***()
.position(ll_bolian)
.title("博联超市")
.icon(BitmapDescriptorFactory.fromResource(R.drawable.cart_alt)).perspective(true)
.draggable(true));// 设置远小近大效果,2.1.0版本新增
CUNZHIHUA = aMap.addMarker(new MarkerOpti***()
.position(ll_cunzhihua)
.title("春之花超市")
.icon(BitmapDescriptorFactory.fromResource(R.drawable.cart_alt)).perspective(true)
.draggable(true));// 设置远小近大效果,2.1.0版本新增
aMap.setOnMarkerClickListener(this);
aMap.setOnInfoWindowClickListener(this);
aMap.setInfoWindowAdapter(this);
BOLIAN.showInfoWindow();
}
/**
* 此方法需存在
*/
@Override
protected void onResume() {
super.onResume();
mapView.onResume();
}
/**
* 此方法需存在
*/
@Override
protected void onPause() {
super.onPause();
mapView.onPause();
deactivate();
}
/**
* 此方法需存在
*/
@Override
protected void onDestroy() {
super.onDestroy();
mapView.onDestroy();
}
/**
* 此方法已经废弃
*/
@Override
public void onLocationChanged(Location location) {
}
/**
* 定位成功后回调函数
*/
@Override
public void onLocationChanged(AMapLocation aLocation) {
if (mListener != null) {
// 将定位信息显示在地图上
mListener.onLocationChanged(aLocation);
}
}
/**
* 激活定位
*/
@Override
public void activate(OnLocationChangedListener listener) {
mListener = listener;
if (mAMapLocationManager == null) {
mAMapLocationManager = LocationManagerProxy.getInstance(this);
/*
* mAMapLocManager.setGpsEnable(false);//
* 1.0.2版本新增方法,设置true表示混合定位中包含gps定位,false表示纯网络定位,默认是true
*/
// Location SDK定位采用GPS和网络混合定位方式,时间最短是5000毫秒,否则无效
mAMapLocationManager.requestLocationUpdates(
LocationProviderProxy.AMapNetwork, 5000, 10, this);
}
}
/**
* 停止定位
*/
@Override
public void deactivate() {
mListener = null;
if (mAMapLocationManager != null) {
mAMapLocationManager.removeUpdates(this);
mAMapLocationManager.destory();
}
mAMapLocationManager = null;
}
@Override
public void onProviderDisabled(String provider) {
// TODO Auto-generated method stub
}
@Override
public void onProviderEnabled(String provider) {
// TODO Auto-generated method stub
}
@Override
public void onStatusChanged(String provider, int status, Bundle extras)
{
// TODO Auto-generated method stub
}
@Override
public View getInfoContents(Marker marker) {
return null;
}
@Override
public View getInfoWindow(Marker marker) {
View view = getLayoutInflater().inflate(R.layout.custom_info_window,
null);
ImageView imageView = (ImageView) view.findViewById(R.id.badge);
imageView.setImageResource(R.drawable.cart_alt);
String title = marker.getTitle();
TextView titleUi = ((TextView) view.findViewById(R.id.title));
SpannableString titleText = new SpannableString(title);
titleText.setSpan(new ForegroundColorSpan(Color.BLACK), 0,
titleText.length(), 0);
titleUi.setTextSize(15);
titleUi.setText(titleText);
TextView snippetUi = ((TextView) view.findViewById(R.id.snippet));
SpannableString snippetText = new SpannableString("点击进入商店");
snippetText.setSpan(new ForegroundColorSpan(Color.GRAY), 0,
snippetText.length(), 0);
snippetUi.setTextSize(12);
snippetUi.setText(snippetText);
return view;
}
@Override
public void onInfoWindowClick(Marker arg0) {
if(arg0.equals(MEIYIDUO)) {
pd.getHandlerMain().sendMsg("enter_shop", "myj");
} else if(arg0.equals(BOLIAN)) {
pd.getHandlerMain().sendMsg("enter_shop", "bl");
} else if(arg0.equals(CUNZHIHUA)) {
pd.getHandlerMain().sendMsg("enter_shop", "czh");
}
this.finish();
}
@Override
public boolean onMarkerClick(Marker arg0) {
// TODO Auto-generated method stub
return false;
}
}

更多文章:
stay away(英语语法:动词短语stay off 和 stay away 有什么区别 我看国外告示牌都是同时标出的)
2026年1月31日 15:55
秋千古代叫什么?“收灯庭院迟迟月,落索秋千剪剪风”.什么意思
2026年1月14日 02:15
黑社会2插曲(清各位告诉我一下,电影《黑社会》的插曲叫什么名字,谢谢)
2026年1月17日 00:30
月光下的凤尾竹简谱(急求葫芦丝《月光下的凤尾竹》降b调的简谱,谢谢大家了!)
2025年8月5日 01:55
抖音很火的一首琵琶曲(我想找一首抖音上的歌,有人知道是什么歌吗找了很久了)
2026年1月15日 13:10
豆瓣里的音乐为什么不能听?豆瓣2021年度音乐榜,都有哪些明星上榜
2026年6月8日 08:20
开学第一课作文500字左右2022(《开学第一课》2022观后感作文十篇)
2026年4月7日 12:45












