コード例 #1
0
 /**
  * Checks the render method
  */
 public function testRender()
 {
     $mapTest = new Map();
     $boundTest = new Bound();
     $boundTest->setSouthWest(new Coordinate(-1.1, -2.1, true));
     $boundTest->setNorthEast(new Coordinate(1.1, 2.1, true));
     $groundOverlayTest = new GroundOverlay();
     $groundOverlayTest->setUrl('url');
     $groundOverlayTest->setBound($boundTest);
     $this->assertEquals(self::$groundOverlayHelper->render($groundOverlayTest, $mapTest), 'var ' . $groundOverlayTest->getBound()->getJavascriptVariable() . ' = new google.maps.LatLngBounds(new google.maps.LatLng(-1.1, -2.1, true), new google.maps.LatLng(1.1, 2.1, true));' . PHP_EOL . 'var ' . $groundOverlayTest->getJavascriptVariable() . ' = new google.maps.GroundOverlay("' . $groundOverlayTest->getUrl() . '", ' . $groundOverlayTest->getBound()->getJavascriptVariable() . ', {"map":' . $mapTest->getJavascriptVariable() . '});' . PHP_EOL);
     $groundOverlayTest->setOptions(array('option1' => 'value1', 'option2' => 'value2'));
     $this->assertEquals(self::$groundOverlayHelper->render($groundOverlayTest, $mapTest), 'var ' . $groundOverlayTest->getBound()->getJavascriptVariable() . ' = new google.maps.LatLngBounds(new google.maps.LatLng(-1.1, -2.1, true), new google.maps.LatLng(1.1, 2.1, true));' . PHP_EOL . 'var ' . $groundOverlayTest->getJavascriptVariable() . ' = new google.maps.GroundOverlay("' . $groundOverlayTest->getUrl() . '", ' . $groundOverlayTest->getBound()->getJavascriptVariable() . ', {"map":' . $mapTest->getJavascriptVariable() . ',"option1":"value1","option2":"value2"});' . PHP_EOL);
 }
コード例 #2
0
 /**
  * Renders the map javascript ground overlay
  *
  * @param Ivory\GoogleMapBundle\Model\Overlays\GroundOverlay $groundOverlay
  * @param Ivory\GoogleMapBundle\Model\Map $map
  * @return string HTML output
  */
 public function render(GroundOverlay $groundOverlay, Map $map)
 {
     $groundOverlayOptions = $groundOverlay->getOptions();
     $groundOverlayJSONOptions = sprintf('{"map":%s', $map->getJavascriptVariable());
     if (!empty($groundOverlayOptions)) {
         $groundOverlayJSONOptions .= ',' . substr(json_encode($groundOverlayOptions), 1);
     } else {
         $groundOverlayJSONOptions .= '}';
     }
     $html = array();
     $html[] = $this->boundHelper->render($groundOverlay->getBound());
     $html[] = sprintf('var %s = new google.maps.GroundOverlay("%s", %s, %s);' . PHP_EOL, $groundOverlay->getJavascriptVariable(), $groundOverlay->getUrl(), $groundOverlay->getBound()->getJavascriptVariable(), $groundOverlayJSONOptions);
     return implode('', $html);
 }
コード例 #3
0
 /**
  * Checks the render ground overlays method
  */
 public function testRenderGroundOverlays()
 {
     $mapTest = new Model\Map();
     $groundOverlayTest = new Overlays\GroundOverlay();
     $groundOverlayTest->setUrl('url');
     $groundOverlayTest->setBound(new Base\Coordinate(-1.1, -2.1, true), new Base\Coordinate(1.1, 2.1, true));
     $mapTest->addGroundOverlay($groundOverlayTest);
     $this->assertEquals(self::$mapHelper->renderGroundOverlays($mapTest), 'var ' . $groundOverlayTest->getBound()->getJavascriptVariable() . ' = new google.maps.LatLngBounds(new google.maps.LatLng(-1.1, -2.1, true), new google.maps.LatLng(1.1, 2.1, true));' . PHP_EOL . 'var ' . $groundOverlayTest->getJavascriptVariable() . ' = new google.maps.GroundOverlay("url", ' . $groundOverlayTest->getBound()->getJavascriptVariable() . ', {"map":' . $mapTest->getJavascriptVariable() . '});' . PHP_EOL);
 }