/** * Renders a map type control. * * @param \Ivory\GoogleMap\Controls\MapTypeControl $mapTypeControl The map type control. * * @return string The JS output. */ public function render(MapTypeControl $mapTypeControl) { $this->jsonBuilder->reset(); foreach ($mapTypeControl->getMapTypeIds() as $index => $mapTypeId) { $this->jsonBuilder->setValue(sprintf('[mapTypeIds][%d]', $index), $this->mapTypeIdHelper->render($mapTypeId), false); } return $this->jsonBuilder->setValue('[position]', $this->controlPositionHelper->render($mapTypeControl->getControlPosition()), false)->setValue('[style]', $this->mapTypeControlStyleHelper->render($mapTypeControl->getMapTypeControlStyle()), false)->build(); }
/** * Renders the map. * * @param \Ivory\GoogleMap\Map $map The map. * * @return string The JS output. */ public function renderMap(Map $map) { $mapTypeId = $map->getMapOption('mapTypeId'); $map->removeMapOption('mapTypeId'); $this->jsonBuilder->reset()->setValue('[mapTypeId]', $this->mapTypeIdHelper->render($mapTypeId), false); $this->renderMapControls($map); if ($map->isAutoZoom()) { $map->removeMapOption('zoom'); } $this->jsonBuilder->setValues($map->getMapOptions()); return sprintf('%s = new google.maps.Map(document.getElementById("%s"), %s);' . PHP_EOL, $map->getJavascriptVariable(), $map->getHtmlContainerId(), $this->jsonBuilder->build()); }
/** * @expectedException \Ivory\GoogleMap\Exception\HelperException * @expectedExceptionMessage The map type id can only be : hybrid, roadmap, satellite, terrain. */ public function testRenderWithInvalidValue() { $this->mapTypeIdHelper->render('foo'); }