示例#1
0
$t->diag('->getBoundsContainingCoords Test');
$coord_1 = new GMapCoord(48.7887996681, 2.23631017383);
$coord_2 = new GMapCoord(48.9243326339, 2.44230382617);
$coord_3 = new GMapCoord(48.8, 2.4);
$bounds_12 = GMapBounds::getBoundsContainingCoords(array($coord_1,$coord_2));
$bounds_123 = GMapBounds::getBoundsContainingCoords(array($coord_1,$coord_2,$coord_3));
$t->is($bounds_12->__toString(),'((48.7887996681, 2.23631017383), (48.9243326339, 2.44230382617))', 'The minimal bounds containing the coords is the rectangle containing the two coords');
$t->is($bounds_123->__toString(),'((48.7887996681, 2.23631017383), (48.9243326339, 2.44230382617))', 'The minimal bounds containing the coords is the rectangle containing the three coords');


$t->diag('->getBoundsContainingMarkers Test');
$marker_1 = new GMapMarker(48.7887996681, 2.23631017383);
$marker_2 = new GMapMarker(48.9243326339, 2.44230382617);
$marker_3 = new GMapMarker(48.8, 2.4);
$bounds_12 = GMapBounds::getBoundsContainingMarkers(array($marker_1,$marker_2));
$bounds_123 = GMapBounds::getBoundsContainingMarkers(array($marker_1,$marker_2,$marker_3));
$t->is($bounds_12->__toString(),'((48.7887996681, 2.23631017383), (48.9243326339, 2.44230382617))', 'The minimal bounds containing the markers is the rectangle containing the two markers');
$t->is($bounds_123->__toString(),'((48.7887996681, 2.23631017383), (48.9243326339, 2.44230382617))', 'The minimal bounds containing the markers is the rectangle containing the three markers');


$t->diag('->getBoundsFromCenter Test');
$center_coord = new GMapCoord(48.856536,2.339307);
$zoom = 11;
$bounds = GMapBounds::getBoundsFromCenterAndZoom($center_coord, $zoom, 300, 300);

$t->is($bounds->__toString(),'((48.7887237041, 2.23631017383), (48.9242565582, 2.44230382617))','On a déduit correctement les bounds à partir de la largeur de la carte, le centre et le zoom');

$bounds = GMapBounds::getBoundsFromCenterAndZoom($center_coord, $zoom, 1, 1);
$t->is($bounds->__toString(),'((48.856536, 2.339307), (48.856536, 2.339307))','On a déduit correctement les bounds à partir de la largeur de la carte, le centre et le zoom');

$t->diag('Fin du test');
示例#2
0
 /**
  *
  * calculates the zoom which fits the markers on the map
  *
  * @param integer $margin a scaling factor around the smallest bound
  * @return integer $zoom
  * @author fabriceb
  * @since 2009-05-02
  */
 public function getMarkersFittingZoom($margin = 0, $default_zoom = 14)
 {
   $bounds = GMapBounds::getBoundsContainingMarkers($this->markers, $margin);
   
   return $bounds->getZoom(min($this->getWidth(),$this->getHeight()), $default_zoom);
 }
示例#3
0
 /**
 *
 * @param GMapMarker[] $markers array of MArkers
 * @return GMapCoord
 * @author fabriceb
 * @since 2009-05-02
 *
 **/
 public static function getCenterCoord($markers)
 {
   $bounds = GMapBounds::getBoundsContainingMarkers($markers);
 
   return $bounds->getCenterCoord();
 }