예제 #1
0
 /**
  * Calculate the position of the blip on the map image.
  *
  * @param Point   $center Point on the image.
  * @param Box     $size   Size of the image.
  * @param integer $zoom   Zoom level of the map.
  *
  * @return Point
  */
 public function calculatePosition(Point $center, Box $size, $zoom)
 {
     $topLeft = new Point($center->getX() - $size->getWidth() / 2, $center->getY() - $size->getHeight() / 2);
     $blipPoint = Geo::calculatePoint($this->latLng, $zoom);
     return new Point($blipPoint->getX() - $topLeft->getX() - $this->imageSize[0] / 2, $blipPoint->getY() - $topLeft->getY() - $this->imageSize[1] / 2);
 }
예제 #2
0
 /**
  * Generate the static map image and add blips to it if any are found
  *
  * @return ImageInterface The resulting image
  *
  * @return void
  */
 public function generate()
 {
     $box = Geo::calculateBox($this->size, $this->centerPoint);
     $this->resultImage = $this->imagine->create($box['base']);
     $jj = 0;
     $xStart = $box['tiles']['start']->getX();
     $xStop = $box['tiles']['stop']->getX();
     $yStart = $box['tiles']['start']->getY();
     $yStop = $box['tiles']['stop']->getY();
     for ($i = $yStart - 1; $i < $yStop; $i++) {
         $ii = 0;
         for ($j = $xStart - 1; $j < $xStop; $j++) {
             $this->addTile($this->tiles->getTile($j, $i), new Point($ii * Geo::TILE_SIZE, $jj * Geo::TILE_SIZE));
             $ii++;
         }
         $jj++;
     }
     $this->loader->run();
     $this->resultImage->crop($box['crop'], $this->size);
     foreach ($this->blips as $blip) {
         $this->drawBlip($blip);
     }
     $this->loader->run();
     return $this->resultImage;
 }