Following on from this question: Identify what projection this Australian map uses? <- this is the sort of map i want to load in

I need help changing the bits necessary in this example of Lambert Projection in Google Maps to make it work with Australian tiles instead: Lambert equal area azimuthal projection Google Map which apparently uses these formulae: Lambert Conformal Conic Projection -- from Wolfram MathWorld

Here is my attempts so far, changing what i think needs changing, but it must not be enough

  • its a bit confusing for me, im a web developer
  • i will be adding the tiles at a later stage
  • in my version i made it so when you click around it shows the coords, but as you do this the ones it shows are not in australia, so thus my problem
  • in the original demo it centers and loads tiles 001 & 101, in mine it does not
  • in my version i made it try to load all tiles so you can see which ones in the error console

Thanks for your time.

Heres is the original javascript it uses as seen at that site: (you may notice it uses google maps api v2, not the latest v3 available due to its age)

var phi0 = 10*Math.PI/180;
var phi1 = 20*Math.PI/180;
var phi2 = 70*Math.PI/180;
var n = (Math.log(Math.cos(phi1)) - Math.log(Math.cos(phi2)))/
    (-Math.log(Math.tan(phi1/2 + Math.PI/4)) + Math.log(Math.tan(phi2/2 + Math.PI/4)));
var rho0 = (Math.cos(phi1)*Math.pow(Math.tan(phi1/2 + Math.PI/4),n))/
    (n*Math.pow(Math.tan(phi0/2 + Math.PI/4),n));

function ConformalConicLambertProjection() {};
ConformalConicLambertProjection.prototype = new GProjection();
ConformalConicLambertProjection.prototype.fromPixelToLatLng = function(pixel, z) {
    var x1 = (-0.0034375*(Math.pow(2,7 + z) - pixel.x))/Math.pow(2,z);
    var y1 = -0.0017254901960784311*Math.pow(2,1 - z)*
        (pixel.y - 405.68181818181824*Math.pow(2,-1 + z));
    var rho = Math.sqrt(2.143305952697287 + Math.pow(x1,2) - 
        2.9280067982826044*y1 + Math.pow(y1,2));
    var t = Math.asin(x1/rho);
    var lng = 78.17779218926289*t-100;
    var lat = 28.64788975654*(-3.141592653589793 + 
    return new GLatLng(lat, lng);
ConformalConicLambertProjection.prototype.fromLatLngToPixel = function(latLng, z) {
    var t = Math.PI/180*(100 + latLng.lng())*n;
    var rho = (Math.cos(phi1)*Math.pow(Math.tan(phi1/2. + Math.PI/4.),n))/
        (n*Math.pow(Math.tan((Math.PI/180*latLng.lat())/2. + Math.PI/4.),n));
    var x1 = rho*Math.sin(t);
    var y1 = rho0 - rho*Math.cos(t);
    x = Math.round(Math.pow(2,z)*(128 + 290.9090909090909*x1));
    y = Math.round(Math.pow(2,-1 + z)*(405.68181818181824 - 579.5454545454546*y1));
    return new GPoint(x,y);
ConformalConicLambertProjection.prototype.tileCheckRange = function(tileIndex, zoom, bs) {
    if(0 <= tileIndex.x && tileIndex.x < Math.pow(2,zoom) &&
       0 <= tileIndex.y && tileIndex.y < Math.pow(2,zoom-1)) {
         return true;}
    else { return false; };

function load() {
  if (GBrowserIsCompatible()) {

    var lambertTileLayer = new GTileLayer(
        new GCopyrightCollection(), 1, 4);
    lambertTileLayer.getTileUrl = function(tile, zoom) {
        return "Tiles/ConformalConicLambertTile_" + tile.x + "_" + tile.y + "_" + zoom + ".png";
    var lambertMap = new GMapType([lambertTileLayer],
        new ConformalConicLambertProjection(), "ConformalConicLambert",

    var map = new GMap2(document.getElementById("map"), {mapTypes:[lambertMap]});

    // Add the controls
    map.addControl(new GSmallZoomControl());
    map.setCenter(new GLatLng(37.9251,-100), 1);

  } else {
    document.getElementById('map').style.backgroundColor = '#DDDDDD';
    document.getElementById('map').innerHTML = 'Sorry, your browser does not appear to be compatible with Google maps.';
  • 2
    Lambert conformal conic and Lambert equal area azimuthal aren't the same. This code is difficult because there are a lot of hard-coded values. At minimum, you would need to change the setCenter and phi0/phi1/phi2 values. Beyond that, I don't know. Sorry!
    – mkennedy
    Sep 5, 2013 at 17:47
  • can you tell by the code if it is that or not ? as in the description on his page it says: "The Lambert conformal conic projection implemented with the Google Maps API." and the link to the page is titled: "The US depicted using a Lambert conformal conic projection." Sep 6, 2013 at 0:24
  • 2
    Because the lines var x1 = rho*Math.sin(t); var y1 = rho0 - rho*Math.cos(t) clearly implement equations (1) and (2) on the Mathworld site, you can be reasonably confident this is a version of the LCC and not the Lambert equal area azimuthal projection. But I agree with @mkennedy: hard-coding the parameters makes this code almost unreadable and practically unmaintainable. If I had to use it I would start over with the MathWorld equations and make it flexible enough to vary all the parameters.
    – whuber
    Sep 6, 2013 at 1:29
  • yes i did compare this en.wikipedia.org/wiki/Lambert_azimuthal_equal-area_projection and en.wikipedia.org/wiki/Lambert_conformal_conic_projection and the java code above does really only look like the later. im just going to have to go back over it from scratch using either the mathworld / wikipedia formulas. ill leave the question open for now in case any one want to do it for me, i might even open it up for bounty. Sep 6, 2013 at 6:22


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.