@SuppressLint("NewApi")
 private void initilizeMap() {
   try {
     System.out.println("---     initialize Map called    ---" + googleMap);
     if (googleMap == null) {
       mapFragment = ((MapFragment) getFragmentManager().findFragmentById(R.id.map));
       googleMap = mapFragment.getMap();
       googleMap.getUiSettings().setMyLocationButtonEnabled(true);
       googleMap.setMyLocationEnabled(true);
       newlatitude = address.getLatitude();
       newlongitude = address.getLongitude();
       try {
         System.out.println(
             "lat :---------- "
                 + address.getLatitude()
                 + " long :---------- "
                 + address.getLongitude());
         if (address.getLatitude() != 0.0 && address.getLongitude() != 0.0) {
           googleMap.addMarker(
               new MarkerOptions()
                   .position(new LatLng(address.getLatitude(), address.getLongitude()))
                   .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_BLUE)));
         }
         ViewGroup.LayoutParams params = mapFragment.getView().getLayoutParams();
         mapFragment.getView().setLayoutParams(params);
         googleMap.animateCamera(
             CameraUpdateFactory.newLatLngZoom(
                 new LatLng(address.getLatitude(), address.getLongitude()), 13.0f));
       } catch (Exception e) {
         e.printStackTrace();
       }
     }
   } finally {
   }
 }
Exemple #2
0
  public void geocodeLocation(Context ctx) {
    if (ctx != null) {

      Geocoder geocoder = new Geocoder(ctx);

      try {
        List<Address> addresses = geocoder.getFromLocationName(this.address, 1);
        if (addresses.size() == 0) {
          String smallAddress = this.addressShort;
          if (smallAddress.contains("-")) {
            smallAddress = smallAddress.split("-")[0];
          }
          addresses = geocoder.getFromLocationName(smallAddress + " " + this.town, 1);
        }
        if (addresses.size() != 0) {
          Address address = addresses.get(0);
          this.lon = (float) address.getLongitude();
          this.lat = (float) address.getLatitude();
        } else {
          String test = "test";
        }
      } catch (IOException e) {
        e.printStackTrace();
      }
    }
  }
  @Override
  public void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    final ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
      actionBar.setDisplayHomeAsUpEnabled(true);
    }

    // set language
    MainActivity.setLocale(this);
    setContentView(R.layout.dbresult);

    // force media volume controls
    setVolumeControlStream(AudioManager.STREAM_MUSIC);

    setupList();

    QueryArgs queryArgs = ListFragment.lameStatic.queryArgs;
    MainActivity.info("queryArgs: " + queryArgs);
    final TextView tv = (TextView) findViewById(R.id.dbstatus);

    if (queryArgs != null) {
      tv.setText(getString(R.string.status_working) + "...");
      Address address = queryArgs.getAddress();
      LatLng center = MappingFragment.DEFAULT_POINT;
      if (address != null) {
        center = new LatLng(address.getLatitude(), address.getLongitude());
      }
      setupMap(center, savedInstanceState);
      setupQuery(queryArgs);
    } else {
      tv.setText(getString(R.string.status_fail) + "...");
    }
  }
  @UiThread
  void updateUiAdapter(Address address) {
    if (map == null) {
      return;
    }
    try {
      ignoreUpdate = true;
      CameraPosition position =
          new CameraPosition.Builder()
              .target(new LatLng(address.getLatitude(), address.getLongitude()))
              .zoom(currentZoom)
              .build();
      CameraUpdate update = CameraUpdateFactory.newCameraPosition(position);
      map.animateCamera(update);

      autocompleteEndereco.setAdapter(null);
      autocompleteEndereco.setText(street);
      autocompleteEndereco.setAdapter(
          new PlacesAutoCompleteAdapter(
              getActivity(), R.layout.autocomplete_list_item, ExploreFragment.class));
      tvNumero.setText(number);
    } catch (Exception e) {
      Log.e("ZUP", e.getMessage(), e);
      Crashlytics.logException(e);
    }
  }
