Static Map Polygon Zoom

Topics: Windows Forms
Aug 17, 2011 at 11:32 AM

Hi, I have a circle with a radius of 5 miles around a marker and when i try a static map the circle shrinks like the markers instead of staying at 5 miles around the marker. Can anyone give me any ideas?

Aug 17, 2011 at 11:44 AM


Aug 17, 2011 at 11:50 AM

On the map i have a marker at sw1, around the marker i have a circle with a radius of 5 miles. When i use a static map like on the demo, the 5 miles radius changes according to the zoom level and does not stay at 5 miles? On the demo the polygons shrink when using the static map so this is what is happening to my 5 mile radius. If you need screen shots then i will put a link to some.

Thanks for a quick response.

Aug 17, 2011 at 12:04 PM

"using the static map" ?

Aug 17, 2011 at 12:27 PM

yes, static map. I converted your code into vb and has to modify it a bit but the image at will explain the problem. If you notice the postcodes spread out which they are supposed to but the circle stays the same size instead of enlarging to 5 miles.

Aug 17, 2011 at 12:34 PM

i see, well you have to modify code to adjust size of the circle

Aug 17, 2011 at 12:43 PM
Edited Aug 17, 2011 at 12:44 PM

Hi, thanks again for a quick response. Please bear with me as maps are new to me. So could i clear the layer and add another circle based on the zoom or would i have to modify the exisiting circle in this which is out of the static map form:-


For Each r As GMapPolygon In Main.objects.Polygons

If r.IsVisible Then

Using rp As New GraphicsPath()

For j As Integer = 0 To r.Points.Count - 1

Dim pr = r.Points(j)

Dim px As GPoint = Main.GMapControl1.Projection.FromLatLngToPixel(pr.Lat, pr.Lng, info.Zoom)

px.Offset(padding, padding)

px.Offset(-topLeftPx.X, -topLeftPx.Y)

Dim p2 As GPoint = px


If j = 0 Then

rp.AddLine(p2.X, p2.Y, p2.X, p2.Y)


Dim p As System.Drawing.PointF = rp.GetLastPoint()

rp.AddLine(p.X, p.Y, p2.X, p2.Y)

End If


If rp.PointCount > 0 Then


gfx.FillPath(r.Fill, rp)

gfx.DrawPath(r.Stroke, rp)

End If

End Using

End If


Aug 17, 2011 at 3:14 PM

..well you have to experiment, i haven't done this before on static map

Aug 17, 2011 at 3:25 PM
Edited Aug 17, 2011 at 3:30 PM

Hi, i am experimenting and have came to a conclusion that I have to find out what percentage the map has changed so I can draw a new circle on the graphics (gfx in your demo) I was thinking that if i had the height and width of the original and changed the same to the percentage that that would work. Could you give me a pointer on how the to get the info i need? Pleaseeeeeeeeee, hang on... i've had a thought :-)


Aug 17, 2011 at 3:29 PM

well you can check wpf demo it has circle and distance is calculated based on meters

Aug 17, 2011 at 5:42 PM
Edited Aug 17, 2011 at 5:44 PM

Sorted :-) See for results.

In case anyone is interested the calulation is below. Just draw a new circle on the big image.


zms(1)=1, zms(2)=2, zms(3)=4, zms(4)=8 etc

original_image_width * (zms(zoomlevel_numericupdown-originalzoomlevel_on_map) * 0.935483871)

original_image_height * (zms(zoomlevel_numericupdown-originalzoomlevel_on_map) * 0.935483871)

May not be the best way but at least it's a way :-)