Skip to content
Snippets Groups Projects
array.html 17.9 KiB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577
<!-- $Id$ -->

<em>This is a port of GMAP-ARRAY-DICTIONARY.txt to advanced_help. It's a work in progress.</em>

<p>This file defines the attributes available in GMap arrays. This is fairly similar to the GMAP-MACRO-DICTIONARY.txt, but distinct in that it addresses array keys and syntax specific to GMap arrays.</p>

<p>Defaults for map attributes can be set on the <a href="base_url:admin/settings/gmap">GMap settings page</a>.</p>

<h2>TOP LEVEL ATTRIBUTES</h2>

The top level of a GMap array will look something like this:
<pre>
  $map = array(
    '<a href="#tl-id"      >id</a>' =>                  // id attribute for the map
    '<a href="#tl-width"   >width</a>' =>               // map width in pixels or %
    '<a href="#tl-height"  >height</a>' =>              // map height in pixels
    '<a href="#tl-lat"     >latitude</a>' =>            // map center latitude
    '<a href="#tl-lon"     >longitude</a>' =>           // map center longitude
    '<a href="#tl-zoom"    >zoom</a>' =>                // zoom level
    '<a href="#tl-mz"      >maxzoom</a>' =>             // Maximum zoom level for autozoom.
    '<a href="#tl-extent"  >extent</a> =>               // map bounds
    '<a href="#tl-mt"      >maptype</a>' =>             // baselayer type
    '<a href="#tl-ct"      >controltype</a>' =>         // size of map controls
    '<a href="#tl-align"   >align</a>' =>               // CSS alignment for map div.
    '<a href="#tl-mtc"     >mtc</a>' =>                 // Map type control.
    '<a href="#tl-bl"      >baselayers</a>' => array(), // Enabled map baselayers.
    '<a href="#tl-styles"  >styles</a>' => array(),     // Shape style definitions.
    '<a href="#tl-behavior">behavior</a>' => array(),   // various map behavior flags
    '<a href="#tl-markers" >markers</a>' => array(),    // array of points on the map
    '<a href="#tl-shapes"  >shapes</a>' => array(),     // array of shapes to overlay on the map
  );
</pre>

<p>Here is a description of the top level keys of the map array.</p>
<ul>

<li><a name="tl-id">id</a>
<dl>
<dt>Values:</dt>
<dd>Identifier (String)</dd>
<dt>Description:</dt>
<dd>A unique identifier, used to distinguish a map from other maps on the page, and as a key to tie controls to a map.</dd>
<dt>Example:</dt>
<dd>
  "mymap"
</dd>
<dt>Notes:</dt>
<dd>
  Assign this if you are planning on using external controls with a map.
  One will be automatically assigned if you don't specify an id.
</dd>
</dl>
</li>

<li><a name="tl-width">width</a>
<dl>
<dt>Values:</dt>
<dd>CSS Dimension (String)</dd>
<dt>Description:</dt>
<dd>Width of map div, in valid css dimensions (generally pixels or percent).</dd>
<dt>Example:</dt>
<dd>"100%"</dd>
</dl>
</li>

<li><a name="tl-height">height</a>
<dl>
<dt>Values:</dt>
<dd>CSS Dimension (String)</dd>
<dt>Description:</dt>
<dd>Height of map div, in valid css dimensions (generally pixels).</dd>
<dt>Example:</dt>
<dd>"400px"</dd>
<dt>Notes:</dt>
<dd>
  Using a percentage for height will most likely lead to a buggy map. Google's javascript
  must be able to determine the actual height of the map div for proper operation.
</dd>
</dl>
</li>

<li><a name="tl-lat">latitude</a>
<dl>
<dt>Values:</dt>
<dd>Latitude of map center in degrees decimal format. (Float)</dd>
<dt>Description:</dt>
<dd>Map center point latitude, as a signed float.</dd>
<dt>Example:</dt>
<dd>39.36827914916013</dd>
<dt>Notes:</dt>
<dd>
  Cast to float if you are unsure what type your latitude variable is; some parts of
  Google Maps do not operate correctly if latitude is passed as a string.
  See "extent" if you wish to provide a bounding rectangle instead.
