The Troupe

Every dance must have a dancer. Every play must have an actor. Every song must have a singer. A company of such performers, particularly a traveling company, is called a troupe. Our map assembles a troupe of variables.

We will need some variables for adjusting our macro; these will make our map dynamic. We find several variable names in our sample macro. A study of Google's Map API illuminates variables' structures and guides our selection criteria.

Our application, while not a fully exploited map, is not a basic application and our troupe is a fair consideration. Some control of the map size and initial magnification is desirable. Also desirable are capacity to specify geolocations for the center of our map and at least one pinned location; the map center and a pinned location may require identical or distinct specifications. A map could require multiple groups with multiple locations; we establish framework for potential enhancements.

markers
A sequence array of marker sets
icon
A map pin image reference
A sequence array of map pin geolocation arrays
lat
Latitude of the pin
lon
Longitude of the pin
zoom
View magnification — between 0 and 17, inclusive
width
A dimension array
magnitude
A positive real number
unit
The measurement standard
height
A dimension array
magnitude
A positive real number
unit
The measurement standard
center
The map center geolocation
lat
Latitude of the map center
lon
Longitude of the map center
control
Type of zoom and pan control displayed on the map
type
The map presentation overlay

We used the following initialization script for our construct. Sequence arrays may have multiple instances; for the sake of simplicity, only singular sequence arrays are generated in this tutorial but the frameworks are included.

<?php
// VARIABLES
// If map control is not posted
//   use defaults
$my_gmap =
(isset($_POST['map'])) ?
   $_POST['my_gmap'] :
array (
  'markers'     => array(
    array(
      'icon'    => 'vertex',
      'geoloc'  => array(
        array(
          'lat' =>  36.66195,
          'lon' => -80.92485
  ) ) ) ),
  'zoom'        => 16,
  'center'      => array(
    'lat'       =>  36.66195,
    'lon'       => -80.9248
  ),
  'width'       => array(
    'magnitude' => 450,
    'unit'      => 'px'
  ),
  'height'      => array(
    'magnitude' => 250,
    'unit'      => 'px'
  ),
  'control'     => 'Small',
  'type'        => 'Map'
);
?>

After establishing default values in our construct, we enumerated finite option sets for a number of variables. These enumerations limit, but do not eliminate, invalid maps by restricting critical variables to acceptable values. While users may still posit useful values which request unreasonable computations (for example: a map width of 600 inches), we prohibit users from submitting invalid data by using select options sets. Dimensional and other limits should be an exercise in boundary checking … and that is a whole other education.

From our construct, enumerated options lists accommodate marker icons, zoom levels, dimensional units, map controls and map types. Giving all enumerations is more than necessary for instructional purposes; the most diverse is sufficient for demonstration. The most diverse enumeration, of map types, follows.

<?php
// Enumerate map type options to limit occurrence of empty maps
$types = array('Map'      =>'Standard street map',
               'Satellite'=>'Standard satellite map',
               'Hybrid'   =>'Hybrid satellite map',
               'Physical' =>'Physical feature map');
?>