adding example apps, fixing powerup issues
[feisty_meow.git] / production / example_apps / zippy_maps / src / Template / Locations / view.ctp
1 <?php
2 use Avmaps\Controller\Component\SimpleMapsComponent;
3
4 /**
5   * @var \App\View\AppView $this
6   */
7 ?>
8 <nav class="large-3 medium-4 columns" id="actions-sidebar">
9     <ul class="side-nav">
10         <li class="heading"><?= __('Actions') ?></li>
11         <li><?= $this->Html->link(__('Edit Location'), ['action' => 'edit', $location->id]) ?> </li>
12         <li><?= $this->Form->postLink(__('Delete Location'), ['action' => 'delete', $location->id], ['confirm' => __('Are you sure you want to delete # {0}?', $location->id)]) ?> </li>
13         <li><?= $this->Html->link(__('List Locations'), ['action' => 'index']) ?> </li>
14         <li><?= $this->Html->link(__('New Location'), ['action' => 'add']) ?> </li>
15     </ul>
16 </nav>
17 <div class="locations view large-9 medium-8 columns content">
18     <h3><?= h($location->name) ?></h3>
19     <table class="vertical-table">
20         <tr>
21             <th scope="row"><?= __('Name') ?></th>
22             <td><?= h($location->name) ?></td>
23         </tr>
24         <tr>
25             <th scope="row"><?= __('Location') ?></th>
26             <td><?= h($location->location) ?></td>
27             <td>
28                                 <?php
29
30         //beginning of static map junk...
31         $addresses = [
32                         [ 'address' => $location->lat
33                         . ',' . $location->lng 
34                         ],
35         ];
36                 
37         $marker_options = [
38                         'color' => $this->MapDisplay->defaultIconColor(),
39                         'shadow' => 'false'
40         ];
41         
42         $markers = $this->GoogleMap->staticMarkers($addresses, $marker_options);
43         
44         $map_options = [
45                         'center' => $location->lat
46                         . ',' . $location->lng,
47                         'markers' => $markers,
48                         'zoom' => 8,
49         ];
50         
51         $map = $this->GoogleMap->staticMap($map_options);
52         
53         echo $map;
54         
55         $this->GoogleMap->finalize();
56         
57         //end static map junk.
58                         ?>
59             
60             </td>
61         </tr>
62         <tr>
63             <th scope="row"><?= __('Lat&Long') ?></th>
64             <td><?= h($location->lat . ',' . $location->lng) ?></td>
65         </tr>
66         <tr>
67             <th scope="row"><?= __('Zip Code (RGC)') ?></th>
68             <td>
69             <?php
70             $results = SimpleMapsComponent::reverseGeocode($location->lat, $location->lng, [
71                 'key' => $api_key
72             ]);
73             if ($results) {
74                                 echo h($results[0]);
75             } else {
76                 echo h('failed to reverse geocode');
77             }
78
79             ?>
80         </tr>
81         <tr>
82             <th scope="row"><?= __('Address (RGC)') ?></th>
83             <td><?= h($results[1]) ?></td>
84         </tr>
85         <tr>
86         <th scope="row"><?= __('Categories') ?></th>
87         <td>
88         <?= $this->Form->control('categories._ids', [
89                 'type' => 'select',
90                     'multiple' => true,
91                     'val' => $selectedList,
92                 'options' => $categoriesList,
93                         ]);
94                         ?>
95                 </td>
96     </table>
97 </div>