# Mercator bias plot in Leaflet

I was inspired by this wikipedia image from the mercator projections page to hack around with leaflet. The idea was to interactively have your cursor move a continent and that it would be corrected for the projection.

See the following JSFiddle for the status sofar;

http://jsfiddle.net/cantdutchthis/NrAEL/1/

I am a bit new in the projections world and although the demo works well enough for the latitude. When I compare the equirectangular and the mercator projection on wikipedia I get the impression that the projection's bias is only on the 'y-axis' when you compare these two projections.

I get the impression that I am not correcting for the longitude due to the first wikipedia picture. I would like to support this but I don't know what the best way to do this is.

Currently the way I am able to show the bias of the mercator projection is by shifting the coordinates to the mousecursor everytime the mouse moves;

map.on("mousemove", function(d){
Object.keys(myLayer._layers).map(function(d){ myLayer.removeLayer( myLayer._layers[d] ) })

var plotCoords = [];

// green is the coordinate array for the landmass
var green = [ [-46.76373672, 82.62796021],... ]

for ( i in green ) {
// shift the landmass to where the cursor is
var x = d.latlng.lng + green[i][0] + 40
var y = d.latlng.lat + green[i][1] - 80
circleCoords.push( [ x,y ] );
}

window.coords = plotCoords

window.geojsonFeature = {
"type": "Feature",
"properties": {},
"geometry": {
"type": "Polygon",
"coordinates": [coords]
}
};

});

What would be the best way to have this interactive leaflet plot also show the effect as shown on wikipedia.

-- Edit!

For more examples see my blog; http://koaning.com

• Nice idea ! It seems to be correct. With Mercator, the spacing between meridian is preserved wherever you are, so your relative longitudinal extent should not change when you move your polygon. – radouxju Jan 24 '14 at 13:44
• DRTL. Frank's bro? – Willy Apr 13 '14 at 14:00
• awesome, I may use this in class. – If you do not know- just GIS May 22 '14 at 0:52
• koaning.com has the newest blog post now. glad to hear people like it. – Vincent Warmerdam May 22 '14 at 6:11
• What exactly do you mean by “corrected for the projection”? Also, what is the purpose of the code? It doesn't seem to add anything to the question. – Martin F Jun 7 '14 at 23:51