Skip navigation
[Jongware]-GfBROo
Currently Being Moderated

Fun with Javascript: World Map

Jan 22, 2010 4:02 PM

A fun little script, could be useful if you are in dire need of some clip art -- or just want to see something else than text, text, text: worldmap.js

 

This is a Javascript implementation of a program I had on the hard disc of several consecutive computers, going back to the late '80s. This version was an implementation in C, which in turn was based upon a Pascal program: CARTOG.PAS, accompanying "Mapping the World in Pascal" by Robert Miller and Francis Reddy, BYTE, December 1987, page 329

 

What does it do? It draws a world map. That's all

 

Written for CS4 (it just might work on CS3, but not on older versions). Simply double-click to run -- it ought to do the rest automatically. If you want to see your location from outer space, go to LATITUDE et LONGITUDE de quelques Villes (which was the first comprehensive listing I found; there are lots of others) and see if your hamlet is listed. You can enter coordinates either as positive/negative values, or succeed them with "E" or "W" and "N" or "S". Only decimal notation is supported -- sorry, minutes & seconds was too much work.

 

What does it look like? Well, here's where I live:

 

iamhere.png

 

So now you can wave if you fly over my house!

 

HOW TO USE

Download the script and unzip it somewhere on your hard disc. Put the file "worldmap.js" in your User Scripts Panel -- a fast way to get there is to right-click any script in the Scripts Panel and select "Reveal in Explorer/Finder". If copied to the correct location, it will automatically appear in the Script Panel list. Double-click to run; nothing else is needed.

 

KNOWN BUGS

There is one difficult-to-track-down bug that ruins the view where only a small part of huge, globe spanning Asia should be drawn. If that happens ... try some other coordinates ...

 

TECHNICAL INFO

The original C (slash Pascal) file came with a coordinate file, but that was extremely rough. I thought it would look nicer with a few more decimals of accuracy, so I visited the Natural Earth website and downloaded their coastal outlines set. Being unnaturally cautious, I downloaded their smallest file -- it's still more than 5,000 coordinates. I don't think it's worth to throw in more vectors at this scale (no, I'm not going to write a full browse-zoom-and-draw-map applet). The outline files are binary encoded, so it took some sleuthing to write out the info I needed in ASCII form. No problem at all! (And I suspect the file format is somewhere on that site, but I didn't even bother to check ;-) ). Then I had to manually close all open paths, so ID could fill the objects for me.

Then it came down to getting the vectors on screen, first in a Mercator (plain) projection -- that code is still in the script somewhere --, then in orthogonal projection. The original program only could handle lines, so I had to find a way to draw the solid objects going over the edge (and that's where the large-land-mass bug slipped in). For the rest, it's all maths, maths, maths, with some JS cleverness to make it run at a fair speed.

  • Currently Being Moderated
    Community Member
    Jan 23, 2010 5:25 AM

    Brilliant! Great job, Jongware. I remember the Miller-Reddy cartog.pas, got it from that Byte issue. Played around with it a lot. I'd never have thought I'd play around with it 23 years later.

     

    Peter

    |
    Mark as:
  • Currently Being Moderated
    Community Member
    Jan 23, 2010 5:56 AM

    Very fun JavaScript ! I tweet it. Effectivement, ça change du GREP et du Text.

    And you don't forget New Caledonia.

    |
    Mark as:
  • Currently Being Moderated
    Community Member
    Jan 23, 2010 8:21 AM

    Absolutely fabulous!

     

    Bravo Jongware.

     

    @+

    Marc

    |
    Mark as:
  • Currently Being Moderated
    Community Member
    Jan 24, 2010 1:30 PM

    Very nice, Theun!

     

    My my, you have way too much time on your hands...

     

    Harbs

    |
    Mark as:
  • Currently Being Moderated
    Community Member
    Jan 24, 2010 8:48 PM

    dang, that script is the GUN!

     

    suppose i can now look forward to receiving more artwork with globes drawn in it as  well as marc autret's wordalyser graphics...

     

    seriously, that is top notch stuff! keep it up

     

    colly

    |
    Mark as:
  • Currently Being Moderated
    Community Member
    Jan 26, 2010 3:28 AM

    Teun,

     

    Mind posting the high-res one?

     

    Peter

    |
    Mark as:
  • Currently Being Moderated
    Community Member
    Jan 26, 2010 7:02 AM

    Yes, thanks.

    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)