Exemple #5
0
    @Override
    protected void onPostExecute(List<Address> addresses) {

      if (addresses == null || addresses.size() == 0) {
        Toast.makeText(getActivity(), "No Location found", Toast.LENGTH_SHORT).show();
      }

      // Clears all the existing markers on the map
      googleMap.clear();

      // Adding Markers on Google Map for each matching address
      for (int i = 0; i < addresses.size(); i++) {

        Address address = (Address) addresses.get(i);

        // Creating an instance of GeoPoint, to display in Google Map
        latLng = new LatLng(address.getLatitude(), address.getLongitude());

        String addressText =
            String.format(
                "%s, %s",
                address.getMaxAddressLineIndex() > 0 ? address.getAddressLine(0) : "",
                address.getCountryName());

        markerOptions = new MarkerOptions();
        markerOptions.position(latLng);
        markerOptions.title(addressText);

        googleMap.addMarker(markerOptions);

        // Locate the first location
        if (i == 0) googleMap.animateCamera(CameraUpdateFactory.newLatLng(latLng));
      }
    }
  public GeoPoint(@NonNull Address address) {
    if (address == null) {
      return;
    }

    this.name = address.getLocality();
    this.latitude = address.getLatitude();
    this.longitude = address.getLongitude();
  }
  public AddressOverlay(Address address) {
    super();
    assert (null != address);
    this.setAddress(address);
    Double convertedLongitude = address.getLongitude() * 1E6;
    Double convertedLatitude = address.getLatitude() * 1E6;

    setGeopoint(new GeoPoint(convertedLatitude.intValue(), convertedLongitude.intValue()));
  }
  private void geocodeLocation(String placeName) {

    // Following adapted from Conder and Darcey, pp.321 ff.
    Geocoder gcoder = new Geocoder(this);

    // Note that the Geocoder uses synchronous network access, so in a serious application
    // it would be best to put it on a background thread to prevent blocking the main UI if network
    // access is slow. Here we are just giving an example of how to use it so, for simplicity, we
    // don't put it on a separate thread.  See the class RouteMapper in this package for an example
    // of making a network access on a background thread. Geocoding is implemented by a backend
    // that is not part of the core Android framework, so we use the static method
    // Geocoder.isPresent() to test for presence of the required backend on the given platform.

    try {
      List<Address> results = null;
      if (Geocoder.isPresent()) {
        results = gcoder.getFromLocationName(placeName, numberOptions);
      } else {
        Log.i(TAG, "No geocoder found");
        return;
      }
      Iterator<Address> locations = results.iterator();
      String raw = "\nRaw String:\n";
      String country;
      int opCount = 0;
      while (locations.hasNext()) {
        Address location = locations.next();
        if (opCount == 0 && location != null) {
          lat = location.getLatitude();
          lon = location.getLongitude();
        }
        country = location.getCountryName();
        if (country == null) {
          country = "";
        } else {
          country = ", " + country;
        }
        raw += location + "\n";
        optionArray[opCount] =
            location.getAddressLine(0) + ", " + location.getAddressLine(1) + country + "\n";
        opCount++;
      }
      // Log the returned data
      Log.i(TAG, raw);
      Log.i(TAG, "\nOptions:\n");
      for (int i = 0; i < opCount; i++) {
        Log.i(TAG, "(" + (i + 1) + ") " + optionArray[i]);
      }
      Log.i(TAG, "lat=" + lat + " lon=" + lon);

    } catch (IOException e) {
      Log.e(TAG, "I/O Failure; do you have a network connection?", e);
    }
  }
  private void identifyCoordinates(ua.maxim.ordersgeocoder.Data.Address address) {

    Address locationAddress;

    locationAddress = getCoordinates(address.toString());

    if (locationAddress != null) {

      address.setLatitude(locationAddress.getLatitude());
      address.setLongitude(locationAddress.getLongitude());
    }
  }
Exemple #10
0
  public void geoLocate(View v) throws IOException {
    hideSoftkeyboard(v);

    EditText et = (EditText) findViewById(R.id.editSearch);
    String location = et.getText().toString();

    Geocoder gc = new Geocoder(this);
    List<Address> list = gc.getFromLocationName(location, 1);
    Address add = list.get(0);
    double lat = add.getLatitude();
    double lng = add.getLongitude();
    gotoLocation(lat, lng, 9);
  }
  public GeoPoint getPointFromAddr(String strAddr) {
    GeoPoint p = null;

    Geocoder coder = new Geocoder(this);
    List<Address> address;

    try {
      address = coder.getFromLocationName(strAddr, 5);
      if (address == null || address.size() == 0) {
        return null;
      }

      Address loc = address.get(0);
      loc.getLatitude();
      loc.getLongitude();

      p = new GeoPoint((int) (loc.getLatitude() * 1E6), (int) (loc.getLongitude() * 1E6));

    } catch (IOException e) {
      Log.d("geocoding", e.getMessage());
    }
    return p;
  }
  /**
   * Geocode user entered location name.
   *
   * @param String - the location to be geocoded
   * @return int - 0 on success, 1 network failure, 2 couldn't geocode wrong location name
   */
  public int geocodeLocationName(String locationName) {
    if (Util.isConnected(AddIncident.this)) {
      try {
        foundAddresses = gc.getFromLocationName(locationName, 5);
        Address address = foundAddresses.get(0);
        AddIncident.latitude = address.getLatitude();
        AddIncident.longitude = address.getLongitude();

      } catch (IOException e) {
        return 2;
      }
    }
    return 1;
  }
 /**
  * Method to to move map to new address.
  *
  * @param address
  */
 private void moveMap(Address address) {
   if (address != null) {
     CameraPosition newPlace =
         new CameraPosition.Builder()
             .target(new LatLng(address.getLatitude(), address.getLongitude()))
             .zoom(15.5f)
             .bearing(8)
             .tilt(0)
             .build();
     map.animateCamera(CameraUpdateFactory.newCameraPosition(newPlace));
   } else {
     Toast.makeText(context, "Cannot find location.", Toast.LENGTH_LONG).show();
   }
 }
Exemple #14
0
    @Override
    protected void onPostExecute(List<Address> addresses) {

      if (addresses == null || addresses.size() == 0) {
        Toast.makeText(getBaseContext(), "No Location found", Toast.LENGTH_SHORT).show();
        setProgressBarIndeterminateVisibility(false);

        return;
      }

      ViewMapFragment mMapFragment =
          (ViewMapFragment) getSupportFragmentManager().findFragmentByTag("map");

      if (!searchMarkers.isEmpty()) {
        // Clears all the existing markers on the map
        for (Marker m : searchMarkers) {
          m.remove();
        }
        searchMarkers.clear();
      }

      // Adding Markers on Google Map for each matching address
      for (int i = 0; i < addresses.size(); i++) {

        Address address = (Address) addresses.get(i);

        // Creating an instance of GeoPoint, to display in Google Map
        LatLng latLng = new LatLng(address.getLatitude(), address.getLongitude());

        String addressText =
            String.format(
                "%s, %s",
                address.getMaxAddressLineIndex() > 0 ? address.getAddressLine(0) : "",
                address.getCountryName());

        MarkerOptions markerOptions = new MarkerOptions();
        markerOptions.position(latLng);
        markerOptions.title(addressText);
        markerOptions.icon(
            BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN));

        searchMarkers.add(mMapFragment.mMap.addMarker(markerOptions));

        // Locate the first location
        if (i == 0) mMapFragment.mMap.animateCamera(CameraUpdateFactory.newLatLng(latLng));
      }
      querying = false;
      setProgressBarIndeterminateVisibility(false);
    }
  @Override
  protected void onHandleIntent(Intent intent) {
    Location location = intent.getParcelableExtra(AddressLocationActivity.LOCATION);
    int type = intent.getIntExtra(AddressLocationActivity.TYPE, 1);
    String address = intent.getStringExtra(AddressLocationActivity.ADDRESS);

    List<Address> list = new ArrayList<Address>();
    Geocoder geocoder = new Geocoder(this, Locale.getDefault());
    String error = "";
    String resultAddress = "";

    try {
      if (type == 2 || address == null) {
        list =
            (ArrayList<Address>)
                geocoder.getFromLocation(location.getLatitude(), location.getLongitude(), 1);
      } else {
        list = (ArrayList<Address>) geocoder.getFromLocationName(address, 1);
      }
    } catch (IOException e) {
      e.printStackTrace();
      error = "Network problem";
    } catch (IllegalArgumentException e) {
      e.printStackTrace();
      error = "Illegal arguments";
    }

    if (list != null && list.size() > 0) {
      Address a = list.get(0);

      if (type == 2 || address == null) {
        for (int i = 0, tam = a.getMaxAddressLineIndex(); i < tam; i++) {
          resultAddress += a.getAddressLine(i);
          resultAddress += i < tam - 1 ? ", " : "";
        }
      } else {
        resultAddress += a.getLatitude() + "\n";
        resultAddress += a.getLongitude();
      }
    } else {
      resultAddress = error;
    }

    MessageEB m = new MessageEB();
    m.setClassName(AddressLocationActivity.class.getName());
    m.setResultMessage(resultAddress);

    EventBus.getDefault().post(m);
  }
