
I've been trying to draw a circle around a POI (lat, lon) using the following code:
private GeometryBase MakeRegularPolygon(double latitude, double longitude, double radius, int sides, Color fillColor, Color lineColor)
{
double resolution = InnerMap.Map.CoordHelper.GetResolutionAtZoomLevel(Map.Map.ZoomLevel, DeepEarth.Unit.Meter);
radius *= (1 / resolution);
Point pixelCenter = InnerMap.Map.CoordHelper.GeoToPixel(new Point(latitude, longitude));
double da = (Math.PI * 2) / sides;
Polygon polygon = new DeepEarth.Geometry.Polygon();
polygon.LineColor = lineColor;
polygon.FillColor = fillColor;
for (int i = 0; i < sides; i++)
{
var pixelOnCircleCoordinate = new Point(pixelCenter.X + (radius * Math.Cos(i * da)), pixelCenter.Y + (radius * Math.Sin(i * da)));
var geoOnCircleCoordinate = InnerMap.Map.CoordHelper.PixelToGeo(pixelOnCircleCoordinate);
polygon.Points.Add(geoOnCircleCoordinate);
CreatePushpin("", geoOnCircleCoordinate.X, geoOnCircleCoordinate.Y);
}
return polygon;
}
The circle itself is drawn just fine. The problem is that the radius is incorrect, I would expect the resolution variable to hold the number of pixels needed to represent one meter at a given zoomlevel. But this seems to be incorrect with a factor near
2. Can anyone tell me how I can retrieve this factor? The relevant code has been marked red.
Thanks in advance!


Developer
Jun 18, 2010 at 1:49 PM

GetResolutionAtZoomLevel(double zoomLevel, Unit unit)
Gets the resolution of a pixel at the "EQUATOR" at the supplied zoom level in the unit provided
maybe try
GetResolutionAtZoomLevel(double zoomLevel, Location geographicPoint, Unit unit)
Gets the resolution of a pixel at the supplied Geographical Point (longitude, latitude) at the supplied zoom level in the unit provided


Developer
Jun 18, 2010 at 1:51 PM

or try
GetResolutionAtZoomLevel(double latitude, double zoomLevel, Unit unit)
the Location geographicPoint
is in the latter versions of DE, if you have a earlier version it just a point in that method

