here is the epsg wiki on the subject.
With other links to esri and openstreetmap discussions.
My understanding is that in the epsg realm the 900913 is deprecated.
(900913 spells google in numeric so it was too cute to be official).
It is now officially 3857 in the epsg database.
and from esri:
ArcGIS Online will be transitioning to WGS 1984 Web Mercator (Auxillary Sphere)
What does this mean for you?
sterlingdq says:
@nnne – For a long time EPSG refused to assign a code to this coordinate system; therefore ESRI created the WKID codes 102113 and 102100.
When EPSG did assign a code, they used 3785, but later changed it to 3857. ArcGIS 10 will follow ESRI practice of using an EPSG code when one exists, and will advertise the coordinate system of the service as 3857. ArcGIS 10 and all Web APIs are being designed to recognize EPSG 3857, ESRI WKID 102113, and ESRI WKID 102100 as equivalent.
Sorry I was stil working on the answer.
WGS 1984 Web Mercator (Auxiliary Sphere) is what you want to select in arcmap but read the what does this mean for you if you are creating tiled services.
I am on 10.1 and this is the definition in it...
and finally the WGS 1984 Web Mercator is just the old esri def pointing to epsg 3785
I suspect the issue relates to the very real difference existing between geometry
objects, existing on a plane map surface, and geography
objects, existing on a curved globe surface.
It is always more accurate (but slower) to do calculations with geography
types on a globe. Projecting features from a globe onto a plane always incurs distortion.
Looking at your SQL code, on the 3rd line you do cast to geography
but for the "incomplete" reasons. You do it to use meters instead of degrees for the distance measure, and that is good. You should also do it because you get more accurate results.
Now, in the 1st line of your SQL code, you make a point out of coordinate parameters, but it is by default a geometry
and so you end up not comparing like with like. Try casting the point you make to geography
and see what happens.
Like this, i think:
ST_SetSRID(ST_MakePoint($1, $2),4326)::geography
If you draw circles using GMaps, they are probably not representing true circles on the globe. If "GMaps" (not sure what you mean, exactly) uses the Web Mercator projection, then a drawn circle really represents an "egg" shape on the globe, with the pointed end up north. That's how the Mercator projection distorts things -- things get hugely stretched as one moves away from the equator.
Best Answer
Although the underlying tiles are projected to epsg:3857, the Maps API accepts Latitude/Longitude pairs in epsg:4326 (vs y/x coordinates in meters, which would be implied by 3857).
Therefore if you want to draw a polygon on the map, you would pass the API latitude/longitude and it will be projected appropriately to match the underlying data (note you may wish to specify geodesic:true in your overlay options in the API)
That said you didn't specify what projection your data in PostGIS is index as, so I can't say whether you need to change anything.