</dd>
</dl>
</li>

<li><a name="tl-lon">longitude</a>
<dl>
<dt>Values:</dt>
<dd>Longitude of map center in degrees decimal format. (Float)</dd>
<dt>Description:</dt>
<dd>Map center point longitude, as a signed float.</dd>
<dt>Example:</dt>
<dd>-81.5625</dd>
<dt>Notes:</dt>
<dd>
  Cast to float if you are unsure what type your latitude variable is; some parts of
  Google Maps do not operate correctly if latitude is passed as a string.
  See "extent" if you wish to provide a bounding rectangle instead.
</dd>
</dl>
</li>

<li><a name="tl-zoom">zoom</a>
<dl>
<dt>Values:</dt>
<dd>0-17 (Integer)</dd>
<dt>Description:</dt>
<dd>Initial map zoom level. (This may be modified after map load by the user / autozoom / etc.)</dd>
<dt>Example:</dt>
<dd>7</dd>
<dt>Notes:</dt>
<dd>
  0 is the furthest out zoom level, 17 is the closest up zoom level (but is subject to change.)
  Some areas do not have satellite data all the way to 17, you may want to stay zoomed out a few clicks.
  See "extent" if you wish to provide a bounding rectangle instead.
</dd>
</dl>
</li>

<li><a name="tl-mz">maxzoom</a>
<dl>
<dt>Values:</dt>
<dd>0-17 (Integer)</dd>
<dt>Description:</dt>
<dd>
  Sets the maximum level of zoom the 'autozoom' behavior flag will zoom to.
  Useful to prevent single-marker maps from zooming in too far.
</dd>
<dt>Example:</dt>
<dd>7</dd>
<dt>Notes:</dt>
<dd></dd>
</dl>
</li>

<li><a name="tl-extent">extent</a>
<dl>
<dt>Values:</dt>
<dd>array(array(float, float), array(float, float))</dd>
<dt>Description:</dt>
<dd>
  Initial bounding box for map. The first inner array is the southwest corner,
  the second inner array is the northeast corner.
  All units are degrees decimal.
  Make sure to cast coordinate components to float as needed.
</dd>
<dt>Example:</dt>
<dd>array(array(43.19, -104.06), array(46.01, -96.76))</dd>
<dt>Notes:</dt>
<dd>
  Setting extent will cause the map to disregard latitude, longitude, and zoom.
  The actual map extent may vary slightly from the requested extent due to the
  tiled zoom level based nature of Google Maps.
</dd>
</dl>
</li>

<li><a name="tl-mt">maptype</a>
<dl>
<dt>Values:</dt>
<dd>"Map", "Satellite", "Hybrid", "Terrain", ... (String)</dd>
<dt>Description:</dt>
<dd>
  Initial baselayer of map. The set of allowable baselayers can be extended,
  see the gmap_extrabaselayers in the gmap_addons project for examples of how to
  add additional baselayers.
</dd>
<dt>Example:</dt>
<dd>"Map"</dd>
<dt>Notes:</dt>
<dd>
  The most common values are "Map" and "Hybrid". Addon modules that add additional
  baselayers must use identfiers that won't conflict with other modules. (The
  four "core" maptypes are poorly named due to legacy macros.)
</dd>
</dl>
</li>

<li><a name="tl-ct">controltype</a>
<dl>
<dt>Values:</dt>
<dd>"None", "Micro", "Small", "Large" (String)</dd>
<dt>Description:</dt>
<dd>Set the pan/zoom control type.</dd>
<dt>Example:</dt>
<dd>"Small"</dd>
<dt>Notes:</dt>
<dd>"Micro" corresponds to GSmallZoomControl, which only provides zoom control.</dd>
</dl>
</li>

<li><a name="tl-align">align</a>
<dl>
<dt>Values:</dt>
<dd>"Right", "Left", "Center" (String)</dd>
<dt>Description:</dt>
<dd>Sets the css alignment of the map div, using classes provided by gmap.css.</dd>
<dt>Example:</dt>
<dd>"Center"</dd>
<dt>Notes:</dt>
<dd>
  The limited flexibility of align is a holdover from the early days. If you
  need to position a map div more accurately, consider using a mapid and targeting
  the div yourself with css.
</dd>
</dl>
</li>

<li><a name="tl-mtc">mtc</a>
<dl>
<dt>Values:</dt>
<dd>"none", "standard", "hier", "menu" (String)</dd>
<dt>Description:</dt>
<dd>The "map type control" widget used to select different baselayers.</dd>
<dt>Example:</dt>
<dd>"standard"</dd>
<dt>Notes:</dt>
<dd>
  "standard" -- buttons ('GMapTypeControl' widget)<br />
  "hier"     -- buttons + dropdown menu ('GHierarchicalMapTypeControl' widget)<br />
  "menu"     -- dropdown menu ('GMenuMapTypeControl' widget)<br />
</dd>
</dl>
</li>

<li><a name="tl-bl">baselayers</a>
<dl>
<dt>Values:</dt>
<dd>array(string, ...)</dd>
<dt>Description:</dt>
<dd>Enabled baselayers.</dd>
<dt>Example:</dt>
<dd>array("Map", "Satellite", "Hybrid", "Terrain")</dd>
<dt>Notes:</dt>
<dd>
  The "traditional" set of baselayers is [Map, Satellite, Hybrid].
  Other modules, such as gmap_extrabaselayers (from gmap_addons) may provide
  additional possibilities.<br />
  The example shows the four "core" baselayers.
</dd>
</dl>
</li>

<li><a name="tl-styles">styles</a>
<dl>
<dt>Values:</dt>
<dd>array(string => array(...), ...)</dd>
<dt>Description:</dt>
<dd>An array of style names and definitions.</dd>
<dt>Example:</dt>
<dd>
<pre>
  array(
    'line_default' => array('0000ff',5,45,'',0,0),
    'poly_default' => array('000000',3,25,'ff0000',45),
    'green' => array('00ff00', 5, 100)
  );
</pre>
</dd>
<dt>Notes:</dt>
<dd>
  Currently, 'line_default' and 'poly_default' are predefined, and apply to lines and
  filled polygons that do not have style information assigned.
  You can override these two defaults on the map level if you wish.<br />
  See "Style definitions" below for more information on styles.
</dd>
</dl>
</li>

<li><a name="tl-behavior">behavior</a>
<dl>
<dt>Values:</dt>
<dd>array(string, ...)</dd>
<dt>Description:</dt>
<dd>
  Map behavior flags.<br />
  Any that aren't set on the map level will be inherited from the defaults.
</dd>
<dt>Example:</dt>
<dd>array('autozoom', 'overview')</dd>
<dt>Notes:</dt>
<dd>
  <p>There are several behavior flags recognized by gmap.module, and other modules
  may choose to add their own behavior flags as well.</p>
  <p>All behavior flags recognized are documented on the <a href="base_url:admin/settings/gmap">GMap settings page</a>.</p>
  <em>Core behavior flags:</em>
    <dl>
    <dt>locpick</dt>      <dd>Puts the map into "locpick" mode, which is used to choose a coordinate using the map.</dd>
    <dt>nodrag</dt>       <dd>Disables map dragging. Also disables keyboard shortcuts.</dd>
    <dt>nokeyboard</dt>   <dd>Disables the keyboard handler (arrow keys, etc.)</dd>
    <dt>nomousezoom</dt>  <dd>Disables the ability to zoom with the mouse wheel.</dt>
    <dt>autozoom</dt>     <dd>Enables automatic map bounds calculation, based on the markers added to the map.</dd>
    <dt>dynmarkers</dt>   <dd>Ensures the marker system is loaded. Use this if you will be dynamically adding markers
      to an empty map.</dd>
    <dt>overview</dt>     <dd>Enables the miniature overview map in the bottom right corner.</dd>
    <dt>collapsehack</dt> <dd>Attempts to work around a resize bug when placing maps inside collapsible fieldsets.<br />
      This does not work in all themes.</dd>
    <dt>scale</dt>        <dd>Adds a map scale legend to the map.</dd>
    <dt>fatmarkers</dt>   <dd>If enabled on a View, this will cause the gmap_views code to
      serialize the views fields and pass it through the map object. This is useful
      if you wish to use custom marker handling code.  Since you can't currently
      use map arrays with GMap Views (only macros), there's usually no point in setting it.</dd>
    </dl>
</dd>
</dl>
</li>

<li><a name="tl-markers">markers</a>
<dl>
<dt>Values:</dt>
<dd>array(array(...), ...)</dd>
<dt>Description:</dt>
<dd>An array of marker arrays to place on the map.</dd>
<dt>Example:</dt>
<dd>
<pre>
array(
  array(
    'options' => array(),
    'text' => 'start',
    'longitude' => 12.196,
    'latitude' => -58.13,
    'markername' => 'route',
    'offset' => 0,
  ),
  array(
    'options' => array(),
    'text' => 'finish',
    'longitude' => 12.196,
    'latitude' => -58.523,
    'markername' => 'route',
    'offset' => 1,
  ),
);
</pre>
</dd>
<dt>Notes:</dt>
<dd>
  <p>There are three types of overlays you can place on a map: markers, shapes, and feeds.
  Each of these classes is represented by a sub-array in the GMap array.</p>

  <p>This is not the only way to put markers on the map. It is, however, the easiest
  way. The markers specified here are loaded through the "static marker loader."</p>

  <p>You can also set arbitrary keys in the array. They will be passed to the javascript
  side automatically.</p>
</dd>
</dl>
</li>

<li><a name="tl-shapes">shapes</a>
<dl>
<dt>Values:</dt>
<dd>array(array(...), ...)</dd>
<dt>Description:</dt>
<dd></dd>
<dt>Example:</dt>
<dd></dd>
<dt>Notes:</dt>
<dd></dd>
</dl>
</li>



<!--
<li><a name="tl-foo">foo</a>
<dl>
<dt>Values:</dt>
<dd></dd>
<dt>Description:</dt>
<dd></dd>
<dt>Example:</dt>
<dd></dd>
<dt>Notes:</dt>
<dd></dd>
</dl>
</li>
-->

</ul>


<h2>OVERLAYS</h2>

<p>There are three types of overlays you can place on a map by default: markers, shapes, and feeds.
Each of these classes is represented by a sub-array in the GMap array.
Addon modules can add more types of overlays.
</p>


<h3>MARKERS</h3>

<pre>
  $marker = array(
    '<a href="ma-lat"    >latitude</a>' => 0.000,
    '<a href="ma-lon"    >longitude</a>' => 0.000,
    '<a href="ma-options">options</a>' => array(),
    '<a href="ma-text"   >text</a>' => 'popup text',
    '<a href="ma-mn"     >markername</a>' =>
    '<a href="ma-offset" >offset</a>' => 0,
  );
</pre>


<p>Here is a description of the keys of a marker array.</p>
<ul>

<li><a name="ma-lat">latitude</a>
<dl>
<dt>Values:</dt>
<dd>Latitude of point in degrees decimal format. (Float)</dd>
<dt>Description:</dt>
<dd>Marker latitude, as a signed float</dd>
<dt>Example:</dt>
<dd>39.36827914916013</dd>
<dt>Notes:</dt>
<dd>
    Cast to float if you are unsure what type your latitude variable is; some parts of
    Google Maps do not operate correctly if latitude is passed as a string.
</dd>
</dl>
</li>

<li><a name="ma-lon">longitude</a>
<dl>
<dt>Values:</dt>
<dd>Longitude of point in degrees decimal format. (Float)</dd>
<dt>Description:</dt>
<dd>Marker longitude, as a signed float.</dd>
<dt>Example:</dt>
<dd>-81.5625</dd>
<dt>Notes:</dt>
<dd>
    Cast to float if you are unsure what type your latitude variable is; some parts of
    Google Maps do not operate correctly if latitude is passed as a string.
