Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to calculate a given LatLng to the world coordinate .

I know I can use the internal projection of Google maps like this:

var map=new google.maps.Map(...);

But I want the formula to calculate, rather then the result.

share|improve this question
I've clarified the question to indicate that you require the forumla. – Devdatta Tengshe Jul 17 '13 at 3:17
@DevdattaTengshe: Thanks, that's what I want. – giser Jul 17 '13 at 5:34
up vote 3 down vote accepted

Openstreetmap uses the same tile naming as Google Maps. You find a lot of formulas to calculate them here:

share|improve this answer

According to links provided by Andre Joost, I found the translation. And this is the projection for google.maps:

function MProjection() {
MProjection.prototype.fromLatLngToPoint = function(latlng) {
    var x = (latlng.lng() + 180) / 360 * 256;
    var y = ((1 - Math.log(Math.tan( * Math.PI / 180) + 1 / Math.cos( * Math.PI / 180)) / Math.PI) / 2 * Math.pow(2, 0)) * 256;
    return new google.maps.Point(x, y);
MProjection.prototype.fromPointToLatLng = function(point) {
    var lng = point.x / 256 * 360 - 180;
    var n = Math.PI - 2 * Math.PI * point.y / 256;
    var lat = (180 / Math.PI * Math.atan(0.5 * (Math.exp(n) - Math.exp(-n))));
    return new google.maps.LatLng(lat, lng);

The 256 means the tileSize.

share|improve this answer

Google maps use Mercator Projection (EPSG:3857). The formulas for the projection are:

enter image description here

where lambda is longitude, phi is latitude. Lambda0 is a constant you have to find out (possibly 0 or +-180 equivalent or something (you can figure out easily). Source:

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.