So, you want to get the latitude / longitude coordinates and find out the coordinates of the pixels in your image of this location?
The main class GMap2 provides conversion to / from a pixel on the displayed map and the lat / long coordinate:
Gmap2.fromLatLngToContainerPixel(latlng)
For example:
var gmap2 = new GMap2(document.getElementById("map_canvas")); var geocoder = new GClientGeocoder(); geocoder.getLatLng( "1600 Pennsylvania Avenue NW Washington, DC 20500", function( latlng ) { var pixel_coords = gmap2.fromLatLngToContainerPixel(latlng); window.alert( "The White House is at pixel coordinates (" + pixel_coodrs.x + ", " + pixel_coords.y + ") on the " + "map image shown on this page." ); } );
So, assuming your map image is a screen capture on the Google Map screen, then this will give you the correct pixel coordinate in that image lat / long coordinate.
It’s more difficult if you capture tile images and stitch them together, since the full tile set area will be outside the area of the displayed map.
In this case, you will need to use the left and top values of the top of the image as the offset from the coordinates that gives fromLatLngToContainerPixel (latlng: GLatLng), subtracting the left coordinate from the x coordinate and above the y coordinate. Therefore, if the upper left image is located at (-50, -122) (left, top), and fromLatLngToContainerPixel () indicates that lat / long has a pixel coordinate (150, 320), then on the image stitched together (150 - ( -50), 320 - (-122)), which is (200, 442).
It is also possible that a similar coordinate transformation function GMap2:
GMap2.fromLatLngToDivPixel(latlng:GLatLng)
will provide you with the correct lat / long to pixel translation for the case of stitched tiles - I have not tested this and am not 100% removed from the API documents.
See here: http://code.google.com/apis/maps/documentation/reference.html#GMap2.Methods.Coordinate-Transformations