</dd>
</dl>
</li>



  Attribute:
    markername
  Values:
    The name of the icon set to use (String)
  Description:
    Marker icons are located in the GMap module's 'markers' directory.
    GMap reads the .ini files to find available markers.
  Example:
    "Light Blue"
  Notes:
    Some marker sets
  sequential markers are available; for example, if the markername is set to "number", then the icons in the marker directory named 'number1.png', 'number2.png' etc.  will be used. If these don't exist 'number.png' would be used.  If that doesn't exist then the default marker will be used.

  Attribute:		text
  Values:				"map bubble text"
  Description:	text and/or HTML to be displayed in the map bubble when the marker is clicked
  Example:			"Point A"
  Notes:        @@@ Bdragon mentioned an "array tabs trick"??



<!--
<li><a name="ma-foo">foo</a>
<dl>
<dt>Values:</dt>
<dd></dd>
<dt>Description:</dt>
<dd></dd>
<dt>Example:</dt>
<dd></dd>
<dt>Notes:</dt>
<dd></dd>
</dl>
</li>
-->

</ul>












Attribute:		shapes
Values:				array()
Description:	an array of shapes to place on the map

A "line" or "polygon" shape will be described by an array that looks like this:
<?php
  $shape = array(
    'type' => "polygon",
    'points' => array(
      array(0.000, 0.000),
      array(0.000, 0.000),
      array(0.000, 0.000),
    ),
    'style' => array("ff0000", 5, 80, "00ff00", 60),
  );
?>


  Attribute:		type
  Values:				"line", "polygon", "circle", "rpolygon"
  Description:	the type of shape to draw
  Example:			"line"
  Notes:        "line" is drawn as a GPolyline.
                "polygon" is drawn as a GPolygon.
                "circle" and "rpolygon" (regular polygon) are special cases of "polygon"; points are calculated on the fly. The array defining circles and regular polygons looks different from the arrays defining lines and polygons; see below.

  Attribute:		points
  Values:				array(array(lat1, lon1), array(lat2, lon2), ... , array(latN, lonN))
  Description:	an array of points defining the shape
  Example:			array(array(44.205835001, -70.3674316406), array(44.3159879052, -68.6096191406))
  Notes:        Each point itself is an array with two elements (latitude, longitude). The different shapes have different requirements with respect to points.

                "line" must have at least two points. It is best to break up long lines into shorter segments, because long lines can be buggy--sometimes beginning and ending points are switched.

                "polygon" should have at least three points; the first and last points should have the same coordinates.

  Attribute:		style
  Values:				array(stroke color, stroke weight, stroke opacity, fill color, fill opacity)
  Description:	a "style array"
  Example:			array("ff0000", 5, 80, "00ff00", 60)
  Notes:        The elements of this array MUST be in the specified order.

                Stroke and fill colors should be hex color codes (without the leading "#"); Google Maps does not accept named colors.

                The stroke weight is the width of the line or polygon border in pixels.

                Stroke and fill opacities should be a percentage between 0 and 100.

                Fill color and fill opacity are not used for type "line".

                If shapes of type "line" don't have styles defined, the 'line_default' style will be used; shapes of type "polygon", "circle", and "rpolygon" will use 'poly_defalt'.

                In previous versions of GMap, opacity was specified as a number between 0 and 1; it is now a number between 0 and 100.

                On backwards compatibility: there were originally more style options, but they were dependant on xmaps; xmaps is no longer compatible with Google Maps, so these options are now ignored. They are: 'pattern', 'text', 'fillcolor', 'fillopacity'; all except for 'pattern' are now available with different syntax.

  Circles and regular polygons are special cases of "polygon" and have significantly different shape arrays:
  <?php
    $shape1 = array(
      'type' => 'circle',
      'center' => array(0.000, 0.000),  // center coordinate of the circle
      'radius' => 100,                  // radius of the circle in kilmeters
      'style' => array(),               // uses 'poly_default' if not defined
    );

    $shape2 = array(
      'type' => 'rpolygon',
      'center' => array(0.000, 0.000),  // center coordinate of the circle
      'numpoints' => 4,                 // number of vertices the polygon should have
      'point2' => array(0.000, 0.000),  // one vertice of the polygon
      'style' => array(),               // uses 'poly_default' if not defined
    );
  ?>