adding example apps, fixing powerup issues
[feisty_meow.git] / production / example_apps / zippy_maps / src / Template / Categories / center.ctp
1 <?php
2 /**
3  * @var \App\View\AppView $this
4  */
5
6 use Cake\Log\Log;
7 Log::debug('[got into center template]');
8 ?>
9 <nav class="large-3 medium-4 columns" id="actions-sidebar">
10         <ul class="side-nav">
11                 <li class="heading"><?= __('Actions') ?></li>
12                 <li><?= $this->Html->link(__('View Category'), ['action' => 'view', $category->id]) ?></li>
13                 <li><?= $this->Html->link(__('Edit Category'), ['action' => 'edit', $category->id]) ?> </li>
14                 <li><?= $this->Form->postLink(__('Delete Category'), ['action' => 'delete', $category->id], ['confirm' => __('Are you sure you want to delete # {0}?', $category->id)]) ?> </li>
15                 <li><?= $this->Html->link(__('List Categories'), ['action' => 'index']) ?> </li>
16                 <li><?= $this->Html->link(__('New Category'), ['action' => 'add']) ?> </li>
17         </ul>
18 </nav>
19 <div class="categories view large-9 medium-8 columns content">
20         <h3><?= h($category->name) ?></h3>
21         <table class="vertical-table">
22                 <tr>
23                         <th scope="row"><?= __('Name') ?></th>
24                         <td><?= h($category->name) ?></td>
25                 </tr>
26                 <tr>
27                         <th scope="row"><?= __('Map of this Category\'s Locations') ?></th>
28                         <td>
29 <?php
30         // dynamic map preparation below.
31         
32         // see if clustering is turned on.
33         $clustering = in_array ( 'clustering', $selectedList );
34         
35         //$this->log("state is: " . $state);
36         
37         // kludgey attempt to focus a little better, based on state size.  
38         $small_state = false;
39         $medium_state = false;
40         // is the state small?
41         $small_state = ($state == 'DE' || $state == 'RI' || $state == 'NH');
42 //      $this->log('small_state=' . var_export($small_state, true));
43         // if not small, we assume medium until told otherwise.
44         if (! $small_state) $medium_state = true;
45 //      $this->log('medium_state=' . var_export($medium_state, true));  
46         // if certain known fat states, then not medium sized.
47         if ($state == 'TX' || $state == 'CA' || $state == 'AK') $medium_state = false;  
48         $zoomFactor = $small_state? 8 : ( $medium_state? 7 : 5 );
49         $this->log('zooming at ' . $zoomFactor);        
50         //question: how to pick a more useful zoom factor?  maybe record in db a starting zoom factor per state?
51         
52         // list options we want to override or add for the map.
53         $map_options = [ 
54                         // automatically encompass markers and auto-center if they haven't told us where to start.
55                         'autoCenter' => ($mapCenter === null)? true : false,
56                         'clustering' => $clustering,
57                         'zoom' => $zoomFactor,
58         ];
59
60         // start at a specified center if one is given.
61         if ($mapCenter) {
62                 $map_options = array_merge($map_options, $mapCenter);
63         }
64         
65         //$this->log('new options set: ' . var_export($map_options, true));
66         
67         
68         // provide the element with all the info it needs to set up the map.
69         $element_options =
70         [
71                 'map_options' => $map_options,
72                 'map_colors' => 'avmaps/js/sg2_map_colors.js',
73                 'the_map' => $this->GoogleMap,
74                 // no options to pass to ajax so far...
75                 'ajax_options' => '{
76                 }',
77                 'default_options' => '{
78                         json_provider: "/categories.json",
79                         iconColor: "' . $this->MapDisplay->defaultIconColor() . '",
80                 }',
81         ];
82         
83         echo $this->element('Avmaps.google_map', $element_options);
84         
85         /*
86         // create the basic map framework using google maps api.
87         $this->MapDisplay->setupMap ( $map_options, $this->GoogleMap );
88         
89         // plug in our chosen color scheme for land, roads, etc.
90         $this->MapDisplay->applyColors ( 'avmaps/js/sg2_map_colors.js' );
91         
92         // after the intial configuration items are done, we can emit the map code.
93         // we can still add markers after this point, and do so below.
94         $this->MapDisplay->emitMap ( false );
95         
96         // we were handed a list of locations that match our query, so we can now add them as markers.
97         $this->MapDisplay->addMarkersInCategory ( $locationsInCategory, $category );
98         
99         // set up our event handler for this view.
100 //      $this->MapDisplay->injectJSFile('avmaps/js/event_trappers.js');
101         
102         // now we think we are ready to go. let's get the map displayed.
103         $this->MapDisplay->finallyDisplayMap ();
104         */
105         
106         // end of dynamic map preparation.
107 ?>
108                         </td>
109                 </tr>
110
111                 <tr>
112                         <th scope="row"><?= __('View Options') ?></th>
113                         <td>
114             <?= $this->Form->create($category) ?>
115                         <?php
116                         echo $this->Form->control ( 'view_options._ids', [ 
117                                         'type' => 'select',
118                                         'multiple' => true,
119                                         'val' => $selectedList,
120                                         'options' => [ 
121                                                         'clustering' => 'clustering' 
122                                         ] 
123                         ] );
124                         ?>
125          
126           <?= $this->Form->button(__('Modify View')) ?>
127                  <?= $this->Form->end() ?>
128          
129             </td>
130                 </tr>
131
132         </table>
133 </div>