How to implement google maps search by address in Android?

How to implement google maps search by address in Android?

  • Implement drag item to the screen edge feature
  • How to generate signed and unsigned APK's using gradle?
  • registerMediaButtonEventReceiver not receiving events
  • Send Data from Service To Activity Android
  • AppInvites “Install” link doesn't open the app
  • Fragment methods: attach(), detach(), remove(), replace(), popBackStack()
  • Related posts:

    Import Android Test Project into Eclipse from Version Control
    java.lang.UnsatisfiedLinkError: Couldn't load stlport_shared: findLibrary returned null (te...
    Parse JSON date format to String using GSON on Android
    How to handle memory limitation of GPU for high resolution image processing on GPU?
    Plugin with id 'com.android.library' not found
    java.lang.VerifyError in Application class for a small percentage of users
  • android:layout_weight beginner's question
  • Adb install failure: INSTALL_CANCELED_BY_USER
  • can I use static layout (native UI) in react native's native android implementation?
  • What's the best language for real-time graphics programming on Android?
  • Android, javamail and proguard
  • How to change Android usb connect mode to charge only?
  • One Solution collect form web for “How to implement google maps search by address in Android?”

    For that you need to create one map overlay class in map activity.

    Example

    class MapOverlay extends com.google.android.maps.Overlay
    {
        public boolean draw(Canvas canvas, MapView mapView, 
        boolean shadow, long when) 
        {
            super.draw(canvas, mapView, shadow);                   
    
            //---translate the GeoPoint to screen pixels---
            Point screenPts = new Point();
            mapView.getProjection().toPixels(p, screenPts);
    
            //---add the marker---
            Bitmap bmp = BitmapFactory.decodeResource(
                getResources(), R.drawable.pink);            
            canvas.drawBitmap(bmp, screenPts.x, screenPts.y-32, null);         
            return true;
        }
    } 
    

    Where please change R.drawable.pink . Put your any drawable.

    Now please write below code in your search onClick event..

    Example

    List<Address> addresses = geoCoder.getFromLocationName(txtsearch.getText().toString(),5);
    
    if(addresses.size() > 0) {
        p = new GeoPoint( (int) (addresses.get(0).getLatitude() * 1E6), 
            (int) (addresses.get(0).getLongitude() * 1E6));
    
        controller.animateTo(p);
        controller.setZoom(12);
    
        MapOverlay mapOverlay = new MapOverlay();
        List<Overlay> listOfOverlays = map.getOverlays();
        listOfOverlays.clear();
        listOfOverlays.add(mapOverlay);
    
        map.invalidate();
        txtsearch.setText("");
    }
    else {
        AlertDialog.Builder adb = new AlertDialog.Builder(GoogleMap.this);
        adb.setTitle("Google Map");
        adb.setMessage("Please Provide the Proper Place");
        adb.setPositiveButton("Close",null);
        adb.show();
    }
    

    Where txtsearch is a EditText and controller is a map controller ..

    Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.