How To Scale A Mapview From Pixels To Meters
I'm making an Android application which uses Google Maps API, and I want to scale a MapView to X_pixels:X_meters. For example, 5 pixels of the MapView in my screen, 20 meters on re
Solution 1:
Use the following code:
intnPixles=5; //number of pixelsGeoPointg0= mapview.getProjection().fromPixels(0, mapview.getHeight()/2);
GeoPointg1= mapview.getProjection().fromPixels(nPixles, mapview.getHeight()/2);
float[] results = newfloat[1];
Location.distanceBetween(g0.getLatitudeE6()/1E6, g0.getLongitudeE6()/1E6, g1.getLatitudeE6(), g1.getLongitudeE6()/1E6, results);
floatdistanceInMeters= results[0];
This calculates distance in meters for latitude level at screen center. Because earth is spheric distance vary from bottom to the top of screen. This is mostly noticed with low zoom levels.
Regards.
Post a Comment for "How To Scale A Mapview From Pixels To Meters"