Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void search(String str) {
- LatLng latLng = null;
- if (str != null && !str.equals("")) {
- String item[] = str.split(";");
- if (item.length == 2) {
- try {
- double lat = Double.parseDouble(item[0]);
- double lng = Double.parseDouble(item[1]);
- latLng = new LatLng(lat, lng);
- } catch (NumberFormatException ignored) {
- }
- } else {
- Geocoder geocoder = new Geocoder(context);
- List<Address> adressList = null;
- try {
- adressList = geocoder.getFromLocationName(str, 1);
- } catch (IOException e) {
- e.printStackTrace();
- }
- if (adressList != null && adressList.size() > 0) {
- Address address = adressList.get(0);
- latLng = new LatLng(address.getLatitude(), address.getLongitude());
- }
- }
- if (latLng != null) {
- mMap.addMarker(new MarkerOptions().position(latLng));
- mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(latLng, 15));
- } else {
- Var.showToast(context, context.getString(R.string.not_found_location) + " " + str);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement