Search in Google Maps API Android

1

I am creating an application that uses Google Maps, I have implemented a search box, the problem is that when doing the search, it is done all over the world. What I want to do is that this search is limited only to my city where the application is focused. For example, when entering the name of a street, just look for the street in my city and not in the whole world. This is the code with which I do the search:

editText = (EditText) findViewById(R.id.search);
    go = (Button) findViewById(R.id.go);
    type = (Button) findViewById(R.id.type);

    go.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            String data = editText.getText().toString();
            List<Address> list = null;

            if(!data.equals("") || data != null ){
                Geocoder geocoder = new Geocoder(Ruta1Unidad.this);


                try{
                   list = geocoder.getFromLocationName(data,1);
                }catch (IOException e) {
                    e.printStackTrace();
                }

                Address address = list.get(0);
                LatLng marker2 = new LatLng(address.getLatitude(),  address.getLongitude());
                mMap.addMarker(new MarkerOptions().position(marker2).title("Prueba"));
                mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(marker2, 13f));

            }
        }
    });
    
asked by Emmanuel Molina 27.12.2017 в 21:42
source

0 answers