Thanks all, got it working. I had originally tried the
fromLatLngToPoint(point) method but it didn't work so I moved on.
HOWEVER, it turns out the problem was I was not feeding it points
properly. I was trying to give it pixel coords or tile coords - what
it actually wants are world coords! Like many problems it evolved from
me not understanding the difference between the different coordinate
systems used by the API. So for anyone searching:
Pixel coords = 2^zoomlevel * tile size. This is the true pixel
position on the map. So the center position on a 1024 pixel (e.g. zoom
level 2) map would be (512,512). Origin is at the top left and it is
given as (x,y).
World coords = a value between 0 and 256 for each of x and y. So
basically the pixel position at zoom level 0. So the center position
will be (256,256). Origin is also at the top left and is given as
(x,y).
Tile coords = Math.floor(pixel coords / tile size). These are tile
sized square divisions of the map, and best not used for most purposes
I imagine since you lose the position within the tile. Again the
origin is top left and written as (x,y).
Latitude/Longtitude coords = this will depend on projection, but in a
mercator projection longtidude is: (relative position / 360) - 180 (as
the origin is in the center rather the top left as it is with the
other 3 methods). Latitude is much more complicated, look at mercator
projection on wikipedia for the gudermannian equation. Significantly,
latitude breaks from normal coordinate convention and so its written
as (lat, long).
The problem with the docmentation is its very clear in the tutorial
section:
http://code.google.com/apis/maps/documentation/javascript/maptypes.html#CustomMapTypes
but it isn't at all clear in the API reference section. For example in
the .fromPointToLatLng() method it describes it using the term 'pixel'
- so I assumed it wanted to be fed pixel coordinates, when infact it
wants world coordinates. Stupid mistake on my part but its cost me
about 5 hours of my life.