2017-06-27 24 views
0

APIからダウンロードしたマーカーを使用してマップフラグメントを作成しました。SearchViewをフラグメントに追加しました。タイトルごとにマーカーを通すか、または切り取る。入力中にクエリに一致する項目のリストを表示します。アイテムをタップすると他のすべてのマーカーが削除され、タップされたマーカーが拡大表示されます。カスタムマップマーカーで検索して結果をリストに表示する

どうすればいいですか?以下は

fragment_map.xml

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context="com.example.abed.whitelabel.Fragments.CustomersFragment"> 

    <LinearLayout 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:orientation="vertical"> 

     <android.support.v7.widget.SearchView 
     android:id="@+id/map_search_view" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     ></android.support.v7.widget.SearchView> 

     <fragment xmlns:android="http://schemas.android.com/apk/res/android" 
      xmlns:map="http://schemas.android.com/apk/res-auto" 
      xmlns:tools="http://schemas.android.com/tools" 
      android:id="@+id/map" 
      android:name="com.google.android.gms.maps.SupportMapFragment" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" /> 


    </LinearLayout> 

</FrameLayout> 

答えて

0

達成するために使用することができロジックです。

マーカーで検索したり、切り抜きしたいと思っています。入力中にクエリに一致する項目のリストが表示されます

apiから取得するすべてのエントリを使用して、検索ビューにアダプタを設定できます。 this SO answerで検索ビューを実装する方法については、

をタップすると、他のすべてのマーカーが削除され、タップされたマーカーがズームされます。

私はsearchViewにリスナーをクリックし

1.Set項目は、以下の手順に従ってください、あなたは検索ビュー候補リストの項目をタップするとします。

2. onItemClick()メソッドの場合は、選択した位置からリストのオブジェクトを取得します。位置の座標は指定できます。 onItemClickメソッドで以下のメソッドを実行します。

3.Clearマップ上のすべてのマーカー選択したすべての最良のコード

CameraPosition cameraPosition = new CameraPosition.Builder() 
    .target(new LatLng(your_location.getLatitude(), your_location.getLongitude()))  // Sets the center of the map to location user 
    .zoom(17)     // Sets the zoom 
    .build();     // Creates a CameraPosition from the builder 
map.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition)); 

下に呼び出すことで、座標にマップmap.clear()

4.Zoomを呼び出すことによって。ハッピーコーディング。 :)

+0

ありがとうございますが、リンクは私が必要とするものではありません。自分のカスタムクラスの配列を取り込み、その配列を検索したいと思います。また、私はそれを行う方法を理解するのを探しています。 –

+0

@AbedNaseri私は、リンクには、検索ビューのオートコンプリート機能で達成しようとしていることについての情報がかなりあり、わかりやすいと思われます。カスタムクラスでもそれを実行できるはずです。 :) – SripadRaj

+0

もう一度、私は本当に自動提案を必要としないし、私はAPIを介して検索したくない、私はすでにAPIからオブジェクトの配列を移入し、今は配列を検索する必要があります。 @SripadRaj –

関連する問題