|
@@ -6,12 +6,11 @@ package com.usai.apex;
|
|
|
//import baidumapsdk.demo.DemoApplication.MyGeneralListener;
|
|
//import baidumapsdk.demo.DemoApplication.MyGeneralListener;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
|
|
+import java.util.HashMap;
|
|
|
|
|
|
|
|
import org.json.JSONException;
|
|
import org.json.JSONException;
|
|
|
import org.json.JSONObject;
|
|
import org.json.JSONObject;
|
|
|
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
import com.baidu.mapapi.BMapManager;
|
|
import com.baidu.mapapi.BMapManager;
|
|
|
import com.baidu.mapapi.MKGeneralListener;
|
|
import com.baidu.mapapi.MKGeneralListener;
|
|
|
import com.baidu.mapapi.map.ItemizedOverlay;
|
|
import com.baidu.mapapi.map.ItemizedOverlay;
|
|
@@ -19,11 +18,15 @@ import com.baidu.mapapi.map.MKEvent;
|
|
|
import com.baidu.mapapi.map.MapController;
|
|
import com.baidu.mapapi.map.MapController;
|
|
|
import com.baidu.mapapi.map.MapView;
|
|
import com.baidu.mapapi.map.MapView;
|
|
|
import com.baidu.mapapi.map.OverlayItem;
|
|
import com.baidu.mapapi.map.OverlayItem;
|
|
|
|
|
+import com.baidu.mapapi.map.PopupClickListener;
|
|
|
|
|
+import com.baidu.mapapi.map.PopupOverlay;
|
|
|
import com.baidu.mapapi.map.SupportMapFragment;
|
|
import com.baidu.mapapi.map.SupportMapFragment;
|
|
|
import com.baidu.platform.comapi.basestruct.GeoPoint;
|
|
import com.baidu.platform.comapi.basestruct.GeoPoint;
|
|
|
import com.usai.util.Network;
|
|
import com.usai.util.Network;
|
|
|
|
|
|
|
|
import android.content.Context;
|
|
import android.content.Context;
|
|
|
|
|
+import android.content.Intent;
|
|
|
|
|
+import android.graphics.Bitmap;
|
|
|
import android.graphics.drawable.Drawable;
|
|
import android.graphics.drawable.Drawable;
|
|
|
import android.os.AsyncTask;
|
|
import android.os.AsyncTask;
|
|
|
import android.os.Bundle;
|
|
import android.os.Bundle;
|
|
@@ -34,66 +37,67 @@ import android.view.Gravity;
|
|
|
import android.view.LayoutInflater;
|
|
import android.view.LayoutInflater;
|
|
|
import android.view.View;
|
|
import android.view.View;
|
|
|
import android.view.ViewGroup;
|
|
import android.view.ViewGroup;
|
|
|
|
|
+import android.widget.TextView;
|
|
|
import android.widget.Toast;
|
|
import android.widget.Toast;
|
|
|
|
|
|
|
|
public class BaiduMapFragment extends Fragment
|
|
public class BaiduMapFragment extends Fragment
|
|
|
{
|
|
{
|
|
|
private SearchTask m_task = null;
|
|
private SearchTask m_task = null;
|
|
|
String fragment_content = null;
|
|
String fragment_content = null;
|
|
|
- private MapView mMapView = null;
|
|
|
|
|
- private MyOverlay mOverlay = null;
|
|
|
|
|
-// private OverlayItem mCurItem = null;
|
|
|
|
|
-// private Button button = null;
|
|
|
|
|
- private ArrayList<OverlayItem> mItems = null;
|
|
|
|
|
-
|
|
|
|
|
- SupportMapFragment fragment;
|
|
|
|
|
- BMapManager mBMapManager = null;
|
|
|
|
|
- public static boolean m_bKeyRight = true;
|
|
|
|
|
- public static final String strKey = "tznWFxd3RvSoul1TGQp6GSzo";
|
|
|
|
|
-
|
|
|
|
|
- public class MyOverlay extends ItemizedOverlay{
|
|
|
|
|
-
|
|
|
|
|
- public MyOverlay(Drawable defaultMarker, MapView mapView) {
|
|
|
|
|
|
|
+ private MapView mMapView = null;
|
|
|
|
|
+ private MyOverlay mOverlay = null;
|
|
|
|
|
+ // private OverlayItem mCurItem = null;
|
|
|
|
|
+ // private Button button = null;
|
|
|
|
|
+ private ArrayList<OverlayItem> mItems = null;
|
|
|
|
|
+ private PopupOverlay pop = null;
|
|
|
|
|
+ SupportMapFragment fragment;
|
|
|
|
|
+ BMapManager mBMapManager = null;
|
|
|
|
|
+ public static boolean m_bKeyRight = true;
|
|
|
|
|
+ HashMap<String, LocationDetail> marker_detail = new HashMap<String, LocationDetail>();
|
|
|
|
|
+ OverlayItem m_curitem = null;
|
|
|
|
|
+ public class MyOverlay extends ItemizedOverlay
|
|
|
|
|
+ {
|
|
|
|
|
+
|
|
|
|
|
+ public MyOverlay(Drawable defaultMarker, MapView mapView)
|
|
|
|
|
+ {
|
|
|
super(defaultMarker, mapView);
|
|
super(defaultMarker, mapView);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public boolean onTap(int index){
|
|
|
|
|
-// OverlayItem item = getItem(index);
|
|
|
|
|
-// mCurItem = item ;
|
|
|
|
|
-// if (index == 3){
|
|
|
|
|
-// button.setText("这是一个系统控件");
|
|
|
|
|
-// GeoPoint pt = new GeoPoint((int) (mLat4 * 1E6),
|
|
|
|
|
-// (int) (mLon4 * 1E6));
|
|
|
|
|
-// // 弹出自定义View
|
|
|
|
|
-// pop.showPopup(button, pt, 32);
|
|
|
|
|
-// }
|
|
|
|
|
-// else{
|
|
|
|
|
-// popupText.setText(getItem(index).getTitle());
|
|
|
|
|
-// Bitmap[] bitMaps={
|
|
|
|
|
-// BMapUtil.getBitmapFromView(popupLeft),
|
|
|
|
|
-// BMapUtil.getBitmapFromView(popupInfo),
|
|
|
|
|
-// BMapUtil.getBitmapFromView(popupRight)
|
|
|
|
|
-// };
|
|
|
|
|
-// pop.showPopup(bitMaps,item.getPoint(),32);
|
|
|
|
|
-// }
|
|
|
|
|
|
|
+ public boolean onTap(int index)
|
|
|
|
|
+ {
|
|
|
|
|
+ Log.d("baidumap...................", "ontap");
|
|
|
|
|
+ View viewCache = getActivity().getLayoutInflater().inflate(
|
|
|
|
|
+ R.layout.marker_view, null);
|
|
|
|
|
+
|
|
|
|
|
+ TextView tv_title = (TextView) viewCache
|
|
|
|
|
+ .findViewById(R.id.tv_title);
|
|
|
|
|
+ TextView tv_info = (TextView) viewCache.findViewById(R.id.tv_info);
|
|
|
|
|
+
|
|
|
|
|
+ OverlayItem item = getItem(index);
|
|
|
|
|
+
|
|
|
|
|
+ tv_title.setText(item.getTitle());
|
|
|
|
|
+ tv_info.setText(item.getSnippet());
|
|
|
|
|
+ m_curitem = item;
|
|
|
|
|
+ pop.showPopup(viewCache, item.getPoint(), 32);
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
-// @Override
|
|
|
|
|
-// public boolean onTap(GeoPoint pt , MapView mMapView){
|
|
|
|
|
-//// if (pop != null){
|
|
|
|
|
-//// pop.hidePop();
|
|
|
|
|
-//// mMapView.removeView(button);
|
|
|
|
|
-//// }
|
|
|
|
|
-// return false;
|
|
|
|
|
-// }
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
|
|
+
|
|
|
|
|
+// @Override
|
|
|
|
|
+// public boolean onTap(GeoPoint pt , MapView mMapView){
|
|
|
|
|
+// if (pop != null){
|
|
|
|
|
+// pop.
|
|
|
|
|
+// pop.hidePop();
|
|
|
|
|
+//// mMapView.removeView(button);
|
|
|
|
|
+// }
|
|
|
|
|
+// return false;
|
|
|
|
|
+// }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
void AddMarker()
|
|
void AddMarker()
|
|
|
{
|
|
{
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
if (mMapView == null)
|
|
if (mMapView == null)
|
|
|
{
|
|
{
|
|
|
|
|
|
|
@@ -103,7 +107,6 @@ public class BaiduMapFragment extends Fragment
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
try
|
|
try
|
|
|
{
|
|
{
|
|
|
JSONObject jsobj = new JSONObject(fragment_content);
|
|
JSONObject jsobj = new JSONObject(fragment_content);
|
|
@@ -111,15 +114,12 @@ public class BaiduMapFragment extends Fragment
|
|
|
int count = jsobj.getInt("total");
|
|
int count = jsobj.getInt("total");
|
|
|
|
|
|
|
|
JSONObject objrecords = jsobj.getJSONObject("records");
|
|
JSONObject objrecords = jsobj.getJSONObject("records");
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
|
|
+ mOverlay = new MyOverlay(getResources().getDrawable(
|
|
|
|
|
+ R.drawable.ic_marker), mMapView);
|
|
|
for (int i = 0; i < count; i++)
|
|
for (int i = 0; i < count; i++)
|
|
|
{
|
|
{
|
|
|
// offset++;
|
|
// offset++;
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
JSONObject objrec = objrecords.getJSONObject("record" + i);
|
|
JSONObject objrec = objrecords.getJSONObject("record" + i);
|
|
|
String area = objrec.getString("area");
|
|
String area = objrec.getString("area");
|
|
|
String company = objrec.getString("company");
|
|
String company = objrec.getString("company");
|
|
@@ -132,71 +132,63 @@ public class BaiduMapFragment extends Fragment
|
|
|
String contact = objrec.getString("contact");
|
|
String contact = objrec.getString("contact");
|
|
|
String email = objrec.getString("email");
|
|
String email = objrec.getString("email");
|
|
|
|
|
|
|
|
-
|
|
|
|
|
LocationDetail detail = new LocationDetail(company, address,
|
|
LocationDetail detail = new LocationDetail(company, address,
|
|
|
telephone, fax, contact, email);
|
|
telephone, fax, contact, email);
|
|
|
|
|
+ marker_detail.put(company, detail);
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 准备overlay 数据
|
|
|
|
|
+ */
|
|
|
|
|
+ GeoPoint p1 = new GeoPoint(
|
|
|
|
|
+ (int) (Double.parseDouble(latitude) * 1E6),
|
|
|
|
|
+ (int) (Double.parseDouble(longitude) * 1E6));
|
|
|
|
|
+ OverlayItem item1 = new OverlayItem(p1, company, city + "\n"
|
|
|
|
|
+ + area);
|
|
|
|
|
|
|
|
-
|
|
|
|
|
- mOverlay = new MyOverlay(getResources().getDrawable(R.drawable.ic_marker),mMapView);
|
|
|
|
|
- /**
|
|
|
|
|
- * 准备overlay 数据
|
|
|
|
|
- */
|
|
|
|
|
- GeoPoint p1 = new GeoPoint ((int)(Double.parseDouble(latitude)*1E6),(int)(Double.parseDouble(longitude)*1E6));
|
|
|
|
|
- OverlayItem item1 = new OverlayItem(p1,company,city+"\n"+area);
|
|
|
|
|
-// /**
|
|
|
|
|
-// * 设置overlay图标,如不设置,则使用创建ItemizedOverlay时的默认图标.
|
|
|
|
|
-// */
|
|
|
|
|
-// item1.setMarker(getResources().getDrawable(R.drawable.icon_marka));
|
|
|
|
|
-//
|
|
|
|
|
-// GeoPoint p2 = new GeoPoint ((int)(mLat2*1E6),(int)(mLon2*1E6));
|
|
|
|
|
-// OverlayItem item2 = new OverlayItem(p2,"覆盖物2","");
|
|
|
|
|
-// item2.setMarker(getResources().getDrawable(R.drawable.icon_markb));
|
|
|
|
|
-//
|
|
|
|
|
-// GeoPoint p3 = new GeoPoint ((int)(mLat3*1E6),(int)(mLon3*1E6));
|
|
|
|
|
-// OverlayItem item3 = new OverlayItem(p3,"覆盖物3","");
|
|
|
|
|
-// item3.setMarker(getResources().getDrawable(R.drawable.icon_markc));
|
|
|
|
|
-//
|
|
|
|
|
-// GeoPoint p4 = new GeoPoint ((int)(mLat4*1E6),(int)(mLon4*1E6));
|
|
|
|
|
-// OverlayItem item4 = new OverlayItem(p4,"覆盖物4","");
|
|
|
|
|
-// item4.setMarker(getResources().getDrawable(R.drawable.icon_gcoding));
|
|
|
|
|
- /**
|
|
|
|
|
- * 将item 添加到overlay中
|
|
|
|
|
- * 注意: 同一个itme只能add一次
|
|
|
|
|
- */
|
|
|
|
|
- mOverlay.addItem(item1);
|
|
|
|
|
-// mOverlay.addItem(item2);
|
|
|
|
|
-// mOverlay.addItem(item3);
|
|
|
|
|
-// mOverlay.addItem(item4);
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * 保存所有item,以便overlay在reset后重新添加
|
|
|
|
|
- */
|
|
|
|
|
- mItems = new ArrayList<OverlayItem>();
|
|
|
|
|
- mItems.addAll(mOverlay.getAllItem());
|
|
|
|
|
-
|
|
|
|
|
-// // 初始化 ground 图层
|
|
|
|
|
-// mGroundOverlay = new GroundOverlay(mMapView);
|
|
|
|
|
-// GeoPoint leftBottom = new GeoPoint((int) (mLat5 * 1E6),
|
|
|
|
|
-// (int) (mLon5 * 1E6));
|
|
|
|
|
-// GeoPoint rightTop = new GeoPoint((int) (mLat6 * 1E6),
|
|
|
|
|
-// (int) (mLon6 * 1E6));
|
|
|
|
|
-// Drawable d = getResources().getDrawable(R.drawable.ground_overlay);
|
|
|
|
|
-// Bitmap bitmap = ((BitmapDrawable) d).getBitmap();
|
|
|
|
|
-// mGround = new Ground(bitmap, leftBottom, rightTop);
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * 将overlay 添加至MapView中
|
|
|
|
|
- */
|
|
|
|
|
- mMapView.getOverlays().add(mOverlay);
|
|
|
|
|
-// mMapView.getOverlays().add(mGroundOverlay);
|
|
|
|
|
-// mGroundOverlay.addGround(mGround);
|
|
|
|
|
- /**
|
|
|
|
|
- * 刷新地图
|
|
|
|
|
- */
|
|
|
|
|
- mMapView.refresh();
|
|
|
|
|
-// mResetBtn.setEnabled(false);
|
|
|
|
|
-// mClearBtn.setEnabled(true);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 将item 添加到overlay中 注意: 同一个itme只能add一次
|
|
|
|
|
+ */
|
|
|
|
|
+ mOverlay.addItem(item1);
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 保存所有item,以便overlay在reset后重新添加
|
|
|
|
|
+ */
|
|
|
|
|
+ mItems = new ArrayList<OverlayItem>();
|
|
|
|
|
+ mItems.addAll(mOverlay.getAllItem());
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 将overlay 添加至MapView中
|
|
|
|
|
+ */
|
|
|
|
|
+ mMapView.getOverlays().add(mOverlay);
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 刷新地图
|
|
|
|
|
+ */
|
|
|
|
|
+ mMapView.refresh();
|
|
|
|
|
+ PopupClickListener popListener = new PopupClickListener()
|
|
|
|
|
+ {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onClickedPopup(int index)
|
|
|
|
|
+ {
|
|
|
|
|
+ Log.d("baidu map.......", "popup on click");
|
|
|
|
|
+ pop.hidePop();
|
|
|
|
|
+
|
|
|
|
|
+ mMapView.refresh();
|
|
|
|
|
+ Intent intent = new Intent();
|
|
|
|
|
+ intent.setClass(getActivity(), LocationDetailActivity.class);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ String markertext = m_curitem.getTitle();
|
|
|
|
|
+
|
|
|
|
|
+ intent.putExtra("detail", marker_detail.get(markertext));
|
|
|
|
|
+ // // intent.putExtra("password", password);
|
|
|
|
|
+ // intent.putExtra("function_name", function_name);
|
|
|
|
|
+ // intent.putExtra("behavior", Network.BEHAVIOR_SEARCH);
|
|
|
|
|
+ startActivity(intent);
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ };
|
|
|
|
|
+ pop = new PopupOverlay(mMapView, popListener);
|
|
|
}
|
|
}
|
|
|
catch (JSONException e)
|
|
catch (JSONException e)
|
|
|
{
|
|
{
|
|
@@ -204,6 +196,7 @@ public class BaiduMapFragment extends Fragment
|
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
public void requestloactions()
|
|
public void requestloactions()
|
|
|
{
|
|
{
|
|
|
|
|
|
|
@@ -232,7 +225,7 @@ public class BaiduMapFragment extends Fragment
|
|
|
m_task.execute();
|
|
m_task.execute();
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
class SearchTask extends AsyncTask<Void, Void, Boolean>
|
|
class SearchTask extends AsyncTask<Void, Void, Boolean>
|
|
|
{
|
|
{
|
|
|
int errorcode;
|
|
int errorcode;
|
|
@@ -374,67 +367,87 @@ public class BaiduMapFragment extends Fragment
|
|
|
// showProgress(false);
|
|
// showProgress(false);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- public void initEngineManager(Context context) {
|
|
|
|
|
- if (mBMapManager == null) {
|
|
|
|
|
- mBMapManager = new BMapManager(context);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if (!mBMapManager.init(strKey,new MyGeneralListener())) {
|
|
|
|
|
- Toast.makeText(getActivity()
|
|
|
|
|
- .getApplicationContext(),
|
|
|
|
|
- "BMapManager 初始化错误!", Toast.LENGTH_LONG).show();
|
|
|
|
|
- }
|
|
|
|
|
|
|
+
|
|
|
|
|
+ public void initEngineManager(Context context)
|
|
|
|
|
+ {
|
|
|
|
|
+ String strKey = ApexTrackingApplication.get_instance().getString(R.string.baidu_key);
|
|
|
|
|
+ if (mBMapManager == null)
|
|
|
|
|
+ {
|
|
|
|
|
+ mBMapManager = new BMapManager(context);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (!mBMapManager.init(strKey, new MyGeneralListener()))
|
|
|
|
|
+ {
|
|
|
|
|
+ Toast.makeText(getActivity().getApplicationContext(),
|
|
|
|
|
+ "BMapManager 初始化错误!", Toast.LENGTH_LONG).show();
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// 常用事件监听,用来处理通常的网络错误,授权验证错误等
|
|
// 常用事件监听,用来处理通常的网络错误,授权验证错误等
|
|
|
- static class MyGeneralListener implements MKGeneralListener {
|
|
|
|
|
-
|
|
|
|
|
- @Override
|
|
|
|
|
- public void onGetNetworkState(int iError) {
|
|
|
|
|
- if (iError == MKEvent.ERROR_NETWORK_CONNECT) {
|
|
|
|
|
- Toast.makeText(ApexTrackingApplication.get_instance().getApplicationContext(), "您的网络出错啦!",
|
|
|
|
|
- Toast.LENGTH_LONG).show();
|
|
|
|
|
- }
|
|
|
|
|
- else if (iError == MKEvent.ERROR_NETWORK_DATA) {
|
|
|
|
|
- Toast.makeText(ApexTrackingApplication.get_instance().getApplicationContext(), "输入正确的检索条件!",
|
|
|
|
|
- Toast.LENGTH_LONG).show();
|
|
|
|
|
- }
|
|
|
|
|
- // ...
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @Override
|
|
|
|
|
- public void onGetPermissionState(int iError) {
|
|
|
|
|
- //非零值表示key验证未通过
|
|
|
|
|
- if (iError != 0) {
|
|
|
|
|
- //授权Key错误:
|
|
|
|
|
- Toast.makeText(ApexTrackingApplication.get_instance().getApplicationContext(),
|
|
|
|
|
- "请在 DemoApplication.java文件输入正确的授权Key,并检查您的网络连接是否正常!error: "+iError, Toast.LENGTH_LONG).show();
|
|
|
|
|
- m_bKeyRight = false;
|
|
|
|
|
- }
|
|
|
|
|
- else{
|
|
|
|
|
- m_bKeyRight = true;
|
|
|
|
|
- Toast.makeText(ApexTrackingApplication.get_instance().getApplicationContext(),
|
|
|
|
|
- "key认证成功", Toast.LENGTH_LONG).show();
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
|
|
+ static class MyGeneralListener implements MKGeneralListener
|
|
|
|
|
+ {
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onGetNetworkState(int iError)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (iError == MKEvent.ERROR_NETWORK_CONNECT)
|
|
|
|
|
+ {
|
|
|
|
|
+ Toast.makeText(
|
|
|
|
|
+ ApexTrackingApplication.get_instance()
|
|
|
|
|
+ .getApplicationContext(), "您的网络出错啦!",
|
|
|
|
|
+ Toast.LENGTH_LONG).show();
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (iError == MKEvent.ERROR_NETWORK_DATA)
|
|
|
|
|
+ {
|
|
|
|
|
+ Toast.makeText(
|
|
|
|
|
+ ApexTrackingApplication.get_instance()
|
|
|
|
|
+ .getApplicationContext(), "输入正确的检索条件!",
|
|
|
|
|
+ Toast.LENGTH_LONG).show();
|
|
|
|
|
+ }
|
|
|
|
|
+ // ...
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onGetPermissionState(int iError)
|
|
|
|
|
+ {
|
|
|
|
|
+ // 非零值表示key验证未通过
|
|
|
|
|
+ if (iError != 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ // 授权Key错误:
|
|
|
|
|
+ Toast.makeText(
|
|
|
|
|
+ ApexTrackingApplication.get_instance()
|
|
|
|
|
+ .getApplicationContext(),
|
|
|
|
|
+ "请在 DemoApplication.java文件输入正确的授权Key,并检查您的网络连接是否正常!error: "
|
|
|
|
|
+ + iError, Toast.LENGTH_LONG).show();
|
|
|
|
|
+ m_bKeyRight = false;
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ m_bKeyRight = true;
|
|
|
|
|
+ Toast.makeText(
|
|
|
|
|
+ ApexTrackingApplication.get_instance()
|
|
|
|
|
+ .getApplicationContext(), "key认证成功",
|
|
|
|
|
+ Toast.LENGTH_LONG).show();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public void onActivityCreated(Bundle savedInstanceState)
|
|
public void onActivityCreated(Bundle savedInstanceState)
|
|
|
{
|
|
{
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
super.onActivityCreated(savedInstanceState);
|
|
super.onActivityCreated(savedInstanceState);
|
|
|
initEngineManager(getActivity().getApplicationContext());
|
|
initEngineManager(getActivity().getApplicationContext());
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
FragmentManager fm = getChildFragmentManager();
|
|
FragmentManager fm = getChildFragmentManager();
|
|
|
fragment = (SupportMapFragment) fm.findFragmentById(R.id.map);
|
|
fragment = (SupportMapFragment) fm.findFragmentById(R.id.map);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
if (fragment == null)
|
|
if (fragment == null)
|
|
|
{
|
|
{
|
|
|
-
|
|
|
|
|
- Log.d("onActivityCreated","create support map fragment");
|
|
|
|
|
- fragment = SupportMapFragment.newInstance();;// .newInstance();
|
|
|
|
|
|
|
+
|
|
|
|
|
+ Log.d("onActivityCreated", "create support map fragment");
|
|
|
|
|
+ fragment = SupportMapFragment.newInstance();
|
|
|
|
|
+ ;// .newInstance();
|
|
|
fm.beginTransaction().replace(R.id.map, fragment).commit();
|
|
fm.beginTransaction().replace(R.id.map, fragment).commit();
|
|
|
}
|
|
}
|
|
|
mMapView = fragment.getMapView();
|
|
mMapView = fragment.getMapView();
|
|
@@ -445,21 +458,23 @@ public class BaiduMapFragment extends Fragment
|
|
|
Bundle savedInstanceState)
|
|
Bundle savedInstanceState)
|
|
|
{
|
|
{
|
|
|
// TODO Auto-generated method stub
|
|
// TODO Auto-generated method stub
|
|
|
-// return super.onCreateView(inflater, container, savedInstanceState);
|
|
|
|
|
|
|
+ // return super.onCreateView(inflater, container, savedInstanceState);
|
|
|
requestloactions();
|
|
requestloactions();
|
|
|
return inflater.inflate(R.layout.fragment_service_location, container,
|
|
return inflater.inflate(R.layout.fragment_service_location, container,
|
|
|
false);
|
|
false);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public void onResume()
|
|
public void onResume()
|
|
|
{
|
|
{
|
|
|
super.onResume();
|
|
super.onResume();
|
|
|
|
|
|
|
|
- Log.d("onResume","get map from fragment");
|
|
|
|
|
|
|
+ Log.d("onResume", "get map from fragment");
|
|
|
|
|
|
|
|
MapController controller = fragment.getMapView().getController();
|
|
MapController controller = fragment.getMapView().getController();
|
|
|
- controller.setCenter(new GeoPoint((int)(39.945 * 1E6), (int)(116.404 * 1E6)));
|
|
|
|
|
- controller.setZoom(13);
|
|
|
|
|
|
|
+ controller.setCenter(new GeoPoint((int) (29.945 * 1E6),
|
|
|
|
|
+ (int) (106.404 * 1E6)));
|
|
|
|
|
+ controller.setZoom(5);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|