summaryrefslogtreecommitdiff
path: root/client/Piztor/src/com/macaroon
diff options
context:
space:
mode:
Diffstat (limited to 'client/Piztor/src/com/macaroon')
-rw-r--r--client/Piztor/src/com/macaroon/piztor/BMapUtil.java5
-rw-r--r--client/Piztor/src/com/macaroon/piztor/Main.java32
-rw-r--r--client/Piztor/src/com/macaroon/piztor/MapMaker.java60
3 files changed, 64 insertions, 33 deletions
diff --git a/client/Piztor/src/com/macaroon/piztor/BMapUtil.java b/client/Piztor/src/com/macaroon/piztor/BMapUtil.java
index 04e2e71..38d9f7d 100644
--- a/client/Piztor/src/com/macaroon/piztor/BMapUtil.java
+++ b/client/Piztor/src/com/macaroon/piztor/BMapUtil.java
@@ -5,11 +5,6 @@ import android.view.View;
public class BMapUtil {
- /**
- * 从view 得到图片
- * @param view
- * @return
- */
public static Bitmap getBitmapFromView(View view) {
view.destroyDrawingCache();
view.measure(View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED),
diff --git a/client/Piztor/src/com/macaroon/piztor/Main.java b/client/Piztor/src/com/macaroon/piztor/Main.java
index c3f6047..952b7f2 100644
--- a/client/Piztor/src/com/macaroon/piztor/Main.java
+++ b/client/Piztor/src/com/macaroon/piztor/Main.java
@@ -4,6 +4,8 @@ import java.util.Timer;
import java.util.TimerTask;
import android.annotation.SuppressLint;
+import android.graphics.Bitmap;
+import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
@@ -19,10 +21,15 @@ import com.baidu.location.BDLocation;
import com.baidu.location.BDLocationListener;
import com.baidu.location.LocationClient;
import com.baidu.location.LocationClientOption;
+import com.baidu.mapapi.map.ItemizedOverlay;
import com.baidu.mapapi.map.LocationData;
import com.baidu.mapapi.map.MapView;
import com.baidu.mapapi.map.OverlayItem;
+import com.baidu.mapapi.map.PopupClickListener;
import com.baidu.mapapi.map.PopupOverlay;
+import com.baidu.platform.comapi.basestruct.GeoPoint;
+
+import com.macaroon.piztor.BMapUtil;
public class Main extends PiztorAct {
final static int SearchButtonPress = 1;
@@ -32,19 +39,6 @@ public class Main extends PiztorAct {
final static int Fetch = 6;
final static int mapViewtouched = 7;
- /**
- * popups
- */
- private PopupOverlay pop = null;
- private TextView popupText = null;
- private View viewCache = null;
- private View popupInfo = null;
- private View popupLeft = null;
- private View popupRight = null;
- private MapView.LayoutParams layoutParam = null;
- private OverlayItem mCurItem = null;
-
-
MapMaker mapMaker = null;
MapView mMapView;
@@ -156,7 +150,6 @@ public class Main extends PiztorAct {
void flushMap() {
if (mapMaker != null)
mapMaker.UpdateMap(AppMgr.mapInfo);
- else System.out.println("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
}
public class MyLocationListener implements BDLocationListener {
@@ -300,8 +293,6 @@ public class Main extends PiztorAct {
actMgr.add(focusStatus, Fetch, focusStatus);
//autodate = new Timer();
flushMap();
- // ImageView view = (ImageView) findViewById(R.id.main_mapview);
- // view.setOnTouchListener(new MultiTouchListener());
setContentView(R.layout.activity_main);
mMapView = (MapView) findViewById(R.id.bmapView);
mapMaker = new MapMaker(mMapView, getApplicationContext());
@@ -316,15 +307,8 @@ public class Main extends PiztorAct {
mLocClient.setLocOption(option);
mLocClient.start();
mapMaker.UpdateLocationOverlay(locData, false);
-
- }
- /*
- public boolean onTap(int index) {
- OverlayItem item = getItem(index);
- mCurItem = item;
- if ()
}
- */
+
@Override
protected void onStart() {
super.onStart();
diff --git a/client/Piztor/src/com/macaroon/piztor/MapMaker.java b/client/Piztor/src/com/macaroon/piztor/MapMaker.java
index 89f29fc..0c1a7d0 100644
--- a/client/Piztor/src/com/macaroon/piztor/MapMaker.java
+++ b/client/Piztor/src/com/macaroon/piztor/MapMaker.java
@@ -12,14 +12,17 @@ import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.KeyEvent;
+import android.view.LayoutInflater;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ImageView;
+import android.widget.TextView;
import android.app.Activity;
import android.content.Context;
import android.content.res.Configuration;
+import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.widget.FrameLayout;
import android.widget.Toast;
@@ -42,6 +45,7 @@ import com.baidu.mapapi.map.MapPoi;
import com.baidu.mapapi.map.MapView;
import com.baidu.mapapi.map.MyLocationOverlay;
import com.baidu.mapapi.map.OverlayItem;
+import com.baidu.mapapi.map.PopupClickListener;
import com.baidu.mapapi.map.PopupOverlay;
import com.baidu.platform.comapi.basestruct.GeoPoint;
@@ -56,6 +60,13 @@ public class MapMaker extends Activity{
private ArrayList<OverlayItem> mItems = null;
private LocationOverlay mLocationOverlay;
private Context context;
+ /**
+ * popups
+ */
+ private PopupOverlay popLay = null;
+ private TextView popupText = null;
+ private View viewCache = null;
+ private View popupInfo = null;
public MapMaker(MapView mapView, Context c) {
mMapView = mapView;
@@ -75,11 +86,31 @@ public class MapMaker extends Activity{
}
}
- public class MyOverlay extends ItemizedOverlay {
+ public class MyOverlay extends ItemizedOverlay{
public MyOverlay(Drawable defaultMarker, MapView mapView) {
super(defaultMarker, mapView);
}
- }
+
+ @Override
+ public boolean onTap(int index){
+ Log.d("123", "Marker tap");
+ OverlayItem item = getItem(index);
+ popupText.setText("^ _ ^");
+ Bitmap bitmap = BMapUtil.getBitmapFromView(popupInfo);
+ popLay.showPopup(bitmap,item.getPoint(),32);
+ return true;
+ }
+
+ @Override
+ public boolean onTap(GeoPoint pt, MapView mMapView){
+ Log.d("123", "Marker tap disappear");
+
+ if (popLay != null){
+ popLay.hidePop();
+ }
+ return false;
+ }
+ }
public void UpdateLocationOverlay(LocationData locationData, boolean hasAnimation) {
/**
@@ -102,6 +133,29 @@ public class MapMaker extends Activity{
mLocationOverlay.enableCompass();
mMapView.refresh();
mOverlay = new MyOverlay(context.getResources().getDrawable(R.drawable.circle_red), mMapView);
+ Log.d("123", "MapView initialized");
+
+ /**
+ * Initialize pop up
+ */
+ LayoutInflater inflater = (LayoutInflater) context.getSystemService( Context.LAYOUT_INFLATER_SERVICE );
+ Log.d("123", "OK 0");
+ viewCache = inflater.inflate(R.layout.custom_text_view, null);
+ Log.d("123", "OK 1");
+ popupInfo = (View) viewCache.findViewById(R.id.popinfo);
+ Log.d("123", "OK 2");
+ popupText = (TextView) viewCache.findViewById(R.id.textcache);
+ Log.d("123", "OK 3");
+ Log.d("123", "Popup initialized");
+
+
+ PopupClickListener popListener = new PopupClickListener() {
+ @Override
+ public void onClickedPopup(int index) {
+ //
+ }
+ };
+ popLay = new PopupOverlay(mMapView, popListener);
}
public void UpdateMap(MapInfo mapInfo) {
@@ -109,9 +163,7 @@ public class MapMaker extends Activity{
* Update location of others
*/
if (mOverlay != null && mOverlay.getAllItem().size() != 0) {
- System.out.println("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
clearOverlay(mMapView);
- System.out.println("+++++++++++++++++++++++------------------------------------------");
}
mOverlay = new MyOverlay(context.getResources().getDrawable(R.drawable.circle_red), mMapView);
//mMapView.refresh();