Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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]
      }
    };

    myLayer.addData(geojsonFeature);

});

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

share|improve this question
1  
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 at 13:44
    
DRTL. Frank's bro? –  Willy Apr 13 at 14:00
    
awesome, I may use this in class. –  user two seven two three nine May 22 at 0:52
    
koaning.com has the newest blog post now. glad to hear people like it. –  Vincent Warmerdam May 22 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 at 23:51

1 Answer 1

I think you wish to change both the relative latitude and relative longitude of the moveable region such that each relative coordinate now appears to be only distorted as much as is the case for other regions that are at the same new latitude? If so, then @radouxju is incorrect and you’re currently only half way there. One defining characteristic of conformal projections, such as Mercator, is that at any point on the globe/map the linear scale factor is constant in all directions. Thus whatever changes you make to the Y-scale as you move should also be made to the X-scale.

share|improve this answer

Your Answer

 
discard

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.