public function distanceTo(Google_Maps_Location $location, $unit = 'km', Google_Maps_Static $map = null) { if ('pixel' == $unit) { $zoom = $map->getZoom(); $x1 = $this->toPoint()->getX(); $x2 = $location->toPoint()->getX(); $y1 = $this->toPoint()->getY(); $y2 = $location->toPoint()->getY(); $distance = sqrt(pow($x1 - $x2, 2) + pow($y1 - $y2, 2)); if ($map instanceof Google_Maps_Static) { $distance = $distance >> 21 - $zoom; } } return $distance; }
/** * Check if given coordinate or point is inside bounds * * @return boolean */ public function containsLocation(Google_Maps_Location $location) { $retval = false; $coordinate = $location->toCoordinate(); if ($coordinate->getLon() < $this->getMaxLon() && $coordinate->getLon() > $this->getMinLon() && $coordinate->getLat() < $this->getMaxLat() && $coordinate->getLat() > $this->getMinLat()) { $retval = true; } return $retval; }