Skip to content

Instantly share code, notes, and snippets.

@igorkulman
Created June 24, 2014 14:18
Show Gist options
  • Save igorkulman/9fa0a229b9c2db57a172 to your computer and use it in GitHub Desktop.
Save igorkulman/9fa0a229b9c2db57a172 to your computer and use it in GitHub Desktop.
public static GeoCoordinate AddMetersToGeoCoordinate(GeoCoordinate current, double metersH, double metersV)
{
return new GeoCoordinate(current.Latitude + (metersH / (111111)), current.Longitude + (metersV / (111111 * Math.Cos(current.Latitude))));
}
public static double MetersToPixels(double meters, double latitude, double zoomLevel)
{
var pixels = meters / (156543.04 * Math.Cos(latitude) / (Math.Pow(2, zoomLevel)));
return Math.Abs(pixels);
}
public static double PixelsToMeters(double pixels, double latitude, double zoomLevel)
{
return pixels * (156543.04 * Math.Cos(latitude) / (Math.Pow(2, zoomLevel)));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment