Thanks bratliff and Barry.
bratliff is there any restrictions on the code you wrote?
I have the following PHP code for determining the zoom level where the
entire area fits:
[code]
class LatLng {
function LatLng($fLat, $fLng) {
$this->lat = $fLat;
$this->lng = $fLng;
}
}
class Point {
function Point($fX, $fY) {
$this->X = $fX;
$this->Y = $fY;
}
}
function LatLngToPoint($latLng, $zoom, $center, $imageSize) {
$point = new Point(0,0);
$center_x = Google_Maps::LonToX($center->lng);
$center_y = Google_Maps::LatToY($center->lat);
$center_offset_x = round($imageSize->X / 2);
$center_offset_y = round($imageSize->Y / 2);
$target_x = Google_Maps::LonToX($latLng->lng);
$delta_x = ($target_x - $center_x) >> (21 - $zoom);
$point->X = $center_offset_x + $delta_x;
$target_y = Google_Maps::LatToY($latLng->lat);
$delta_y = ($target_y - $center_y) >> (21 - $zoom);
$point->Y = $center_offset_y + $delta_y;
return $point;
}
function getZoomLevel($center, $northWest, $southEast, $imageSize) {
$zoom = 20;
$found = false;
while ($zoom >= 1 && !$found) {
$NW = LatLngToPoint($northWest, $zoom, $center, $imageSize);
$SE = LatLngToPoint($southEast, $zoom, $center, $imageSize);
if ($NW->X >= 0 && $NW->Y >= 0 && $SE->X <= 640 && $SE->Y <= 640)
{
$found = true;
} else {
$zoom--;
}
}
if ($zoom == 0) {
echo "Image required greater than entire world\n";
die();
}
return $zoom;
}
[/code]
This requires the Google_Maps class from bratliff.
I hope it helps someone.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Maps API" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/Google-Maps-API?hl=en
-~----------~----~----~----~------~----~------~--~---