/** * Renders the decode path method. * * @param string $encodedPath The encoded path. * * @throws \Ivory\GoogleMap\Exception\HelperException If the encoded path is not valid. * * @return string The JS output. */ public function renderDecodePath($encodedPath) { if (!is_string($encodedPath)) { throw HelperException::invalidEncodedPath(); } return sprintf('google.maps.geometry.encoding.decodePath("%s")', addslashes($encodedPath)); }
/** * Renders an animation. * * @param string $animation The animation. * * @throws \Ivory\GoogleMap\Exception\HelperException If the animation is not valid. * * @return string The JS output. */ public function render($animation) { switch ($animation) { case Animation::BOUNCE: case Animation::DROP: return sprintf('google.maps.Animation.%s', strtoupper($animation)); default: throw HelperException::invalidAnimation(); } }
/** * Renders a zoom control style. * * @param string $zoomControlStyle The zoom control style. * * @throws \Ivory\GoogleMap\Exception\HelperException If thhe zoom control style is not valid. * * @return string The JS output. */ public function render($zoomControlStyle) { switch ($zoomControlStyle) { case ZoomControlStyle::DEFAULT_: case ZoomControlStyle::LARGE: case ZoomControlStyle::SMALL: return sprintf('google.maps.ZoomControlStyle.%s', strtoupper($zoomControlStyle)); default: throw HelperException::invalidZoomControlStyle(); } }
/** * Renders a map type control style. * * @param string $mapTypeControlStyle The map type control style. * * @throws \Ivory\GoogleMap\Exception\ControlException If the map type control style is not valid. * * @return string The JS output. */ public function render($mapTypeControlStyle) { switch ($mapTypeControlStyle) { case MapTypeControlStyle::DEFAULT_: case MapTypeControlStyle::DROPDOWN_MENU: case MapTypeControlStyle::HORIZONTAL_BAR: return sprintf('google.maps.MapTypeControlStyle.%s', strtoupper($mapTypeControlStyle)); default: throw HelperException::invalidMapTypeControlStyle(); } }
/** * Renders a map map type ID. * * @param string $mapTypeId The map type ID. * * @throws \Ivory\GoogleMap\Exception\HelperException If the map type ID is not valid. * * @return string The JS output. */ public function render($mapTypeId) { switch ($mapTypeId) { case MapTypeId::HYBRID: case MapTypeId::ROADMAP: case MapTypeId::SATELLITE: case MapTypeId::TERRAIN: return sprintf('google.maps.MapTypeId.%s', strtoupper($mapTypeId)); default: throw HelperException::invalidMapTypeId(); } }
/** * Renders a control position. * * @param string $controlPosition The control position. * * @throws \Ivory\GoogleMap\Exception\HelperException If the control position is not valid. * * @return The JS output. */ public function render($controlPosition) { switch ($controlPosition) { case ControlPosition::BOTTOM_CENTER: case ControlPosition::BOTTOM_LEFT: case ControlPosition::BOTTOM_RIGHT: case ControlPosition::LEFT_BOTTOM: case ControlPosition::LEFT_CENTER: case ControlPosition::LEFT_TOP: case ControlPosition::RIGHT_BOTTOM: case ControlPosition::RIGHT_CENTER: case ControlPosition::RIGHT_TOP: case ControlPosition::TOP_CENTER: case ControlPosition::TOP_LEFT: case ControlPosition::TOP_RIGHT: return sprintf('google.maps.ControlPosition.%s', strtoupper($controlPosition)); default: throw HelperException::invalidControlPosition(); } }
/** * Removes an extension helper. * * @param string $name The extension helper name. * * @throws \Ivory\GoogleMap\Exception\HelperException If the extension helper does not exist. */ public function removeExtensionHelper($name) { if (!$this->hasExtensionHelper($name)) { throw HelperException::invalidExtension($name); } unset($this->extensionHelpers[$name]); }
/** * Renders the autocomplete javascripts. * * @param \Ivory\GoogleMap\Places\Autocomplete $autocomplete The autocomplete. * * @throws \Ivory\GoogleMap\Exception\HelperException if the autocomplete bound does not have coordinates. * * @return string The HTML output. */ public function renderJavascripts(Autocomplete $autocomplete) { $output = array(); if (!$this->apiHelper->isLoaded() && !$autocomplete->isAsync()) { $output[] = $this->apiHelper->render($autocomplete->getLanguage(), array('places')); } $output[] = '<script type="text/javascript">' . PHP_EOL; if ($autocomplete->isAsync()) { $output[] = 'function load_ivory_google_place () {' . PHP_EOL; } if ($autocomplete->hasBound()) { if (!$autocomplete->getBound()->hasCoordinates()) { throw HelperException::invalidAutocompleteBound(); } $output[] = $this->coordinateHelper->render($autocomplete->getBound()->getSouthWest()); $output[] = $this->coordinateHelper->render($autocomplete->getBound()->getNorthEast()); $output[] = $this->boundHelper->render($autocomplete->getBound()); } $output[] = $this->renderAutocomplete($autocomplete); if ($autocomplete->isAsync()) { $output[] = '}' . PHP_EOL; } $output[] = '</script>' . PHP_EOL; if (!$this->apiHelper->isLoaded() && $autocomplete->isAsync()) { $output[] = $this->apiHelper->render($autocomplete->getLanguage(), array('places'), 'load_ivory_google_place'); } return implode('', $output); }
/** * Gets a specific marker cluster helper. * * @param string $name The marker cluster type. * * @throws \Ivory\GoogleMap\Exception\HelperException If the helper does not exist. * * @return \Ivory\GoogleMap\Helper\Overlays\MarkerCluster\MarkerClusterHelperInterface The marker cluster helper. */ public function getHelper($name) { if (!$this->hasHelper($name)) { throw HelperException::invalidMarkerClusterHelper(); } return $this->helpers[$name]; }