Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/richardzcode/worldmap.js
Draw world map on canvas
https://github.com/richardzcode/worldmap.js
Last synced: about 2 months ago
JSON representation
Draw world map on canvas
- Host: GitHub
- URL: https://github.com/richardzcode/worldmap.js
- Owner: richardzcode
- Created: 2012-07-30T22:12:35.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2012-08-09T01:33:54.000Z (over 12 years ago)
- Last Synced: 2024-04-14T09:14:22.940Z (10 months ago)
- Language: JavaScript
- Size: 191 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
worldMap.js
===========Draw world map on canvas
##Inroduction
Spent quite some time searching on web on converting latitude/longitude to pixel. Pretty common question I thought. Amazingly, no simple answer. Everybody wanted to write either a academic paper, or a gmap tutorial.
WTF, I just wanted to draw a small world map and plot some stuff on top! What projection? Well, the one that commonly used by 3rd party ip to lat/lon translation.
Until somebody mentioned, for small size map, lat/lon are quite linear...
So, here is the magic formula:
var x = ((lng / 360) + 0.5) * width;
var y = (1 - ((lat / 180) + 0.5)) * height;Then get lands shapfile from [Natural Earth](http://www.naturalearthdata.com/). Extract out lat/lon by using [shpdump](http://shapelib.maptools.org/shapelib-tools.html#shpdump). We got a map.
##Screenshot
![demo](https://github.com/richardzcode/worldMap.js/blob/master/worldMapDemo.png?raw=true)