Skip to content

Instantly share code, notes, and snippets.

@zmack
Created November 25, 2008 20:48
Show Gist options
  • Save zmack/29082 to your computer and use it in GitHub Desktop.
Save zmack/29082 to your computer and use it in GitHub Desktop.
,previewCenter: function() {
var tile = this.getMostPopulatedTile();
if ( tile == null ) {
return { span: null, coords: null, params: null }
}
var map_projection = this.gmap.getCurrentMapType().getProjection();
var x = tile.x * 256 + 128;
var y = tile.y * 256 + 128;
var center_coords = map_projection.fromPixelToLatLng(new GPoint(x, y), this.gmap.getZoom());
x = tile.x * 256;
y = tile.y * 256;
var top_left = map_projection.fromPixelToLatLng(new GPoint(x, y), this.gmap.getZoom());
x += 256;
y += 256;
var bottom_right = map_projection.fromPixelToLatLng(new GPoint(x, y), this.gmap.getZoom());
var span = { x: Math.abs(bottom_right.x - top_left.x), y: Math.abs(bottom_right.y - top_left.y) }
return {
span: (span.y +"," + span.x),
coords: (center_coords.y + "," + center_coords.x),
params: 'center=' + (span.y + "," + span.x) + '&span=' + (center_coords.y + "," + center_coords.x)
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment