= __('Map of this Category\'s Locations') ?> |
log("state is: " . $state);
// kludgey attempt to focus a little better, based on state size.
$small_state = false;
$medium_state = false;
// is the state small?
$small_state = ($state == 'DE' || $state == 'RI' || $state == 'NH');
// $this->log('small_state=' . var_export($small_state, true));
// if not small, we assume medium until told otherwise.
if (! $small_state) $medium_state = true;
// $this->log('medium_state=' . var_export($medium_state, true));
// if certain known fat states, then not medium sized.
if ($state == 'TX' || $state == 'CA' || $state == 'AK') $medium_state = false;
$zoomFactor = $small_state? 8 : ( $medium_state? 7 : 5 );
$this->log('zooming at ' . $zoomFactor);
//question: how to pick a more useful zoom factor? maybe record in db a starting zoom factor per state?
// list options we want to override or add for the map.
$map_options = [
// automatically encompass markers and auto-center if they haven't told us where to start.
'autoCenter' => ($mapCenter === null)? true : false,
'clustering' => $clustering,
'zoom' => $zoomFactor,
];
// start at a specified center if one is given.
if ($mapCenter) {
$map_options = array_merge($map_options, $mapCenter);
}
//$this->log('new options set: ' . var_export($map_options, true));
// provide the element with all the info it needs to set up the map.
$element_options =
[
'map_options' => $map_options,
'map_colors' => 'avmaps/js/sg2_map_colors.js',
'the_map' => $this->GoogleMap,
// no options to pass to ajax so far...
'ajax_options' => '{
}',
'default_options' => '{
json_provider: "/categories.json",
iconColor: "' . $this->MapDisplay->defaultIconColor() . '",
}',
];
echo $this->element('Avmaps.google_map', $element_options);
/*
// create the basic map framework using google maps api.
$this->MapDisplay->setupMap ( $map_options, $this->GoogleMap );
// plug in our chosen color scheme for land, roads, etc.
$this->MapDisplay->applyColors ( 'avmaps/js/sg2_map_colors.js' );
// after the intial configuration items are done, we can emit the map code.
// we can still add markers after this point, and do so below.
$this->MapDisplay->emitMap ( false );
// we were handed a list of locations that match our query, so we can now add them as markers.
$this->MapDisplay->addMarkersInCategory ( $locationsInCategory, $category );
// set up our event handler for this view.
// $this->MapDisplay->injectJSFile('avmaps/js/event_trappers.js');
// now we think we are ready to go. let's get the map displayed.
$this->MapDisplay->finallyDisplayMap ();
*/
// end of dynamic map preparation.
?>
|