Encoding Latitudes and Longitudes

acme on 2007-06-20T15:58:31

I was browsing the Google Maps API Documentation and noticed this wonderful little feature, where you can encode latitudes and longitudes as strings:

// instead of this:
var polyline = new GPolyline([
    new GLatLng(37.4419, -122.1419),
    new GLatLng(37.4519, -122.1519),
    new GLatLng( 37.4619, -122.1819)
], "#FF0000", 10);
map.addOverlay(polyline);

// you can use:
var encodedPolyline = new GPolyline.fromEncoded({
    color: "#FF0000",
    weight: 10,
    points: "yzocFzynhVq}@n}@o}@nzD",
    levels: "BBB",
    zoomFactor: 32,
    numLevels: 4
});
map.addOverlay(encodedPolyline);

What the? Luckily they explain the encoding madness.