当前位置:操作系统 > 安卓/Android >>

android - MapView地图里标记自己的地点,生成新的地点

 

/**

     * This is class for touch event ,when user touched the screen for 

     * enough time, user can tag the touched place as user's favorite

     * place, or fix current position and set as destination.

     * @author xinyan

     *@date 2011-10-10

     */ 

    class Touchy extends Overlay { 

 

        @Override 

        public boolean onTouchEvent(MotionEvent e, MapView mapView) { 

            Log.v(TAG, "Touchy is touched..."); 

            if (MotionEvent.ACTION_DOWN == e.getAction()) { 

                start = e.getEventTime(); 

                x = (int) e.getX(); 

                y = (int) e.getY(); 

                touchPoint = mMapView.getProjection().fromPixels(x, y); 

                Log.v(TAG, "Touchy is touched.. and we get touch point."); 

            } 

            if (MotionEvent.ACTION_UP == e.getAction()) { 

                stop = e.getEventTime(); 

            } 

            if (stop - start > 1500) { 

                OverlayItem overlayItem = new OverlayItem(touchPoint, 

                        "Pined position", "A new position"); 

                CustomPinpoint custom = new CustomPinpoint(marker, 

                        StandardActivity.this); 

                custom.insertPinpoint(overlayItem); 

                mMapView.getOverlays().add(custom); 

 

                new AlertDialog.Builder(StandardActivity.this) 

                        .setIcon(null) 

                        .setTitle(R.string.whatYouWant) 

                        .setSingleChoiceItems( 

                                R.array.select_dialog_whatYouWant, 0, 

                                new DialogInterface.OnClickListener() { 

                                    @Override 

                                    public void onClick(DialogInterface dialog, 

                                            int whichButton) { 

 

                                        if (0 == whichButton) { 

 

                                            // user clicked fix my current 

                                            // position choice 

                                        } else if (1 == whichButton) { 

 

                                            // user clicked set as destination 

                                            // choice 

                                        } 

                                    } 

                                }) 

                        .setPositiveButton(R.string.positive, 

              &nb

补充:移动开发 , Android ,
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,