Exemple #16
0
  public LatLng find(View v) {
    e = (EditText) view.findViewById(R.id.editText1);
    String strAddress = e.getText().toString();
    Geocoder coder = new Geocoder(getActivity());
    List<Address> address;

    try {
      address = coder.getFromLocationName(strAddress, 5);
      if (address == null) {
        return null;
      }
      Address location = address.get(0);
      location.getLatitude();
      location.getLongitude();

      p1 = new LatLng(location.getLatitude(), location.getLongitude());

    } catch (Exception ex) {

      ex.printStackTrace();
    }
    e.setText(p1.toString());
    return p1;
  }
  private void getLatitudeLongitudeOfLocation(String locationET) {

    if (Geocoder.isPresent()) {
      try {
        Geocoder gc = new Geocoder(getBaseContext());
        List<Address> addresses =
            gc.getFromLocationName(locationET, 1); // get the found Address Objects
        List<LatLng> ll =
            new ArrayList<LatLng>(
                addresses.size()); // A list to save the coordinates if they are available
        for (Address a : addresses) {
          if (a.hasLatitude() && a.hasLongitude()) {
            ll.add(new LatLng(a.getLatitude(), a.getLongitude()));
            LatitudeOfLocation = a.getLatitude();
            LongitudeOfLocation = a.getLongitude();
          }
        }
      } catch (IOException e) {
        // if there is no place that has Latitude and Longitude, set them to default values
        LatitudeOfLocation = 555.0;
        LongitudeOfLocation = 555.0;
      }
    }
  }
 public double[] getLatLong(String location) {
   Geocoder geocode = new Geocoder(mContext, Locale.getDefault());
   double[] details = new double[2];
   try {
     List<Address> addresses = geocode.getFromLocationName(location, 1);
     if (addresses != null) {
       Address fetchedAddress = addresses.get(0);
       details[0] = fetchedAddress.getLatitude();
       details[1] = fetchedAddress.getLongitude();
     }
   } catch (IOException e) {
     return details;
   }
   return details;
 }
 @Background
 void geocoderTask(Place place) {
   showHideLoading(true);
   try {
     Address addr = GeoUtils.getFromPlace(place);
     showHideLoading(false);
     if (addr == null) {
       return;
     }
     LatLng latLong = new LatLng(addr.getLatitude(), addr.getLongitude());
     updateCamera(latLong);
   } catch (Exception e) {
     Log.e("ZUP", e.getMessage(), e);
     Crashlytics.logException(e);
   }
 }
 /**
  * transfer an address to coordinates
  *
  * @param strAddress the address that need to be transfered
  * @return the transfered coordinates
  */
 public static double[] toLatLong(String strAddress) {
   Geocoder geocoder = new Geocoder(ContextProvider.get(), Locale.getDefault());
   List<Address> addresses;
   double[] returnLatLong = new double[2];
   try {
     addresses = geocoder.getFromLocationName(strAddress, 1);
     if (addresses != null && addresses.size() > 0) {
       Address returnedAddress = addresses.get(0);
       returnLatLong[0] = returnedAddress.getLatitude();
       returnLatLong[1] = returnedAddress.getLongitude();
     }
   } catch (Exception e) {
     return new double[] {0.0, 0.0};
   }
   return returnLatLong;
 }
