0

ユーザーがクリックした地図上の場所の緯度と経度を取得し、それらを計算します。ところで、私はエミュレーターで作業していて、携帯電話にアクセスできず、エミュレーターで実行する必要があると言います。何をすべきか助けてください!

4

3 に答える 3

0
We can not get the current lat and long values in the emulator up to my knowledge. You have to put them your self.Correct me if I am wrong but this is true for that you have to use the real device.

I think this code will help you.Give try on device and let me know.

public class Google_maps extends MapActivity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_google_maps);


        MapView mapview=(MapView)findViewById(R.id.mapView);
        mapview.setBuiltInZoomControls(true);
        MapOverlay mapOverlay = new MapOverlay();
        List<Overlay> listOfOverlays = mapview.getOverlays();
        listOfOverlays.clear();
        listOfOverlays.add(mapOverlay);        

        mapview.invalidate();

    }

    class MapOverlay extends Overlay
    {

        @Override
        public boolean onTouchEvent(MotionEvent event, MapView mapView) 
        {   
            //---when user lifts his finger---
            if (event.getAction() == 1) {                
                GeoPoint p = mapView.getProjection().fromPixels(
                    (int) event.getX(),
                    (int) event.getY());
                    Toast.makeText(getBaseContext(), 
                        p.getLatitudeE6() / 1E6 + "," + 
                        p.getLongitudeE6() /1E6 , 
                        Toast.LENGTH_SHORT).show();


            }                            
            return false;
        }        
    }
    @Override
    protected boolean isRouteDisplayed() {
        return false;
    }}
于 2013-02-20T06:01:36.663 に答える
0

使用しているもの (Google API、または地図の画像) を明確にする必要があります。画像を使用している場合は Java for Android を使用していると想定しています
onTouchEvent。地図上で経度と緯度を自分で知っている限り、経度と緯度として画面に表示されます...質問はより具体的にしてください。

public boolean onTouchEvent(MotionEvent event){
    int action = event.getAction();
    int x = event.getX()  
    int y = event.getY();
    return yourBoolean;
}
于 2013-02-20T05:46:46.827 に答える
0

この質問は非常に紛らわしいので、必要性を詳しく説明してください。Webサービスまたは現在の場所から取得していると思われる緯度と経度の値をGoogleマップに表示できます。エミュレータで Google マップを使用するには、Google マップ キーが必要です。どのような支援が必要かを正確にお知らせください。

http://blogspot.fluidnewmedia.com/2009/04/displaying-google-maps-in-the-android-emulator/ 上記のリンク ID から始めるとよいでしょう。

于 2013-02-20T05:36:06.663 に答える