2017-01-14 5 views
0

私は、Androidに新たなんだと、私はこの記事のようなのMapView上のタッチ Google Maps Android API v2 - detect touch on mapどのようにアンドロイドにGoogleマップのタッチイベントを処理するために(断片内)

を処理したいしかし、それはかなり違い、私の例では、Iフラグメントクラスを使用してすべてのマップビジネスを処理します。

マイレイアウト:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:ads="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" > 

    <com.google.android.gms.maps.MapView 
     android:id="@+id/map" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" /> 
    <ImageButton 
     android:id="@+id/buttonTracking" 
     ... /> 
</LinearLayout> 

私はすでにsetOnTouchListenerを使用しようとしているが、それは

public class MapsFragment extends Fragment implements PermissionsFragment { 
    public View onCreateView(LayoutInflater inflater, ViewGroup container, 
         Bundle savedInstanceState) { 
     ll = (LinearLayout) inflater.inflate(R.layout.fragment_maps, container, false); 
     mMapView = (MapView) ll.findViewById(R.id.map); 
     ll.setOnTouchListener(new View.OnTouchListener(){ 
      @Override 
      public boolean onTouch(View v, MotionEvent event){ 
       Log.e("INFO", "Touched"); 
       return true; 
      } 
     }); 
    } 
} 

私はanythingsを欠場動作しませんか?助けてください! Googleマップのおかげで

答えて

0

セットクリックリスナーはMapViewの

GoogleMap map; 

map.setOnMapClickListener(new GoogleMap.OnMapClickListener() { 
     @Override 
     public void onMapClick(final LatLng clickCoords) { 
      //do your code here 
     } 
}; 
+1

clickListenerは、ユーザーのアクションを検出するために十分ではありませんではないオブジェクト。私はユーザードラッグマップを検出したい。この問題を解決するために、 'setOnCameraMoveStartedListener'を理由= 'REASON_GESTURE'で使用しています。 –

関連する問題