I've set up a database which through a textview displays the latitude and longitude of a specific building. There is a "go" button underneath which loads up my mapsActivity. However, I can't seem to get the lat and long to be placed on the map.
Maps Activity
Go to location Method being called
building Activity
As you can see my code is pretty messy trying to get this to work. If anyone could teamview with me it'd be a lot easier to show what i'm trying to do. I feel like i'm close.
Maps Activity
Code
public class MapsActivity extends AppCompatActivity implements OnMapReadyCallback, GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener, LocationListener {
GoogleMap mGoogleMap;
SupportMapFragment mapFrag;
LocationRequest mLocationRequest;
GoogleApiClient mGoogleApiClient;
Location mLastLocation;
Marker mCurrLocationMarker, map1, map2, map3, map4, map5, map6, map7;
ZoomControls zoom;
// public static String TAG1;
// public static String TAG2;
public static String TAG_LAT = "lat";
public static String TAG_LNG = "lng";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
ToggleButton b1 = (ToggleButton) findViewById(R.id.button3);
getSupportActionBar().setTitle("Queen's Building Search");
Intent intent = getIntent();
mapFrag = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
mapFrag.getMapAsync(this);
zoom = (ZoomControls) findViewById(R.id.zcZoom);
zoom.setOnZoomOutClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mGoogleMap.animateCamera(CameraUpdateFactory.zoomOut());
}
});
zoom.setOnZoomInClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mGoogleMap.animateCamera(CameraUpdateFactory.zoomIn());
}
});
Bundle extras = getIntent().getExtras();
if(extras != null){
double value = extras.getDouble("Latitude");
double value1 = extras.getDouble("Longitude");
// TAG_LAT = extras.getString("Latitude");
// TAG_LNG = extras.getString("Longitude");
goToLocation(value, value1);
}Go to location Method being called
Code
public void goToLocation(double lat, double lng) {
LatLng ll = new LatLng(lat, lng);
CameraUpdate update = CameraUpdateFactory.newLatLng(ll);
mGoogleMap.moveCamera(update);
// btnGo();
}building Activity
Code
btnGoLocation.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Double lat = selectedBuilding.getLatitude();
Double lng = selectedBuilding.getLongitude();
Bundle bundle = new Bundle();
// Intent intent = new Intent(BuildingActivity.this, MapsActivity.class);
//Bundle extras = getIntent().getExtras();
Intent intent = new Intent(BuildingActivity.this, MapsActivity.class);
bundle.putDouble(MapsActivity.TAG_LNG,lat);
bundle.putDouble(MapsActivity.TAG_LNG, lng);
// Intent intent = new Intent(getApplicationContext(), MapsActivity.class);
// intent.putExtra("Latitude", +lat);
// intent.putExtra("Longitude", ""+lng);
// intent.putExtra("latitude", lat);
// intent.putExtra("longitude", lng);
intent.putExtras(bundle);
startActivity(intent);
// Double latt=extras.getDouble(lat);
//Double loNg=extras.getDouble(lng)
}
});As you can see my code is pretty messy trying to get this to work. If anyone could teamview with me it'd be a lot easier to show what i'm trying to do. I feel like i'm close.



![[Image: 4f2d8e8a917f4be2a829a0405325e880.png]](https://imgh.us/4f2d8e8a917f4be2a829a0405325e880.png)
