public class GPSView extends Activity {
final static double SEARCH_RADIUS = 5;
MapView map = null;
@SuppressWarnings("serial")
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
map = (MapView) findViewById(R.id.map);
String mapurl = "http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer";
map.addLayer(new ArcGISTiledMapServiceLayer(mapurl));
// 地图状态的改变
map.setOnStatusChangedListener(new OnStatusChangedListener() {
public void onStatusChanged(Object source, STATUS status) {
statusChange(source, status);
}
});
}
protected void statusChange(Object source, STATUS status) {
if (source == map && status == STATUS.INITIALIZED) {
LocationService locService = map.getLocationService();
locService.setAutoPan(false);
// 监听
locService.setLocationListener(new LocationListener() {
boolean locationChanged = false;
// Zooms to the current location when first GPS fix arrives.
public void onLocationChanged(Location loc) {
if (!locationChanged) {
locationChanged = true;
double locy = 0.0;
double locx = 0.0;
// locy = loc.getLatitude();
// locx = loc.getLongitude();
Log.i("andli", locx + "," + locy);
locx = 120.54186;
locy = 31.89647;
Point wgspoint = new Point(locx, locy);
// GPS坐标转ArcGis坐标
Point mapPoint = (Point) GeometryEngine.project(
wgspoint, SpatialReference.create(4326),
map.getSpatialReference());
Unit mapUnit = map.getSpatialReference().getUnit();
double zoomWidth = Unit.convertUnits(SEARCH_RADIUS,
Unit.create(LinearUnit.Code.MILE_US), mapUnit);
Envelope zoomExtent = new Envelope(mapPoint, zoomWidth,
zoomWidth);
map.setExtent(zoomExtent);
}
}
public void onProviderDisabled(String arg0) {
}
public void onProviderEnabled(String arg0) {
}
public void onStatusChanged(String arg0, int arg1, Bundle arg2) {
}
});
// 开启服务
locService.start();
}
}
protected void onDestroy() {
super.onDestroy();
map = null;
}
}
- 大小: 64 KB
分享到:
相关推荐
GPS定位功能。GPS定位例子。开启软件后,要等2分钟,就会弹出经纬度。
此程序为在jetson nano中实现GPS定位
启联嵌入式GPS定位平台是全球首款迷你GPS定位平台,通过配合GPS设备,您可以自行搭建全球卫星定位系统,进而很方便的监控移动资产,如车辆、箱包以及人员、宠物的位置信息,搭建过程极其简单,嵌入式GPS定位平台将...
GPS定位系统设计,也希望感兴趣的童鞋一起分享。
基于STM32的GPS定位系统的设计与实现-课题申请表.pdf基于STM32的GPS定位系统的设计与实现-课题申请表.pdf基于STM32的GPS定位系统的设计与实现-课题申请表.pdf基于STM32的GPS定位系统的设计与实现-课题申请表.pdf基于...
STM32L052C控制GPS模块VK1097U7M3的原理图,通过实际项目验证,能正常GPS定位,可以在串口打印相关的定位信息。需要的人可以参考。希望能给你们帮助!
利用手机内置GPS返回设备所在的经纬度坐标,刚启动的时候初次定位较慢,反应时间3-5分钟。另外,手机要开启GPS定位功能;
Android Studio 项目,集成了Android GPS定位。 在项目中也集成了高德SDK的定位效果。 项目的中key可以在高德开放平台上自行申请。
Android GPS 定位的实现 使用Google地图 Android下实现GPS定位服务
GPS定位技术原理及误差分析差分定位技术美国中国北斗卫星导航
基于单片机的简易GPS定位信息显示系统的设计.pdf
gps 定位算法仿真程序 导航定位解算原理仿真(gps navigation simulation program )
C# Gps定位实例.rar 取手机位置
卫通星GPS定位器GT06协议socket通讯JAVA Spring Boot对接
本设计是以 STC12C5A60S2 单片机为核心来实现 GPS 定位及信息显示的系 统。 系统主要是通过 GPS 模块接收定位信息, 单片机处理后, 再将数据传送到 LCD12864 并显示经度、 纬度、 时间等信息, 并且可以通过 GSM ...
在Android中的GPS定位在Android中的GPS定位在Android中的GPS定位在Android中的GPS定位
51单片机C语言编写的GPS定位 GPS模块 附接线图
武汉蓝台公交GPS定位自动报站器数据生成器软件.docx
采用GPS模式进行定位,分为后台Service进行实时定位,前台绑定服务,并调用后来定位到的信息进行展示。...4.停止GPS定位服务(非销毁后台服务) 注意:后台服务需要在程序退出时,需要手工停止服务,不然会自启动。
基于单片机的GPS定位信息显示系统设计PPT课件.pptx