-
Notifications
You must be signed in to change notification settings - Fork 0
/
openlayers_layer_type_osm.inc
80 lines (74 loc) · 1.92 KB
/
openlayers_layer_type_osm.inc
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
<?php
/**
* @file
* OSM Layer Type
*/
/**
* Define the Ctools plugin options.
*/
function openlayers_openlayers_layer_type_osm_openlayers_layer_types() {
return array(
'title' => t('OSM'),
'description' => t('OpenStreetMap Standard'),
'layer_type' => array(
'file' => 'openlayers_layer_type_osm.inc',
'class' => 'openlayers_layer_type_osm',
'parent' => 'openlayers_layer_type',
),
);
}
/**
* OpenLayers OSM Layer Type class
*/
class openlayers_layer_type_osm extends openlayers_layer_type {
/**
* Provide initial values for options.
*/
function options_init() {
return parent::options_init() +
array(
'layer_handler' => 'xyz',
'type' => 'png',
);
}
/**
* Options form which generates layers
*/
function options_form($defaults = array()) {
return array(
'base_url' => array(
'#type' => 'textfield',
'#title' => t('Base URL'),
'#default_value' => isset($this->data['base_url']) ?
$this->data['base_url'] : ''
),
'type' => array(
'#type' => 'select',
'#title' => t('File Format'),
'#options' => array(
'png' => 'png',
'jpg' => 'jpg'),
'#default_value' => isset($this->data['type']) ?
$this->data['type'] : 'png'
),
'resolutions' => array(
'#type' => 'select',
'#multiple' => TRUE,
'#options' => array_combine(
array_map('strval', openlayers_get_resolutions('900913')),
range(0, 21)),
'#title' => t('Zoom Level Range'),
'#default_value' => isset($this->data['resolutions']) ?
$this->data['resolutions'] :
array_map('strval', openlayers_get_resolutions('900913'))
),
);
}
/**
* Render.
*/
function render(&$map) {
drupal_add_js(drupal_get_path('module', 'openlayers') .
'/plugins/layer_types/openlayers_layer_type_osm.js');
}
}