/** * @Route("/view") */ public function documentAction(Request $request) { if (Remote::isOptionsRequest()) { return Remote::getCORSSymfonyResponse(); } $secret = $request->get('identifier'); /** @var Doc $doc */ $doc = $this->getDoctrine()->getManager()->getRepository('AppShedExtensionsSpreadsheetMapsBundle:Doc')->findOneBy(['itemsecret' => $secret]); if (!$doc) { $screen = new Screen('Error'); $screen->addChild(new HTML('You must setup the extension before using it')); return (new Remote($screen))->getSymfonyResponse(); } $address = strtolower($doc->getAddress() ?: 'address'); try { $document = $this->getDocument($doc->getKey(), $this->getFilterString($doc->getFilters(), $request)); //This screen will have a list of the markers in Address column $screen = new Map($document->getTitle()); //For each row of the table foreach ($document as $entry) { $index = true; $lines = $entry->getCustom(); //Each of the columns of the row foreach ($lines as $customEntry) { $name = $customEntry->getColumnName(); $value = $customEntry->getText(); //If the name of a column ends with a '-' then we dont show it if ((strlen($name) - 1 == strpos($name, '-')) == false) { if ($index == true) { //This screen will have all the values across the row $innerScreen = new Screen($value); $index = false; } else { if (!empty($value)) { if ($name == $address) { $geo = $this->geoService->getGeo($value); if ($geo) { $marker = new Marker($address, $value, $geo['lng'], $geo['lat']); $marker->setScreenLink($innerScreen); $screen->addChild($marker); } } $innerScreen->addChild(new HTML($value)); } } } } } return (new Remote($screen))->getSymfonyResponse(); } catch (\Exception $e) { $screen = new Screen('Error'); $screen->addChild(new HTML('There was an error reading')); $screen->addChild(new Text($e->getMessage())); $this->logger->error('Problem reading a spreadsheet', ['exception' => $e]); return (new Remote($screen))->getSymfonyResponse(); } }
<?php require __DIR__ . '/../build/appshed-api.phar'; use AppShed\Remote\Element\Screen\Map; use AppShed\Remote\Element\Item\Marker; use AppShed\Remote\HTML\Remote; if (Remote::isOptionsRequest()) { Remote::getCORSResponseHeaders(); } $screen = new Map('Map Screen'); $screen->addChild(new Marker('Hi there', 'hello', 32, 49)); $remote = new Remote($screen); $remote->getResponse();
public function screenProvider() { $screen = new Map('Map Screen'); $screen->addChild(new Marker('Hi there', 'hello', 32, 49)); return [[$screen]]; }