I am trying to plot a lat long on my screen using a small circle. This is my code:
currLat = 19.12550467;
currLong = 72.86587704;
collCurrLat = 19.1255857;
collCurrLong = 72.8660916;
cPoint c1 = GlobalMercator.LatLonToPixel(currLat,currLong, 16);
cPoint c2 = GlobalMercator.LatLonToPixel(collCurrLat,collCurrLong, 16);
int dist = GlobalMercator.distanceInMeters(c1.cx, c1.cy, c2.cx, c2.cy, 16);
int xcol = (int) ((((MapView)mParent).getWidth()/360.0) * (180 + collCurrLong));
int ycol = (int) ((((MapView)mParent).getHeight()/180.0) * (90 - collCurrLat));
canvas.drawCircle( xcol, ycol,GlobalMercator.meterDitanceToPixels(10,16 ), mSelectionBrush);
The currLat and currLong are the lat/long of the point at the center of my screen (I plotted it using).
int x = ((MapView)mParent).getWidth()/2; int y = ((MapView)mParent).getHeight()/2;
The collCurrLat and collCurrLong are the lat/long of the near by point I need to plot on the map.
I used a method distanceInMeters() using these lat/long values to calculate the distance and it comes to be 21 meters.
But when i got the output using drawCircle in the code above, it seems that the x, y coordinates obtained using collCurrLat/collCurrLat are much farther than 21 meters (i.e. the distance between currLat/currLong and collCurrLat/collCurrLong). Also the value for xcol and ycol appear at the same location irrespective of varying lat long values! This is a rendition of my UI.
Can you please validate whether the approach I have taken to plot the collCurrLat/collCurrLong point is correct.