Exemple #21
0
    @Override
    protected JSONObject doInBackground(Object... params) {
      Address requestAddress = (Address) params[1];

      ClientResource res = new ClientResource(params[0].toString());
      res.setMethod(Method.POST);

      double latitude = 0;
      double longitude = 0;

      // Location returns null if no position is currently available. In this case, cancel the
      // request.
      if (requestAddress == null) {

        JSONObject o = new JSONObject();
        try {
          o.put("ID", -1);
        } catch (JSONException e) {
          e.printStackTrace();
        }
        return o;
      } else {
        latitude = requestAddress.getLatitude();
        longitude = requestAddress.getLongitude();
      }

      int bottomId = 10000; // Indicates that we want the latest.

      int sort = ((Integer) params[2]).intValue();

      JSONObject obj =
          JSONMessage.getPosts(
              bottomId, "", Double.valueOf(latitude), Double.valueOf(longitude), sort);
      StringRepresentation stringRep = new StringRepresentation(obj.toString());

      stringRep.setMediaType(MediaType.APPLICATION_JSON);
      JSONObject o = null;
      try {
        Representation r = res.post(stringRep);
        o = new JSONObject(r.getText());
      } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
      return o;
    }
  public LatLng getCoordenada(String endereco) {
    Geocoder geocoder = new Geocoder(context);
    try {
      List<Address> enderecos = geocoder.getFromLocationName(endereco, 1);
      if (!enderecos.isEmpty()) {
        Address enderecoLocalizado = enderecos.get(0);
        double latitude = enderecoLocalizado.getLatitude();
        double longitude = enderecoLocalizado.getLongitude();

        return new LatLng(latitude, longitude);
      } else {
        return null;
      }
    } catch (IOException e) {
      return null;
    }
  }
 public void a(Address paramAddress)
 {
   getArguments().putParcelable("address", paramAddress);
   if ((paramAddress.hasLatitude()) && (paramAddress.hasLongitude()))
   {
     l();
     a(new LatLng(paramAddress.getLatitude(), paramAddress.getLongitude()));
     return;
   }
   paramAddress = a.b(", ", paramAddress).toString();
   if ((d != null) && (d.u())) {
     d.a(true);
   }
   d = new cd(paramAddress, e);
   d.f(new Void[0]);
   a(d);
 }
  public static void logAddress(String logTag, Address address) {

    int maxAddressLineIndex = address.getMaxAddressLineIndex();
    for (int i = 0; i <= maxAddressLineIndex; i++) {
      String addressLine = address.getAddressLine(i);
      Log.d(logTag, i + ":  " + addressLine);
    }

    double latitude = 0.0d;
    double longitude = 0.0d;

    boolean hasLatitude = address.hasLatitude();
    if (hasLatitude) {
      latitude = address.getLatitude();
    }
    boolean hasLongitude = address.hasLongitude();
    if (hasLongitude) {
      longitude = address.getLongitude();
    }

    String adminArea = address.getAdminArea();
    String featureName = address.getFeatureName();
    String locality = address.getLocality();
    String postalCode = address.getPostalCode();
    String premises = address.getPremises();
    String subAdminArea = address.getSubAdminArea();
    String subLocality = address.getSubLocality();
    String subThoroughfare = address.getSubThoroughfare();
    String thoroughfare = address.getThoroughfare();
    String phone = address.getPhone();
    String url = address.getUrl();

    // logValue(logTag, "latitude", hasLatitude, latitude);
    // logValue(logTag, "longitude", hasLongitude, longitude);
    //        logValue(logTag,"adminArea", adminArea);
    //        logValue(logTag,"featureName", featureName);
    //        logValue(logTag,"locality", locality);
    //        logValue(logTag,"postalCode", postalCode);
    //        logValue(logTag,"premises", premises);
    //        logValue(logTag,"subThoroughfare", subThoroughfare);
    //        logValue(logTag,"subAdminArea",subAdminArea);
    //        logValue(logTag,"subLocality", subLocality);
    //        logValue(logTag,"thoroughfare", thoroughfare);
    //        logValue(logTag,"phone", phone);
    //        logValue(logTag,"url", url);
  }
 protected boolean setLatLongFromPlace(String place) {
   List<Address> addresses = new ArrayList<Address>();
   try {
     addresses = geocoder.getFromLocationName(place, 1);
   } catch (IOException e) {
     Toast.makeText(this, getString(R.string.location_unable_to_geocode), Toast.LENGTH_SHORT)
         .show();
     return false;
   }
   if (addresses.size() == 0) {
     showNotFoundDialog(place);
     return false;
   }
   // TODO(johntaylor) let the user choose, but for now just pick the first.
   Address first = addresses.get(0);
   setLatLong(first.getLatitude(), first.getLongitude());
   return true;
 }
  /**
   * Update the note using the details provided. The note to be updated is specified using the
   * rowId, and it is altered to use the title and body values passed in
   *
   * @param rowId id of note to update
   * @param title value to set note title to
   * @param body value to set note body to
   * @return true if the note was successfully updated, false otherwise
   */
  public boolean updateTrack(long rowId, MusicTrack track, Address a) {
    ContentValues initialValues = new ContentValues();

    Date d = new Date();

    initialValues.put(KEY_DATETIME, d.getTime());
    initialValues.put(KEY_TRACK, track.mTrackName);
    initialValues.put(KEY_ALBUM, track.mAlbumName);
    initialValues.put(KEY_ARTIST, track.mArtistName);
    initialValues.put(KEY_CITY, a.getLocality());
    initialValues.put(KEY_STATE, a.getAdminArea());
    initialValues.put(KEY_COUNTRY, a.getCountryName());
    initialValues.put(KEY_FEATURE, a.getFeatureName());
    initialValues.put(KEY_LON, a.getLongitude());
    initialValues.put(KEY_LAT, a.getLatitude());

    return mDb.update(DATABASE_TABLE, initialValues, KEY_ROWID + "=" + rowId, null) > 0;
  }
  /**
   * Create a new note using the title and body provided. If the note is successfully created return
   * the new rowId for that note, otherwise return a -1 to indicate failure.
   *
   * @param title the title of the note
   * @param body the body of the note
   * @return rowId or -1 if failed
   */
  public long insertTrack(MusicTrack track, Address a) {
    Date d = new Date();

    ContentValues initialValues = new ContentValues();
    initialValues.put(KEY_DATETIME, d.getTime());
    initialValues.put(KEY_TRACK, track.mTrackName);
    initialValues.put(KEY_ALBUM, track.mAlbumName);
    initialValues.put(KEY_ARTIST, track.mArtistName);

    if (a != null) {
      initialValues.put(KEY_CITY, a.getLocality());
      initialValues.put(KEY_STATE, a.getAdminArea());
      initialValues.put(KEY_COUNTRY, a.getCountryName());
      initialValues.put(KEY_FEATURE, a.getFeatureName());
      initialValues.put(KEY_LON, a.getLongitude());
      initialValues.put(KEY_LAT, a.getLatitude());
    }

    return mDb.insert(DATABASE_TABLE, null, initialValues);
  }
  @Override
  public void onClick(View v) {
    String localizacion = edt_buscar.getText().toString();
    List<Address> addressList = null;

    if (!localizacion.equals("")) {
      Geocoder geocoder = new Geocoder(context);
      try {
        addressList = geocoder.getFromLocationName(localizacion, 1);
      } catch (IOException e) {
        e.printStackTrace();
      }
      Address address = addressList.get(0);
      LatLng bus_latLng = new LatLng(address.getLatitude(), address.getLongitude());
      mMap.addMarker(new MarkerOptions().position(bus_latLng).title(address.getAddressLine(0)));

      mMap.animateCamera(CameraUpdateFactory.newLatLng(bus_latLng));
    } else {
      Toast.makeText(context, "No se ingreso ninguna palabra clave", Toast.LENGTH_LONG).show();
    }
  }
 @Background
 void searchTask(String query) {
   showHideLoading(true);
   try {
     Address addr = GeoUtils.search(query, latitude, longitude);
     showHideLoading(false);
     if (addr == null || map == null) {
       return;
     }
     CameraPosition p =
         new CameraPosition.Builder()
             .target(new LatLng(addr.getLatitude(), addr.getLongitude()))
             .zoom(16f)
             .build();
     CameraUpdate update = CameraUpdateFactory.newCameraPosition(p);
     map.animateCamera(update);
   } catch (Exception e) {
     Log.e("ZUP", e.getMessage(), e);
     Crashlytics.logException(e);
   }
 }
  public void onSearch(View view) {

    loca = (EditText) findViewById(R.id.editText);
    String location1 = loca.getText().toString();
    List<Address> addressList = null;
    if (location1 != null && !location1.equals("")) {
      Geocoder geocoder = new Geocoder(this);
      try {
        addressList = geocoder.getFromLocationName(location1, 1);
      } catch (IOException e) {
        e.printStackTrace();
      }
      Address address = addressList.get(0);
      currentAddress = address;
      LatLng latLng = new LatLng(address.getLatitude(), address.getLongitude());

      mMap.addMarker(new MarkerOptions().position(latLng).title("Marker"));
      mMap.animateCamera(CameraUpdateFactory.newLatLng(latLng));
    } else {
      setUpMap();
    }
  }