private void showLocations(Cursor c) { MarkerOptions markerOptions = null; LatLng position = null; mMap.clear(); while (c.moveToNext()) { markerOptions = new MarkerOptions(); position = new LatLng(Double.parseDouble(c.getString(1)), Double.parseDouble(c.getString(2))); // Coordenadas seleccionadas localizacionVO = new WS_LocalizacionVO(); localizacionVO.setLatitudeLoc(position.latitude); localizacionVO.setLongitudeLoc(position.longitude); modifico = true; markerOptions.position(position); markerOptions.title(c.getString(0)); markerSelect = mMap.addMarker(markerOptions); } if (position != null) { CameraUpdate cameraPosition = CameraUpdateFactory.newLatLngZoom(position, 15); mMap.animateCamera(cameraPosition); } }
private void posicionActual(WS_LocalizacionVO localizacionVO) { if (googleApiClient != null && googleApiClient.isConnected()) { if (localizacionVO == null || (localizacionVO.getLatitudeLoc() == 0.0 && localizacionVO.getLongitudeLoc() == 0.0)) { // Posicion Actual localizacionVO = new WS_LocalizacionVO(); Location location = LocationServices.FusedLocationApi.getLastLocation(googleApiClient); if (location != null) { localizacionVO.setLatitudeLoc(location.getLatitude()); localizacionVO.setLongitudeLoc(location.getLongitude()); mMap.animateCamera( CameraUpdateFactory.newLatLngZoom( new LatLng(localizacionVO.getLatitudeLoc(), localizacionVO.getLongitudeLoc()), 15)); } else { final MapaUbicacionActivity mapaActivity = this; final AlertView dialog = new AlertView( this, AlertViewType.AlertViewTypeInfo, getResources().getString(R.string.msgActivarGPS)); dialog.setDelegado( new AlertViewInterface() { @Override public void accionSi() { // TODO Auto-generated method stub } @Override public void accionNo() { // TODO Auto-generated method stub } @Override public void accionAceptar() { // TODO Auto-generated method stub mapaActivity.finish(); } }); dialog.show(); } } else { mMap.animateCamera( CameraUpdateFactory.newLatLngZoom( new LatLng(localizacionVO.getLatitudeLoc(), localizacionVO.getLongitudeLoc()), 15)); String title = ""; /*try{ Geocoder geocoder = new Geocoder(this, Locale.getDefault()); List<Address> addressIn = geocoder. getFromLocation(localizacionVO.getLatitudeLoc(), localizacionVO.getLongitudeLoc(), 1); Address address = addressIn.get(0); title += address.getAddressLine(0) + ", "; title += address.getAddressLine(1) + ", "; title += address.getAddressLine(2); } catch(Exception e){ title = ""; }*/ markerSelect = mMap.addMarker( new MarkerOptions() .title(title) .position( new LatLng( localizacionVO.getLatitudeLoc(), localizacionVO.getLongitudeLoc()))); } } }