/**
* Inherit from mapview and override ontouchevent to Implement Bubble Processing
* @ Author Hejin
*
*/
Class seeothermapview extends mapview {
Context context;
Geopoint pt;
Float lastx;
Float lasty;
Long lastdowntime;
Boolean mislongpressed;
Boolean misexcute; // determines whether a long-time operation has been performed
Public seeothermapview (context ){
Super (context );
This. Context = context;
// Todo auto-generated constructor stub
}
Public seeothermapview (context, attributeset attrs ){
Super (context, attrs );
This. Context = context;
}
Public seeothermapview (context, attributeset attrs, int defstyle ){
Super (context, attrs, defstyle );
This. Context = context;
}
@ Override
Public Boolean ontouchevent (motionevent event ){
Switch (event. getaction ()){
Case motionevent. action_down:
Lastx = (INT) event. getx ();
Lasty = (INT) event. Gety ();
Lastdowntime = event. getdowntime ();
Misexcute = true;
Break;
Case motionevent. action_move:
Int thisx = (INT) event. getx ();
Int thisy = (INT) event. Gety ();
Long thiseventtime = event. geteventtime ();
// Check whether long-pressing is performed on a non-long-time basis
If (! Mislongpressed ){
Mislongpressed = islongpressed (lastx, lasty, thisx, thisy, lastdowntime, thiseventtime, 1000 );
}
If (mislongpressed ){
// What is done in long-pressed Mode
// Convert pixel coordinates into address coordinates
If (misexcute ){
PT = This. getprojection (). frompixels (thisx, thisy );
// Todo auto-generated method stub
New msgdlg (context, R. drawable. app, "", Pt. getlatitudee6 () + "-" + Pt. getlongitudee6 (), "yes", "no ");
Setposition (Pt. getlatitudee6 (), Pt. getlongitudee6 (), R. drawable. icon_geo );
Misexcute = false;
}
Mislongpressed = false;
} Else {
// What the Mobile mode does
}
Break;
Case motionevent. action_up:
Misexcute = false;
Break;
}
// Obtain the position of the screen click 20.
// Return true;
Return super. ontouchevent (event );
}
Public void setposition (INT clat, int Clon, int drawableid ){
Geopoint P;
P = new geopoint (clat, clon );
Drawable mark = getresources (). getdrawable (drawableid );
// Create iteminizedoverlay
Itemizedoverlay <overlayitem> itemoverlay = new itemizedoverlay <overlayitem> (mark, this );
// Add iteminizedoverlay to mapview
Itemoverlay. additem (New overlayitem (P, "item0", "itme0 "));
This. getoverlays (). Clear ();
This. getoverlays (). Add (itemoverlay );
This. getcontroller (). setcenter (P );
This. Refresh ();
}
/**
** Determine whether there is a long press * @ Param lastx x coordinate * @ Param lasty y coordinate *
*
* @ Param thisx
* X coordinate when moving *
* @ Param thisy
* Y coordinate when moving *
* @ Param lastdowntime
* Press time *
* @ Param thiseventtime
* Moving time *
* @ Param longpresstime
* Determine the threshold value of a long press time
*/
Static Boolean islongpressed (float lastx, float lasty, float thisx,
Float thisy, long lastdowntime, long thiseventtime,
Long longpresstime ){
Float offsetx = math. Abs (thisx-lastx );
Float offsety = math. Abs (thisy-lasty );
Long intervaltime = thiseventtime-lastdowntime;
If (offsetx <= 5 & offsety <= 5 & intervaltime> = longpresstime ){
Return true;
}
Return false;
}
}