1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
| <?php
namespace Luc\StatBundle\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Luc\StatBundle\Entity\Budget;
use Luc\StatBundle\Form\BudgetType;
use Ivory\GoogleMap\Map;
use Ivory\GoogleMap\MapTypeId;
use Ivory\GoogleMap\Controls\ControlPosition;
use Ivory\GoogleMap\Controls\PanControl;
use Ivory\GoogleMap\Overlays\Animation;
use Ivory\GoogleMap\Overlays\Marker;
use Ivory\GoogleMap\Controls\ZoomControl;
use Ivory\GoogleMap\Events\MouseEvent;
use Ivory\GoogleMap\Overlays\InfoWindow;
/**
* Budget controller.
*
* @Route("/budget")
*/
class BudgetController extends Controller
{
/**
* Lists all Budget entities.
*
* @Route("/", name="budget")
* @Method("GET")
* @Template()
*/
public function indexAction()
{
$em = $this->getDoctrine()->getManager();
$entities = $em->getRepository('LucStatBundle:Budget')->findAll();
//
$map = new Map();
$map->setPrefixJavascriptVariable('map_');
$map->setHtmlContainerId('map_canvas');
//$map->setAsync(false);
// Disable the auto zoom flag
$map->setAutoZoom(false);
// Sets the center
$map->setCenter(13.363, 3.009, true);
// Sets the zoom
$map->setMapOption('zoom', 8);
//Set the type
//$map->setMapOption('mapTypeId', 'roadmap');
$map->setStylesheetOption('width', '800px');
//$map->setStylesheetOption('height', '300px');
$map->setLanguage('fr');
// Markers
$marker = new Marker();
// Configure your marker options
//$marker->setPrefixJavascriptVariable('marker_');
$marker->setPosition(13.363, 3.1090, true);
//$marker->setAnimation(Animation::DROP);
//$marker->setAnimation('bounce');
//$marker->setOption('clickable', false);
//$marker->setOption('clickable', true);
//$marker->setOption('flat', true);
/*$marker->setOptions(array(
'clickable' => false,
'flat' => true,
));
*/
//ajouter une fenetre d'info sur le marker
$infoWindow = new InfoWindow();
$infoWindow->setPrefixJavascriptVariable('info_window_');
$infoWindow->setPosition(0, 0, true);
$infoWindow->setPixelOffset(1.1, 2.1, 'px', 'pt');
$infoWindow->setContent('<p>Voici le contenu</p>');
$infoWindow->setOpen(false);
//$infoWindow->setAutoOpen(true);
$infoWindow->setOpenEvent(MouseEvent::CLICK);
$infoWindow->setAutoClose(true);
$infoWindow->setOption('disableAutoPan', true);
$infoWindow->setOption('zIndex', 10);
/*$infoWindow->setOptions(array(
'disableAutoPan' => true,
'zIndex' => 10,
));
*/
//$infoWindow->setOpenEvent('click');
$infoWindow->setOpenEvent('mouseover');
// Add your info window to the marker
$marker->setInfoWindow($infoWindow);
//
// Add your marker to the map
$map->addMarker($marker);
/*
//Add your pan control to the map
$panControl = new PanControl();
$map->setPanControl($panControl);
$map->setPanControl(ControlPosition::TOP_LEFT);
//
$zoomControl = new ZoomControl();
$zoomControl->setControlPosition('top_right');
$map->setZoomControl($zoomControl);
*/
return array(
'entities' => $entities,
'map'=> $map,
);
} |