[問題] 在mapView上click並觸發事件
各位版友好~
小弟想請問一下這個問題
我想要達到的功能是這樣
用GPS定位抓到現在的位置並顯示地圖
然後在地圖上click
觸發事件之後在click的點上新增一個標籤tag在上面
嗯嗯
是說我現在竟然連click顯示個吐司都沒辦法..
不知道哪裡有問題
public class Part14_MapActivity extends MapActivity implements
LocationListener {
/** Called when the activity is first created. */
private MapView map;
private MapController mapCtrl;
private MyLocationOverlay myPoint;
private LocationManager mgr;
private String bestProv;
/*public enum BasePoint
{
TOP_LEFT,TOP_CENTER,TOP_RIGHT,MIDDLE_LEFT,MIDDLE_CENTER,MIDDLE_RIGHT,
BOTTOM_LEFT,BOTTOM_CENTER,BOTTOM_RIGHT
}*/
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//setViews();
setMap(25.019943,121.542553);
}
............
private void setMap(double dlat,double dlon)
{
map=(MapView)findViewById(R.id.map);
map.setBuiltInZoomControls(true);
map.setSatellite(false);
mapCtrl=map.getController();
mapCtrl.setZoom(18);
//////setup overlay function
List<Overlay> mapOverlays=map.getOverlays();//get overlay container of
map
OverlayItem item;
Drawable pic;
MapItemlizedOverlay mOverlay;
GeoPoint point;
pic=getResources().getDrawable(R.drawable.ic_launcher);//ic_launcher is
just a pic default in res
pic.setBounds(-pic.getMinimumWidth()/2, -pic.getMinimumHeight()/2,
pic.getMinimumWidth()/2,pic.getMinimumHeight()/2);
///
pic.setAlpha(100);
mOverlay=new MapItemlizedOverlay(pic,this);//set default tag pic and
context
point=new GeoPoint((int)(dlat*1e6),(int)(dlon*1e6));
item=new OverlayItem(point,"台北市","天龍國");
mOverlay.addOverlay(item);
mapOverlays.add(mOverlay);
//GPS2
mgr=(LocationManager)getSystemService(LOCATION_SERVICE);
Criteria c=new Criteria();
bestProv=mgr.getBestProvider(c, true);
map.setOnLongClickListener(new View.OnLongClickListener(){
public boolean onLongClick(View arg0) {
// TODO Auto-generated method stub
Toast.makeText(Part14_MapActivity.this, "ahhhhhhhh",100000).show();
Log.d("ahhhh","ffffffffff");
return false;
}
});
......
不知道是哪出了問題....
連log都不知道在哪.....
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 1.161.13.145
推
08/07 11:45, , 1F
08/07 11:45, 1F
→
08/07 22:13, , 2F
08/07 22:13, 2F
推
08/08 17:12, , 3F
08/08 17:12, 3F
→
08/11 11:27, , 4F
08/11 11:27, 4F