title: Convert lat/lon to pixel coordinate?
body: <p>I'm trying to convert a lat/lon pair to a pixel coordinate. I have found this mercator projection but I don't understand the code. What is the factor,x_adj, y_adj variable?
  When I run the code without those constants my lat/lon pair is not on my map and the x and y pixel coordinate is not what I want.</p>
  
  <pre><code>function get_xy(lat, lng)
  {
  var mapWidth=2058;
  var mapHeight=1746;
  var factor=.404;
  var x_adj=-391;
  var y_adj=37;
  var x = (mapWidth*(180+lng)/360)%mapWidth+(mapWidth/2);
  var latRad = lat*Math.PI/180;
  var mercN = Math.log(Math.tan((Math.PI/4)+(latRad/2)));
  var y = (mapHeight/2)-(mapWidth*mercN/(2*Math.PI));
  return { x: x*factor+x_adj,y: y*factor+y_adj}
  }
  </code></pre>
  
  <p>Source: <a href="http://webdesignerwall.com/tutorials/interactive-world-javascript-map/comment-page-1?replytocom=103225" rel="nofollow noreferrer">http://webdesignerwall.com/tutorials/interactive-world-javascript-map/comment-page-1?replytocom=103225</a></p>
  
  <p>[2] <a href="https://stackoverflow.com/questions/14329691/covert-latitude-longitude-point-to-a-pixels-x-y-on-mercator-projection?rq=1">Covert latitude/longitude point to a pixels (x,y) on mercator projection</a></p>