0

I am working on google maps. I done every thing as simple map and now map is shown in my activity now I want that I search location using Edit text and then by clicking on find button.But i am confused that how to do it and how to save LatLang of searched location. here is code for getting map

 btn_find=(Button)findViewById(R.id.btn_find);
        
        map = ((MapFragment) getFragmentManager()
                .findFragmentById(R.id.map)).getMap();
        if (map == null) {
            Toast.makeText(this, "Google Maps not available",
                    Toast.LENGTH_LONG).show();
        }

and this is my layout

    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <Button
            android:id="@+id/btn_find"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/str_btn_find"
            android:layout_alignParentRight="true" />

        <EditText
            android:id="@+id/et_location"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:inputType="text"
            android:hint="@string/hnt_et_location"
            android:layout_toLeftOf="@id/btn_find" />

    </RelativeLayout>

    <fragment xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/map"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        class="com.google.android.gms.maps.MapFragment" />

help me for that

  • Have a look at [this](http://stackoverflow.com/questions/3574644/how-can-i-find-the-latitude-and-longitude-from-address). There are many post which already exist for this. – Exception May 22 '15 at 11:04
  • Okay do you want latitude and longitude of the location edit text gives. and then it searches that address on google maps? – Suraj Palwe May 22 '15 at 11:09
  • yes sir as we search on google maps – Chaudry Junaid SaifUllah Chadh May 22 '15 at 11:11
  • @ChaudryJunaidSaifUllahChadh Follow [this](http://wptrafficanalyzer.in/blog/android-geocoding-showing-user-input-location-on-google-map-android-api-v2/) tutorial. It tries to do exactly what you desire. – Exception May 22 '15 at 11:18
  • Sir the tutorial you suggested me is causing ClassCastException exception. And It is not solving. When I extend my activity with FragmentActivity it gives this exception. Now tell me what should I do ? @ Exception – Chaudry Junaid SaifUllah Chadh May 22 '15 at 11:30

0 Answers0