android - LatLang value of the physical center in the visible GoogleMap region considering mercator projection -


i want calculate center , radius of circle in middle of screen radius being half of width of visible region.

visibleregion.latlngbounds.getcenter() 

or

cameraposition.target 

values center has offset physical center when zoom out lot.

in following picture calculated black shaded circle follow:

   visibleregion visibleregion = mmap.getprojection().getvisibleregion();    latlng nearleft = visibleregion.nearleft;    latlng nearright = visibleregion.nearright;    mcircle.setcenter(visibleregion.latlngbounds.getcenter());    mcircle.setradius(distancefrom(nearleft.latitude, nearleft.longitude, nearright.latitude, nearright.longitude) / 4);      public double distancefrom(double lat1, double lng1, double lat2, double lng2)     {         // return distance between 2 points, stored 2 pair location;         double dlat = math.toradians(lat2 - lat1);         double dlng = math.toradians(lng2 - lng1);         double = math.sin(dlat / 2) * math.sin(dlat / 2) + math.cos(math.toradians(lat1))                 * math.cos(math.toradians(lat2)) * math.sin(dlng / 2) * math.sin(dlng / 2);         double c = 2 * math.atan2(math.sqrt(a), math.sqrt(1 - a));         double dist = earth_radious * c;         return new double(dist * meter_conversion).floatvalue();     } 

im looking radius , center of green circle.enter image description here

for who's interested solved way: calculate pixel position of center , pixel position of point on circle @ start using goolgemap.getprojection(). camera changes draw circle centered @ pixel position convverting point() latlang , radius equals distance between center point , point on circle in meter.


Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -