Android Google Maps: How to calculate the distance between the middle of the screen/map and the top of the screen -


i trying calculate distance middle of screen/map(shown) top of screen. have kind of algorithm not sure works properly. getting numbers 6367 , above. here algorithm:

    double radius = 6367.45;     latlngbounds bounds = map.getprojection().getvisibleregion().latlngbounds;      latlng center = bounds.getcenter();     latlng north = bounds.northeast;      // convert lat or lng decimal degrees radians (divide 57.2958)     double centerlat = center.latitude / 57.2958;     double centerlong = center.longitude / 57.2958;     double northlat = north.latitude / 57.2958;     double northlong = north.longitude / 57.2958;      // distance = circle radius center top of screen     // ma not sure if returns true numbers amm real distance     // , call in setoncamerachangelistener on every zoom right?     // yes     boundradius = radius*(math.acos(math.sin(centerlat) * math.sin(northlat) + math.cos(centerlat)*math.cos(northlat)*math.cos(northlong - centerlong))); 

am calculating correctly? if not, doing wrong?

you use distancebetween() (documentation). believe takes curvature of earth consideration.


Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

android - CollapsingToolbarLayout: position the ExpandedText programmatically -

Listeners to visualise results of load test in JMeter -