How to Draw a Curved Great Circle line in Google Maps

Peter Rukavina

Someone came up to me in a coffee shop yesterday and told me they had a web application in which they wanted to connect two locations on a Google Map with a line. Not a regular straight line, but rather a curved “great circle” line. I mumbled about various possible approaches to this — setting up a custom tile-server and generating lines on the back end, etc. — only to find that this functionality is already build into the Google Maps API:

var polyOptions = {geodesic:true};
var polyline = new GPolyline([
  new GLatLng(61.1699849, -149.944496),
  new GLatLng(46.2361, -63.13)
  ], "#ff0000", 3, 1, polyOptions);
map.addOverlay(polyline);

Add an overlay like this — the key is the geodesic:true — and you go from straight line to curvy one. This is well-documented in the Google Maps API documentation.

Great Circle Line in Google Maps Screen Shot

Comments

Submitted by oliver on

Permalink

If Google’s so geodesically enlightened, why are they using that archaic projection that portrays Greenland as bigger than Africa?

You mean a "Mercator projection". It's not archaic. It's probably the most common type of projection used in cartography today, there are others of course, but anytime you put a 3D map on a 2D screen there must be some distortion somewhere.

Add new comment

Plain text

  • Allowed HTML tags: <b> <i> <em> <strong> <blockquote> <code> <ul> <ol> <li>
  • Lines and paragraphs break automatically.

About This Blog

Photo of Peter RukavinaI am . I am a writer, letterpress printer, and a curious person.

To learn more about me, read my /nowlook at my bio, listen to audio I’ve posted, read presentations and speeches I’ve written, or get in touch (peter@rukavina.net is the quickest way). 

You can subscribe to an RSS feed of posts, an RSS feed of comments, or a podcast RSS feed that just contains audio posts. You can also receive a daily digests of posts by email.

Search