Getting latitude and longitude from latlng object in android
This can easily be found in the Google Maps API reference:
public final class LatLng
public final double latitude
Latitude, in degrees. This value is in the range [-90, 90].
public final double longitude
Longitude, in degrees. This value is in the range [-180, 180).
So in your example you should call:
double lat = latlng.latitude;double lng = latlng.longitude;
var res = results1[key][key1].toString().split("(");console.log(" latlong::"+res);var res2= res[1].split(",");console.log(" latlong::"+res2);latlongFrom[0]=res2[0];console.log(" latlong::"+latlongFrom[0]);var res3=res2[1].split(")");console.log(" latlong::"+res3[0]);latlongFrom[1]=res3[0];console.log(" latlong::"+latlongFrom[1]);
This is what I have done.The res contains the value of (lat,long).
To get Latitude and Longitude your have to declare 2 double variables.
map.setOnMapClickListener(new OnMapClickListener() { @Override public void onMapClick(LatLng latln) { double latitude, longitude; latitude(latln.latitude); longitude(latln.longitude); }});