Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Assuming that your map is Google Maps, they use the Mercator projection, so you'd need to use that for the conversion. Under the Mercator projection, the distance that a pixel represents in meters varies with latitude, so while a meter is a very small distance compared to the Earth radius, latitude is important.</p> <p>All the examples below are javascript, so you might need to translate them.</p> <p>Here is a general explanation of the coordinate system:</p> <p><a href="http://code.google.com/apis/maps/documentation/javascript/maptypes.html#WorldCoordinates" rel="nofollow noreferrer">http://code.google.com/apis/maps/documentation/javascript/maptypes.html#WorldCoordinates</a></p> <p>This example contains a MercatorProjection object, which includes the methods fromLatLngToPoint() and fromPointToLatLng():</p> <p><a href="http://code.google.com/apis/maps/documentation/javascript/examples/map-coordinates.html" rel="nofollow noreferrer">http://code.google.com/apis/maps/documentation/javascript/examples/map-coordinates.html</a></p> <p>Once you have converted your (x,y) to (lat,lon), this is how you draw a circle:</p> <pre><code>// Pseudo code var d = radius/6378800; // 6378800 is Earth radius in meters var lat1 = (PI/180)* centerLat; var lng1 = (PI/180)* centerLng; // Go around a circle from 0 to 360 degrees, every 10 degrees for (var a = 0 ; a &lt; 361 ; a+=10 ) { var tc = (PI/180)*a; var y = asin(sin(lat1)*cos(d)+cos(lat1)*sin(d)*cos(tc)); var dlng = atan2(sin(tc)*sin(d)*cos(lat1),cos(d)-sin(lat1)*sin(y)); var x = ((lng1-dlng+PI) % (2*PI)) - PI ; var lat = y*(180/PI); var lon = x*(180/PI); // Convert the lat and lon to pixel (x,y) } </code></pre> <p>These two mashups draw a circle of a given radius on the surface of the Earth:</p> <p><a href="http://maps.forum.nu/gm_sensitive_circle2.html" rel="nofollow noreferrer">http://maps.forum.nu/gm_sensitive_circle2.html</a></p> <p><a href="http://maps.forum.nu/gm_drag_polygon.html" rel="nofollow noreferrer">http://maps.forum.nu/gm_drag_polygon.html</a></p> <p>If you choose to ignore the projection then you'd use cartesian coordinates and simply draw the circle using Pythagoras Theorem:</p> <p><a href="http://en.wikipedia.org/wiki/Circle#Cartesian_coordinates" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/Circle#Cartesian_coordinates</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload