From 764f24d57e299775a17435d554f6444f2b720bbd Mon Sep 17 00:00:00 2001
From: duanwencheng <765928881@qq.com>
Date: Mon, 25 May 2015 22:13:10 +0800
Subject: [PATCH 1/2] add BaiduMapManager.java
---
.../mapexplorer/maps/BaiduMapManager.java | 138 ++++++++++++++++++
1 file changed, 138 insertions(+)
create mode 100644 src/com/yuneec/android/mapexplorer/maps/BaiduMapManager.java
diff --git a/src/com/yuneec/android/mapexplorer/maps/BaiduMapManager.java b/src/com/yuneec/android/mapexplorer/maps/BaiduMapManager.java
new file mode 100644
index 0000000..fc0ee8c
--- /dev/null
+++ b/src/com/yuneec/android/mapexplorer/maps/BaiduMapManager.java
@@ -0,0 +1,138 @@
+package com.yuneec.android.mapexplorer.maps;
+
+import android.content.SharedPreferences;
+
+import com.baidu.location.BDLocation;
+import com.baidu.location.BDLocationListener;
+import com.baidu.location.LocationClient;
+import com.baidu.location.LocationClientOption;
+import com.baidu.location.LocationClientOption.LocationMode;
+import com.baidu.mapapi.map.BaiduMap;
+import com.baidu.mapapi.map.MapStatus;
+import com.baidu.mapapi.map.MapStatusUpdate;
+import com.baidu.mapapi.map.MapStatusUpdateFactory;
+import com.baidu.mapapi.map.MapView;
+import com.baidu.mapapi.map.MyLocationData;
+import com.baidu.mapapi.model.LatLng;
+import com.yuneec.android.mapexplorer.entity.LatLongInfo;
+import com.yuneec.android.mapexplorer.settings.MyApplication;
+
+public class BaiduMapManager {
+
+ private static BaiduMapManager baiduMapManager = null;
+ private static MapView mapView;
+ private static BaiduMap baiduMap;
+ public static BaiduMap getBaiduMap() {
+ return baiduMap;
+ }
+
+ private MapStatus mapStatus;
+ private MapStatusUpdate mapStatusUpdate;
+
+ public BDLocationListener myLocationListener = new MyLocationListener();// 定位的回调接口
+ private LatLng currentLatLng;//当前坐标
+ private double currentLatitude;
+ private double currentlongitude;
+ private BaiduMapManager() {
+ super();
+ }
+ public static BaiduMapManager getInstance(MapView mapView) {
+ if (baiduMapManager == null) {
+ baiduMapManager = new BaiduMapManager();
+ BaiduMapManager.mapView = mapView;
+ baiduMap=mapView.getMap();
+ mapView.showZoomControls(false);// 不显示缩放控件
+ }
+ return baiduMapManager;
+ }
+
+
+ public LatLng getmCurrentLatLng() {
+ return currentLatLng;
+ }
+
+ public double getmCurrentatitude() {
+ return currentLatitude;
+ }
+
+ public double getmCurrentlongitude() {
+ return currentlongitude;
+ }
+
+
+ /**
+ * 定位
+ * @param locationClient 定位的核心类
+ */
+ public void goToMyLocation(LocationClient locationClient) {
+ // 设置是否允许定位图层,只有先允许定位图层后设置定位数据才会生效
+ baiduMap.setMyLocationEnabled(true);
+ baiduMap.setMapType(BaiduMap.MAP_TYPE_SATELLITE);
+ setLocationClient(locationClient);
+ updateBaiduMap(currentLatLng);
+ }
+
+
+ /**
+ * 设置LocationClient数据
+ * @param LocationClient
+ */
+ public void setLocationClient(LocationClient locationClient) {
+ // 使用LocationClientOption类.
+ LocationClientOption option = new LocationClientOption();
+ option.setLocationMode(LocationMode.Hight_Accuracy);// 设置定位模式
+ option.setCoorType("bd09ll");// 返回的定位结果是百度经纬度,默认值gcj02
+ option.setScanSpan(3000);// 设置发起定位请求的间隔时间为3000ms
+ option.setIsNeedAddress(true);// 返回的定位结果包含地址信息
+ option.setNeedDeviceDirect(true);// 返回的定位结果包含手机机头的方向
+ option.setOpenGps(true);
+ locationClient.setLocOption(option);
+ locationClient.registerLocationListener(myLocationListener);
+ locationClient.start();
+ }
+
+ /**
+ * 刷新地图
+ * @param latLng
+ */
+ public void updateBaiduMap(LatLng latLng) {
+ // 获得地图的当前状态的信息
+ mapStatus = new MapStatus.Builder().zoom(18).target(latLng).build();
+ // 设置地图将要变成的状态
+ mapStatusUpdate = MapStatusUpdateFactory.newMapStatus(mapStatus);
+ baiduMap.animateMapStatus(mapStatusUpdate);// 设置地图的变化
+
+ }
+
+
+
+ public class MyLocationListener implements BDLocationListener {
+
+
+ @Override
+ public void onReceiveLocation(BDLocation location) {
+ if (location == null || mapView == null)
+ return;
+
+ currentLatitude = location.getLatitude();
+ currentlongitude = location.getLongitude();
+ currentLatLng = new LatLng(location.getLatitude(),
+ location.getLongitude());
+
+ SharedPreferences.Editor sharedata = MyApplication.getInstance().getContext().getSharedPreferences("data", 0).edit();
+ sharedata.putString("oldLat",String.valueOf(currentLatitude));
+ sharedata.putString("oldLng",String.valueOf(currentlongitude));
+ sharedata.commit();
+
+ // 构造定位数据
+ MyLocationData locData = new MyLocationData.Builder()
+ .accuracy(location.getRadius())
+ .latitude(currentLatitude)
+ .longitude(currentlongitude)
+ .build();
+ baiduMap.setMyLocationData(locData);// 设置定位数据
+ }
+ }
+
+
+}
From fb31b08ff45dd0147fd7b3eab9c99122a23e9fe6 Mon Sep 17 00:00:00 2001
From: duanwencheng <765928881@qq.com>
Date: Tue, 26 May 2015 08:52:11 +0800
Subject: [PATCH 2/2] baidu map example
---
AndroidManifest.xml | 50 +-
project.properties | 3 +-
res/layout/activity_main.xml | 187 ++-
res/menu/main.xml | 11 +-
res/values-v11/styles.xml | 2 +-
res/values-v14/styles.xml | 2 +-
res/values/colors.xml | 137 +-
res/values/dimens.xml | 353 ++++-
res/values/strings.xml | 1342 ++++++++++++++++-
res/values/styles.xml | 514 ++++++-
.../android/mapexplorer/SharedPreference.java | 4 +
.../mapexplorer/base/BaseActivity.java | 28 +-
.../mapexplorer/library/AlertDialog.java | 1 +
.../mapexplorer/settings/MyApplication.java | 2 +
.../android/mapexplorer/util/TimeUtil.java | 1 +
15 files changed, 2582 insertions(+), 55 deletions(-)
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 6f935fb..c14754e 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -5,23 +5,65 @@
android:versionName="1.0" >
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ android:name=".activity.MapActivity"
+ android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
+ android:label="@string/app_name"
+ android:screenOrientation="sensorLandscape"
+ android:windowSoftInputMode="adjustPan" >
+
-
+
\ No newline at end of file
diff --git a/project.properties b/project.properties
index cac0d3f..4ab1256 100644
--- a/project.properties
+++ b/project.properties
@@ -11,5 +11,4 @@
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
# Project target.
-target=android-20
-android.library.reference.1=../appcompat_v7
+target=android-19
diff --git a/res/layout/activity_main.xml b/res/layout/activity_main.xml
index 6480542..bcb3634 100644
--- a/res/layout/activity_main.xml
+++ b/res/layout/activity_main.xml
@@ -1,12 +1,191 @@
+
+ android:background="@drawable/fpv_bg"
+ android:splitMotionEvents="false" >
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ android:layout_centerInParent="true"
+ android:text="FPS"
+ android:textColor="@android:color/holo_red_light"
+ android:textSize="14.0sp"
+ android:visibility="gone" />
-
+
\ No newline at end of file
diff --git a/res/menu/main.xml b/res/menu/main.xml
index a36dbd0..898b1dc 100644
--- a/res/menu/main.xml
+++ b/res/menu/main.xml
@@ -1,12 +1,5 @@
-