/**
  * Renders the info window open flag.
  *
  * @param \Ivory\GoogleMap\Overlays\InfoWindow $infoWindow The info window.
  * @param \Ivory\GoogleMap\Map                 $map        The map.
  * @param \Ivory\GoogleMap\Overlays\Marker     $marker     The marker.
  *
  * @return string The JS output.
  */
 public function renderOpen(InfoWindow $infoWindow, Map $map, Marker $marker = null)
 {
     if ($marker !== null) {
         return sprintf('%s.open(%s, %s);' . PHP_EOL, $infoWindow->getJavascriptVariable(), $map->getJavascriptVariable(), $marker->getJavascriptVariable());
     }
     return sprintf('%s.open(%s);' . PHP_EOL, $infoWindow->getJavascriptVariable(), $map->getJavascriptVariable());
 }
Beispiel #2
0
 public function __construct(\Ivory\GoogleMap\Map $map, array $center)
 {
     $map->setCenter($center[0], $center[1], true);
     $map->setMapOption('zoom', 14);
     $map->setStylesheetOptions(array('width' => '100%', 'height' => '100%'));
     $this->map = $map;
 }
 /**
  * @inheritdoc
  */
 public function renderAfter(Map $map)
 {
     // Obtengo todos los marcadores del mapa
     $markers = $map->getMarkers();
     $mapVar = $map->getJavaScriptVariable();
     $polylines = $map->getPolylines();
     $polyVars = array();
     // Obtengo las variables (String) de cada uno de los marcadores y se almacenan en un array.
     $variables = array();
     foreach ($markers as $mark) {
         $variable = $mark->getJavaScriptVariable();
         array_push($variables, $variable);
     }
     // Obtengo las variables de las polylines.
     foreach ($polylines as $polyline) {
         array_push($polyVars, $polyline->getJavaScriptVariable());
     }
     // Guardo las variables en String $ret, para ser el retorno del metodo
     $ret = 'markers = new Array(); map = ' . $mapVar . ';' . ' polylines = new Array();';
     $i = 0;
     foreach ($variables as $variable) {
         $ret = $ret . 'markers[' . $i . '] = ' . $variable . ';' . PHP_EOL;
         $i++;
     }
     $i = 0;
     foreach ($polyVars as $polyline) {
         $ret = $ret . 'polylines[' . $i . '] = ' . $polyline . ';' . PHP_EOL;
     }
     return $ret;
 }
    /**
     * {@inheritdoc}
     */
    public function renderAfter(Map $map)
    {
        // Here, we can render js code just after the generated one.
        return '
                    var mapVariable = ' . $map->getJavascriptVariable() . ';
                    var geocoder;
                    var marker;
                    function initialize() {
                        if (mapVariable.addMarker === true){
                            geocoder = new google.maps.Geocoder();
                            google.maps.event.addListener(mapVariable, "click", function(event) {
                                placeMarker(event.latLng);
                            });
                        }
                    }
                    function placeMarker(location) {
                        if (marker == null){
                            marker = new google.maps.Marker({
                                position: location,
                                map: mapVariable,
                                markerID: 0
                            });
                            google.maps.event.addListener(marker, "click", markerClickEventListener);
                            marker.info = new google.maps.InfoWindow({
                                content: "<br>"
                            });
                            geocodePosition(marker.getPosition());
                            google.maps.event.addListener(marker, "click", function() {
                                marker.info.open(mapVariable, marker);
                            });
                        }else{
                            marker.setPosition(location);
                            geocodePosition(marker.getPosition());
                        }
                    }

                    function geocodePosition(pos) {
                        geocoder.geocode({
                            latLng: pos
                        }, function(responses) {
                            if (responses && responses.length > 0) {
                                var address = responses[0].address_components[1].long_name + " " +
                                              responses[0].address_components[0].long_name + ", " +
                                              responses[0].address_components[2].long_name;
                                updateMarkerAddress(address);
                            } else {
                                updateMarkerAddress("Cannot determine address at this location.");
                            }
                        });
                    }

                    function updateMarkerAddress(str) {
                        var contentText = str + "<br>";
                        marker.markerAddress = str;
                        marker.info.setContent(contentText);
                        new google.maps.event.trigger( marker, "click");
                    }
                    initialize();' . PHP_EOL;
    }
 /**
  * Renders a polygon.
  *
  * @param \Ivory\GoogleMap\Overlays\Polygon $polygon The polygon.
  * @param \Ivory\GoogleMapl\Map             $map     The map.
  *
  * @return string Ths JS output.
  */
 public function render(Polygon $polygon, Map $map)
 {
     $this->jsonBuilder->reset()->setValue('[map]', $map->getJavascriptVariable(), false)->setValue('[paths]', array());
     foreach ($polygon->getCoordinates() as $index => $coordinate) {
         $this->jsonBuilder->setValue(sprintf('[paths][%d]', $index), $coordinate->getJavascriptVariable(), false);
     }
     $this->jsonBuilder->setValues($polygon->getOptions());
     return sprintf('%s = new google.maps.Polygon(%s);' . PHP_EOL, $polygon->getJavascriptVariable(), $this->jsonBuilder->build());
 }
 public function testPrePersistWithAutozoom()
 {
     $this->map->setCenter(-1.1, -2.2);
     $this->map->setBound(1, 2, 3, 4);
     $this->map->setAutoZoom(true);
     $this->map->prePersist();
     $this->assertNull($this->map->getCenter());
     $this->assertSame(1, $this->map->getBound()->getSouthWest()->getLatitude());
     $this->assertSame(2, $this->map->getBound()->getSouthWest()->getLongitude());
     $this->assertSame(3, $this->map->getBound()->getNorthEast()->getLatitude());
     $this->assertSame(4, $this->map->getBound()->getNorthEast()->getLongitude());
 }
 public function testRenderMarkersWithAutoOpenInfoWindow()
 {
     $map = new Map();
     $map->setJavascriptVariable('map');
     $map->addMarker($marker = new Marker());
     $marker->setJavascriptVariable('marker');
     $marker->getPosition()->setJavascriptVariable('marker_position');
     $marker->setInfoWindow($infoWindow = new InfoWindow());
     $infoWindow->setJavascriptVariable('marker_info_window');
     $infoWindow->setAutoOpen(true);
     $this->helper->renderMarkers($map->getMarkerCluster(), $map);
     $this->assertNotEmpty($map->getEventManager()->getEvents());
 }
    public function testRenderMarkers()
    {
        $map = new Map();
        $map->setJavascriptVariable('map');
        $map->addMarker($marker = new Marker());
        $marker->setJavascriptVariable('marker');
        $marker->getPosition()->setJavascriptVariable('marker_position');
        $expected = <<<EOF
map_container.markers.marker = marker = new google.maps.Marker({"position":marker_position});

EOF;
        $this->assertSame($expected, $this->helper->renderMarkers($map->getMarkerCluster(), $map));
    }
 /**
  * Renders a marker.
  *
  * @param Ivory\GoogleMap\Overlays\Marker $marker The marker.
  * @param Ivory\GoogleMap\Map             $map    The map.
  *
  * @return string The JS output.
  */
 public function render(Marker $marker, Map $map = null)
 {
     $this->jsonBuilder->reset()->setValue('[position]', $marker->getPosition()->getJavascriptVariable(), false);
     if ($map !== null) {
         $this->jsonBuilder->setValue('[map]', $map->getJavascriptVariable(), false);
     }
     if ($marker->hasAnimation()) {
         $this->jsonBuilder->setValue('[animation]', $this->animationHelper->render($marker->getAnimation()), false);
     }
     if ($marker->hasIcon()) {
         $this->jsonBuilder->setValue('[icon]', $marker->getIcon()->getJavascriptVariable(), false);
     }
     if ($marker->hasShadow()) {
         $this->jsonBuilder->setValue('[shadow]', $marker->getShadow()->getJavascriptVariable(), false);
     }
     if ($marker->hasShape()) {
         $this->jsonBuilder->setValue('[shape]', $marker->getShape()->getJavascriptVariable(), false);
     }
     $this->jsonBuilder->setValues($marker->getOptions());
     return sprintf('%s = new google.maps.Marker(%s);' . PHP_EOL, $marker->getJavascriptVariable(), $this->jsonBuilder->build());
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     //
     $map = new Map();
     $mapHelper = new MapHelper();
     $geocoder = new Geocoder();
     $geocoder->registerProviders(array(new GeocoderProvider(new CurlHttpAdapter())));
     $response = $geocoder->geocode('23 Lapu-lapu Street, Agdao, Davao City, Philippines 8000');
     foreach ($response->getResults() as $result) {
         $marker = new Marker();
         $marker->setPosition($result->getGeometry()->getLocation());
         $map->setCenter($result->getGeometry()->getLocation());
         $map->addMarker($marker);
     }
     $map->setStylesheetOptions(array('width' => '100%', 'height' => '300px'));
     $map->setMapOption('zoom', 15);
     $map->setAsync(true);
     $data['map'] = $mapHelper->render($map);
     return view('pages.contact.index')->with(['data' => $data]);
 }
 /**
  * Provides map for specified Track
  * @param Track $track
  * @throws \Ivory\GoogleMap\Exception\DirectionsException
  * @throws \Ivory\GoogleMap\Exception\MapException
  * @return Map
  */
 public function getMap($track)
 {
     $directionsRequest = new DirectionsRequest();
     $directionsRequest->setOrigin($track->getStartLatitude(), $track->getStartLongitude());
     $directionsRequest->setDestination($track->getEndLatitude(), $track->getEndLongitude());
     $directionsRequest->setTravelMode(TravelMode::DRIVING);
     $directions = new Directions(new CurlHttpAdapter());
     $response = $directions->route($directionsRequest);
     $map = new Map();
     $map->setCenter((double) ($track->getStartLatitude() + $track->getEndLatitude()) / 2, (double) ($track->getStartLongitude() + $track->getEndLongitude()) / 2);
     $map->setAutoZoom(false);
     $map->setMapOption('zoom', 14);
     $map->setMapOption('mapTypeId', MapTypeId::SATELLITE);
     $map->setMapOption('disableDefaultUI', true);
     $map->setMapOption('draggable', false);
     $map->setMapOption('scrollwheel', false);
     $map->setStylesheetOptions(array('width' => '100%', 'height' => '300px'));
     foreach ($response->getRoutes() as $route) {
         $overviewPolyline = $route->getOverviewPolyline();
         $map->addEncodedPolyline($overviewPolyline);
     }
     return $map;
 }
 /**
  * {@inheritdoc}
  */
 public function renderAfter(Map $map)
 {
     if ($map->isAsync()) {
         return '}' . PHP_EOL . $this->renderLibrary($this->source, $this->callback);
     }
 }
