source: sipes/modules_contrib/openlayers/docs/RAW_LAYERS.txt @ 1e95969

stableversion-3.0
Last change on this file since 1e95969 was 177a560, checked in by José Gregorio Puentes <jpuentes@…>, 8 años ago

se agrego el directorio de modulos contribuidos de drupal

  • Propiedad mode establecida a 100644
File size: 2.0 KB
Línea 
1
2Raw layers are an addition to OpenLayers post-alpha7 which allow users to
3manually add points to a layer type. In comparison to the layer_type
4method of pulling in custom data, this allows you to 'push' data into the
5layer data array itself. In any case where reusability is a priority,
6layer_types should be utilized (as documented in LAYER_TYPES.txt). However,
7this is a quick method for success that may be more accessible to more
8developers.
9
10A brief, example-only implementation of an arbitrary layer is below.
11
12/**
13 * Implementation of hook_ctools_plugin_api().
14 * Required to provide layers
15 */
16function geolocator_ctools_plugin_api($module, $api) {
17  if ($module == "openlayers") {
18    switch ($api) {
19      case 'openlayers_layers':
20        return array('version' => 1);
21    }
22  }
23}
24
25/**
26 * One can have the 'features' => element point to a function
27 * or be built on the fly within the _layers method. However,
28 * close attention must be paid to ctools caching in order to
29 * insure that dynamic data stays dynamic
30 */
31function geolocator_openlayers_layers() {
32  $layers = array();
33  $layer = new stdClass();
34  $layer->api_version = 1;
35  $layer->name = 'afghanistan';
36  $layer->title = 'One Point on Afghanistan';
37  $layer->description = '';
38  $layer->data = array(
39    'layer_type' => 'openlayers_layer_type_raw',
40    'projection' => array('900913'),
41    'features' => array(
42      array(
43      "wkt"=> "POINT(65 33)",
44      "projection"=> "4326",
45      "attributes"=>
46        array(
47          "name"=> "Afghanistan",
48          "description"=> "248"
49        )
50      )
51    )
52  );
53  $layers[$layer->name] = $layer;
54  return $layers;
55}
56
57/**
58 * map_preprocess_alter allows one to add a new layer to a map
59 * before layers are rendered and data is pulled from them.
60 */
61function geolocator_openlayers_map_preprocess_alter(&$map) {
62  $map['layers']['afghanistan'] = 'afghanistan';
63  $map['layer_activated']['afghanistan'] = 'afghanistan';
64  $map['layer_switcher']['afghanistan'] = 'afghanistan';
65}
Nota: Vea TracBrowser para ayuda de uso del navegador del repositorio.