-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathleaflet_custom.module
More file actions
131 lines (112 loc) · 3.28 KB
/
leaflet_custom.module
File metadata and controls
131 lines (112 loc) · 3.28 KB
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
<?php
/**
* @file
* Code for the Leaflet Custom Maps feature.
*/
include_once 'leaflet_custom.features.inc';
/**
* Loads all available custom maps.
*/
function _leaflet_custom_load_all() {
$query = new EntityFieldQuery();
$query
->entityCondition('entity_type', 'leaflet_custom_map', '=')
->entityCondition('bundle', 'leaflet_custom_map', '=');
$results = $query->execute();
$maps = array();
if(!empty($results)) {
$maps = entity_load('leaflet_custom_map', array_keys($results['leaflet_custom_map']));
}
return $maps;
}
/**
* Loads a single custom maps.
*/
function _leaflet_custom_load_one($entity_id) {
$query = new EntityFieldQuery();
$query
->entityCondition('entity_type', 'leaflet_custom_map', '=')
->entityCondition('bundle', 'leaflet_custom_map', '=')
->propertyCondutuib('id', $entity_id);
$results = $query->execute();
$maps = array();
if(!empty($results)) {
$maps = entity_load('leaflet_custom_map', array_keys($results['leaflet_custom_map']));
}
return reset($maps);
}
/**
* Implements hook_leaflet_map_info().
*
* Returns a list of custom maps for this module.
*/
function leaflet_custom_leaflet_map_info() {
global $language;
// $langcode = $language->language;
$langcode = LANGUAGE_NONE;
$map_info = array();
$map_entities = _leaflet_custom_load_all();
foreach ($map_entities as $map_entity) {
$map_info[$map_entity->title] = array(
'label' => $map_entity->title,
'description' => $map_entity->field_description[$langcode][0]['value'],
'settings' => array(
'minZoom' => $map_entity->field_minzoom[$langcode][0]['value'],
'maxZoom' => $map_entity->field_maxzoom[$langcode][0]['value'],
'dragging' => TRUE,
'touchZoom' => TRUE,
'scrollWheelZoom' => TRUE,
'doubleClickZoom' => TRUE,
'zoomControl' => TRUE,
'attributionControl' => TRUE,
'trackResize' => TRUE,
'fadeAnimation' => TRUE,
'zoomAnimation' => TRUE,
'closePopupOnClick' => TRUE,
),
'layers' => array(
'earth' => array(
'urlTemplate' => $map_entity->field_url_template[$langcode][0]['value'],
'options' => array(
'attribution' => $map_entity->field_attribution[$langcode][0]['value'],
),
),
),
'additional' => array(
'layers' => array(
'earth' => array(
'options' => array(
'tms' => TRUE,
'continuousWorld' => TRUE,
'noWrap' => TRUE,
),
),
),
),
'leaflet_custom_map_entity_id' => $map_entity->id,
);
}
return $map_info;
}
/**
* Implements hook_leaflet_map_prebuild_alter().
* Invoked by leaflet_build_map().
*/
function leaflet_custom_leaflet_map_prebuild_alter(&$settings) {
if (isset($settings['map']['additional'])) {
foreach ($settings['map']['additional'] as $item_key => $values) {
$settings['map'][$item_key] = array_merge_recursive(
$settings['map'][$item_key],
$values
);
}
}
/*
if (isset($settings['map']['leaflet_custom_map_entity_id'])) {
$entity_id = $settings['map']['leaflet_custom_map_entity_id']);
$map_entity = _leaflet_custom_load_one($entity_id);
if (!empty($entity_id)) {
}
}
*/
}