Beispiel #13
0
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It is a breeze. Simply tell Lumen the URIs it should respond to
| and give it the Closure to call when that URI is requested.
|
*/
use Ivory\GoogleMap\Map;
use Ivory\GoogleMap\MapTypeId;
$app->get('/', function () use($app) {
    return $app->version();
});
$app->get('map', function () use($app) {
    $map = new Map();
    $map->setPrefixJavascriptVariable('map_');
    $map->setHtmlContainerId('map_canvas');
    $map->setAsync(false);
    $map->setAutoZoom(false);
    $map->setCenter(0, 0, true);
    $map->setMapOption('zoom', 3);
    $map->setBound(-2.1, -3.9, 2.6, 1.4, true, true);
    $map->setMapOption('mapTypeId', MapTypeId::ROADMAP);
    $map->setMapOption('mapTypeId', 'roadmap');
    $map->setMapOption('disableDefaultUI', true);
    $map->setMapOption('disableDoubleClickZoom', true);
    $map->setMapOptions(array('disableDefaultUI' => true, 'disableDoubleClickZoom' => true));
    $map->setStylesheetOption('width', '300px');
    $map->setStylesheetOption('height', '300px');
    $map->setStylesheetOptions(array('width' => '300px', 'height' => '300px'));
Beispiel #14
0
 public function testLanguage()
 {
     $this->map->setLanguage('fr');
     $this->assertSame('fr', $this->map->getLanguage());
 }
Beispiel #15
0
 /**
  * Create empty map
  *
  * @param Coordinate $center
  * @param bool       $async
  *
  * @return Map
  * @throws \Ivory\GoogleMap\Exception\AssetException
  * @throws \Ivory\GoogleMap\Exception\MapException
  */
 public function createEmptyMap(Coordinate $center, bool $async = true) : Map
 {
     $map = new Map();
     $map->setLanguage('en');
     $map->setPrefixJavascriptVariable('map_');
     $map->setHtmlContainerId('map_canvas');
     $map->setMapOption('mapTypeId', MapTypeId::ROADMAP);
     $map->setAutoZoom(false);
     $map->setCenter($center);
     $map->setMapOption('zoom', 2);
     $map->setJavascriptVariable('location_map');
     $map->setAsync($async);
     $map->setStylesheetOptions(['width' => '100%', 'height' => '300px']);
     return $map;
 }
 /**
  * {@inheritdoc}
  */
 public function render(MarkerCluster $markerCluster, Map $map)
 {
     $this->jsonBuilder->reset()->setValues($markerCluster->getOptions());
     return sprintf('%s = new MarkerClusterer(%s, %s, %s);' . PHP_EOL, $markerCluster->getJavascriptVariable(), $map->getJavascriptVariable(), sprintf('%s.functions.to_array(%s.markers)', $this->getJsContainerName($map), $this->getJsContainerName($map)), $this->jsonBuilder->build());
 }
 /**
  * Renders a ground overlay.
  *
  * @param \Ivory\GoogleMap\Overlays\GroundOverlay $groundOverlay The ground overlay.
  * @param \Ivory\GoogleMap\Map                    $map           The map.
  *
  * @return string The JS output.
  */
 public function render(GroundOverlay $groundOverlay, Map $map)
 {
     $this->jsonBuilder->reset()->setValue('[map]', $map->getJavascriptVariable(), false)->setValues($groundOverlay->getOptions());
     return sprintf('%s = new google.maps.GroundOverlay("%s", %s, %s);' . PHP_EOL, $groundOverlay->getJavascriptVariable(), $groundOverlay->getUrl(), $groundOverlay->getBound()->getJavascriptVariable(), $this->jsonBuilder->build());
 }
 /**
  * Renders a circle.
  *
  * @param \Ivory\GoogleMap\Overlays\Circle $circle The circle.
  * @param \Ivory\GoogleMap\Map             $map    The map.
  *
  * @return string The JS output.
  */
 public function render(Circle $circle, Map $map)
 {
     $this->jsonBuilder->reset()->setValue('[map]', $map->getJavascriptVariable(), false)->setValue('[center]', $circle->getCenter()->getJavascriptVariable(), false)->setValue('[radius]', $circle->getRadius())->setValues($circle->getOptions());
     return sprintf('%s = new google.maps.Circle(%s);' . PHP_EOL, $circle->getJavascriptVariable(), $this->jsonBuilder->build());
 }
Beispiel #19
0
 /**
  * Renders a map control in the json builder.
  *
  * @param \Ivory\GoogleMap\Map $map           The map.
  * @param string               $controlName   The control name.
  * @param mixed                $controlHelper The control helper.
  */
 protected function renderMapControl(Map $map, $controlName, $controlHelper)
 {
     $lcFirstControlName = lcfirst($controlName);
     if (!$map->hasMapOption($lcFirstControlName)) {
         return;
     }
     $this->jsonBuilder->setValue(sprintf('[%s]', $lcFirstControlName), (bool) $map->getMapOption($lcFirstControlName));
     if ($map->getMapOption($lcFirstControlName)) {
         $hasControlMethod = 'has' . $controlName;
         if ($map->{$hasControlMethod}()) {
             $getControlMethod = 'get' . $controlName;
             $this->jsonBuilder->setValue(sprintf('[%sOptions]', $lcFirstControlName), $controlHelper->render($map->{$getControlMethod}()), false);
         }
     }
     $map->removeMapOption($lcFirstControlName);
 }
 /**
  * Gets the libraries needed for the map.
  *
  * @param \Ivory\GoogleMap\Map $map The map.
  *
  * @return array The map libraries.
  */
 protected function getLibraries(Map $map)
 {
     $libraries = $map->getLibraries();
     $encodedPolylines = $map->getEncodedPolylines();
     if (!empty($encodedPolylines)) {
         $libraries[] = 'geometry';
     }
     return array_unique($libraries);
 }
Beispiel #21
0
 public function generateAction($address, $info_bulle = '', $width = '100%', $height = '100%')
 {
     $geocoder = new \Geocoder\Geocoder();
     $adapter = new \Geocoder\HttpAdapter\CurlHttpAdapter();
     $chain = new \Geocoder\Provider\ChainProvider(array(new \Geocoder\Provider\FreeGeoIpProvider($adapter), new \Geocoder\Provider\HostIpProvider($adapter), new \Geocoder\Provider\GoogleMapsProvider($adapter, 'fr_FR', 'France', true), new \Geocoder\Provider\BingMapsProvider($adapter, 'AIzaSyBZ3sNuoMPrXGCNbhnEbGmfzGxOohhEX4E')));
     $geocoder->registerProvider($chain);
     $address = urldecode($address);
     $info_bulle = urldecode($info_bulle);
     // Récupération des coordonnées du programme
     try {
         $coordonnees = $geocoder->geocode($address);
     } catch (ChainNoResultException $e) {
         try {
             $coordonnees = $geocoder->geocode('France');
         } catch (ChainNoResultException $e) {
             return false;
         }
     }
     $info_content = '<div style="min-width:150px;text-align:center;">' . $info_bulle . '</div>';
     $info_window = new InfoWindow();
     $info_window->setAutoOpen(true);
     $info_window->setOpen(true);
     $info_window->setContent($info_content);
     $marker = new Marker();
     $marker->setPosition($coordonnees->getLatitude(), $coordonnees->getLongitude(), true);
     $marker->setAnimation('drop');
     $marker->setOption('clickable', true);
     $marker->setOption('flat', true);
     if ($info_bulle) {
         $marker->setInfoWindow($info_window);
     }
     // Création de la map
     $map = new Map();
     $map->setPrefixJavascriptVariable('map_');
     $map->setHtmlContainerId('map_canvas');
     $map->setAsync(true);
     $map->setAutoZoom(false);
     $map->setCenter($coordonnees->getLatitude(), $coordonnees->getLongitude(), true);
     $map->setMapOption('zoom', 12);
     $map->setMapOption('mapTypeId', MapTypeId::ROADMAP);
     $map->setMapOption('disableDefaultUI', false);
     $map->setMapOption('disableDoubleClickZoom', false);
     $map->setStylesheetOption('width', $width);
     $map->setStylesheetOption('height', $height);
     $map->setLanguage('fr');
     $map->addMarker($marker);
     return $map;
 }
 /**
  * View action
  * @param int $id
  * @throws \Exception
  */
 public function viewAction($id = null)
 {
     if (is_null($id)) {
         throw new \Exception('Bad request');
     }
     $id = abs((int) $id);
     $userId = $this->session->get('uid');
     $model = $this->loadModel('events');
     $comments = $this->loadModel('comment');
     $event = $model->getEvent($id);
     $isJoined = $model->checkJoinedUser($id, $userId);
     $attendingUsers = $model->getAttendingUsers($id);
     /** Google Maps API */
     $map = new Map();
     $markerPositions = $instructions = $commonInfo = [];
     $map->setLanguage('uk');
     $map->setAutoZoom(true);
     $map->setPrefixJavascriptVariable('map_');
     $map->setHtmlContainerId('map-canvas-view');
     $map->setMapOptions(array('disableDefaultUI' => true, 'disableDoubleClickZoom' => true, 'mapTypeId' => 'roadmap'));
     $map->setStylesheetOptions(array('width' => '58%', 'height' => 'calc(100% - 0)', 'position' => 'absolute', 'right' => '0px', 'top' => '50px', 'bottom' => '2px', 'overflow' => 'hidden'));
     // Build directions
     $request = new DirectionsRequest();
     $request->setLanguage('uk');
     $request->setUnitSystem(UnitSystem::METRIC);
     $request->setTravelMode($event['routeMode']);
     $request->setOrigin($event['routeFrom']);
     $request->setDestination($event['routeTo']);
     // @TODO: Do it
     // $request->addWaypoint($event['routeVia']);
     // $request->setOptimizeWaypoints(true);
     // $request->setAvoidHighways(true);
     // $request->setAvoidTolls(true);
     // $request->setProvideRouteAlternatives(true);
     $directions = new Directions(new CurlHttpAdapter());
     $response = $directions->route($request);
     if ($response->getStatus() === 'OK') {
         $routes = $response->getRoutes();
         foreach ($routes as $route) {
             $overviewPolyline = $route->getOverviewPolyline();
             //$waypointOrder = $route->getWaypointOrder();  // Get the waypoint order
             foreach ($route->getLegs() as $leg) {
                 // Set the start location & the end location into array
                 $markerPositions = ['start' => [$leg->getStartLocation()->getLatitude(), $leg->getStartLocation()->getLongitude()], 'end' => [$leg->getEndLocation()->getLatitude(), $leg->getEndLocation()->getLongitude()]];
                 $commonInfo = ['distance' => $leg->getDistance()->getText(), 'duration' => $leg->getDuration()->getText(), 'startAddress' => $leg->getStartAddress(), 'endAddress' => $leg->getEndAddress()];
                 // Set the directions steps
                 foreach ($leg->getSteps() as $key => $step) {
                     $instructions[] = [$step->getInstructions(), $step->getDistance()->getText(), $step->getDuration()->getText(), $step->getTravelMode()];
                 }
             }
         }
         // Build markers
         foreach ($markerPositions as $latlng) {
             $position = new Coordinate($latlng[0], $latlng[1], true);
             $marker = new Marker($position, 'drop', null, null, null, new InfoWindow());
             $map->addMarker($marker);
         }
         // Build Polyline
         $encodedPolyline = new EncodedPolyline();
         $encodedPolyline->setValue($overviewPolyline->getValue());
         $encodedPolyline->setOptions(array('geodesic' => true, 'strokeColor' => '#3079ed', 'strokeOpacity' => 0.8, 'strokeWeight' => 5));
         $map->addEncodedPolyline($encodedPolyline);
     } else {
         $position = new Coordinate($event['latTo'], $event['lngTo']);
         $info = $event['routeTo'];
         $info .= !empty($event['date']) ? '<hr><i class="glyphicon glyphicon-time"></i> ' . $event['date'] : '';
         $info .= !empty($event['end_date']) ? '<br><i class="glyphicon glyphicon-time"></i> ' . $event['end_date'] : '';
         $marker = new Marker($position, 'drop', null, null, null, new InfoWindow($info));
         $map->addMarker($marker);
     }
     // Render map
     $mapHelper = new MapHelper();
     $this->view->map = $mapHelper->render($map);
     $this->view->event = $event;
     $this->view->comments = $comments->getComments($id);
     $this->view->commentsAccess = (bool) $userId;
     $this->view->isJoined = (bool) $isJoined;
     $this->view->attendingUsers = $attendingUsers;
     $this->view->instructions = $instructions;
     $this->view->render('events/view');
 }
 /**
  * Renders an encoded polyline.
  *
  * @param \Ivory\GoogleMap\Overlays\EncodedPolyline $encodedPolyline The encoded polyline.
  * @param \Ivory\GoogleMap\Map                      $map             The map.
  *
  * @return string The JS output.
  */
 public function render(EncodedPolyline $encodedPolyline, Map $map)
 {
     $this->jsonBuilder->reset()->setValue('[map]', $map->getJavascriptVariable(), false)->setValue('[path]', $this->encodingHelper->renderDecodePath($encodedPolyline->getValue()), false)->setValues($encodedPolyline->getOptions());
     return sprintf('%s = new google.maps.Polyline(%s);' . PHP_EOL, $encodedPolyline->getJavascriptVariable(), $this->jsonBuilder->build());
 }
 /**
  * Renders a rectangle.
  *
  * @param \Ivory\GoogleMap\Overlays\Rectangle $rectangle The rectangle.
  * @param \Ivory\GoogleMap\Map                $map       The map.
  *
  * @return string The JS output.
  */
 public function render(Rectangle $rectangle, Map $map)
 {
     $this->jsonBuilder->reset()->setValue('[map]', $map->getJavascriptVariable(), false)->setValue('[bounds]', $rectangle->getBound()->getJavascriptVariable(), false)->setValues($rectangle->getOptions());
     return sprintf('%s = new google.maps.Rectangle(%s);' . PHP_EOL, $rectangle->getJavascriptVariable(), $this->jsonBuilder->build());
 }
 /**
  * Gets the javascript container name according to the map.
  *
  * @param \Ivory\GoogleMap\Map $map The map.
  *
  * @return string The javascript container name.
  */
 protected function getJsContainerName(Map $map)
 {
     return $map->getJavascriptVariable() . '_container';
 }
 public function testRenderAfterWithAsyncMap()
 {
     $map = new Map();
     $map->setAsync(true);
     $this->assertSame('}' . PHP_EOL, $this->coreExtensionHelper->renderAfter($map));
 }
    public function testRender()
    {
        $map = new Map();
        $map->setJavascriptVariable('map');
        $map->getCenter()->setJavascriptVariable('map_center');
        $expected = <<<EOF
<div id="map_canvas" style="width:300px;height:300px;"></div>
<style type="text/css">
#map_canvas{
width:300px;
height:300px;
}
</style>
<script type="text/javascript">
function load_ivory_google_map_api () { google.load("maps", "3", {"other_params":"language=en&sensor=false"}); };
</script>
<script type="text/javascript" src="//www.google.com/jsapi?callback=load_ivory_google_map_api"></script>
<script type="text/javascript">
map_container = {"map":null,"coordinates":{},"bounds":{},"points":{},"sizes":{},"circles":{},"encoded_polylines":{},"ground_overlays":{},"polygons":{},"polylines":{},"rectangles":{},"info_windows":{},"marker_images":{},"marker_shapes":{},"markers":{},"marker_cluster":null,"kml_layers":{},"event_manager":{"dom_events":{},"dom_events_once":{},"events":{},"events_once":{}},"closable_info_windows":{},"functions":{"to_array":function (object) { var array = []; for (var key in object) { array.push(object[key]); } return array; }}};
map_container.coordinates.map_center = map_center = new google.maps.LatLng(0, 0, true);
map_container.map = map = new google.maps.Map(document.getElementById("map_canvas"), {"mapTypeId":google.maps.MapTypeId.ROADMAP,"zoom":3});
map.setCenter(map_center);
</script>

EOF;
        $this->assertSame($expected, $this->mapHelper->render($map));
    }
 /**
  * Renders a kml layer.
  *
  * @param \Ivory\GoogleMap\Layers\KMLLayer $kmlLayer The KML layer.
  * @param \Ivory\GoogleMap\Map             $map      The map.
  *
  * @return string The JS output.
  */
 public function render(KMLLayer $kmlLayer, Map $map)
 {
     $this->jsonBuilder->reset()->setValue('[map]', $map->getJavascriptVariable(), false)->setValues($kmlLayer->getOptions());
     return sprintf('%s = new google.maps.KmlLayer("%s", %s);' . PHP_EOL, $kmlLayer->getJavascriptVariable(), $kmlLayer->getUrl(), $this->jsonBuilder->build());
 }