Skip to content

Commit

Permalink
Update default mapquest OSM layer.
Browse files Browse the repository at this point in the history
Fix "Example GeoJSON Map'.
Update resolutions array to 21 resolutions instead of 18.
Add zoomOffset parameter to layer type xyz, you can now restrict zoom per layer.
Removed default 'maxExtent' parameter until further notice.
  • Loading branch information
Pol Dell'Aiera authored and Pol Dell'Aiera committed Jan 30, 2013
1 parent 6b2a850 commit 115b293
Show file tree
Hide file tree
Showing 10 changed files with 57 additions and 24 deletions.
5 changes: 3 additions & 2 deletions includes/openlayers.layers.inc
Expand Up @@ -85,7 +85,8 @@ function _openlayers_openlayers_layers() {
'//otile3' . $mapquest_host . '/tiles/1.0.0/osm/${z}/${x}/${y}.png',
'//otile4' . $mapquest_host . '/tiles/1.0.0/osm/${z}/${x}/${y}.png',
),
'wrapDateLine' => TRUE,
'wrapDateLine' => FALSE,
'resolutions' => openlayers_get_resolutions('900913', 0, 19)
);
$layers[$layer->name] = $layer;

Expand Down Expand Up @@ -323,7 +324,7 @@ function _openlayers_openlayers_layers() {
$layers[$layer->name] = $layer;

$info = _mapbox_layers_info();
$resolutions = array_combine(range(0, 18), openlayers_get_resolutions('900913'));
$resolutions = array_combine(range(0, 21), openlayers_get_resolutions('900913'));

foreach ($info as $key => $item) {
$openlayers_layers = new stdClass;
Expand Down
21 changes: 10 additions & 11 deletions includes/openlayers.maps.inc
Expand Up @@ -118,17 +118,19 @@ function _openlayers_openlayers_maps() {
$items['default_google'] = $openlayers_maps;

// Example map with MapQuest and GeoJSON
$openlayers_maps = new stdClass;
$openlayers_maps->disabled = FALSE;
$openlayers_maps = new stdClass();
$openlayers_maps->disabled = FALSE; /* Edit this to true to make a default openlayers_maps disabled initially */
$openlayers_maps->api_version = 1;
$openlayers_maps->name = 'example_geojson';
$openlayers_maps->title = t('Example GeoJSON Map');
$openlayers_maps->description = t('A simple map with a custom GeoJSON layer with direct data. Also an example of zooming into a layer.');
$openlayers_maps->title = 'Example GeoJSON Map';
$openlayers_maps->description = 'A simple map with a custom GeoJSON layer with direct data. Also an example of zooming into a layer.';
$openlayers_maps->data = array(
'width' => 'auto',
'height' => '400px',
'image_path' => drupal_get_path('module', 'openlayers') . '/themes/default_dark/img/',
'css_path' => drupal_get_path('module', 'openlayers') . '/themes/default_dark/style.css',
'proxy_host' => '',
'hide_empty_map' => 0,
'center' => array(
'initial' => array(
'centerpoint' => '0,0',
Expand All @@ -140,14 +142,13 @@ function _openlayers_openlayers_maps() {
),
),
'behaviors' => array(
'openlayers_behavior_attribution' => array(
'seperator' => '',
),
'openlayers_behavior_keyboarddefaults' => array(),
'openlayers_behavior_layerswitcher' => array(
'ascending' => 1,
'sortBaseLayer' => '0',
'roundedCorner' => 1,
'roundedCornerColor' => '#222222',
'maximizeDefault' => 0,
),
'openlayers_behavior_navigation' => array(
'zoomWheelEnabled' => 1,
Expand All @@ -162,10 +163,8 @@ function _openlayers_openlayers_maps() {
'layers' => array(
'openlayers_geojson_picture_this' => 'openlayers_geojson_picture_this',
),
),
'openlayers_behavior_zoomtolayer' => array(
'zoomtolayer' => 'openlayers_geojson_picture_this',
'point_zoom_level' => '18',
'panMapIfOutOfView' => 0,
'keepInMap' => 1,
),
),
'default_layer' => 'mapquest_openaerial',
Expand Down
Expand Up @@ -100,6 +100,7 @@ function edit_form_validate(&$form, &$form_state) {

$parent = get_parent_class($layer);
$parent_object = new $parent;
$form_state['values']['data'] += $layer->options_init();
$form_state['values']['data'] += $parent_object->options_init();

$layer_types = openlayers_layer_types();
Expand Down
15 changes: 11 additions & 4 deletions openlayers.module
Expand Up @@ -873,7 +873,11 @@ function openlayers_get_resolutions($projection, $zoom_start = 0, $zoom_end = FA
4.777314266967774,
2.388657133483887,
1.1943285667419434,
0.5971642833709717);
0.5971642833709717,
0.29858214169740677,
0.14929107084870338,
0.07464553542435169
);
break;
case '4326':
// 16 zoom levels, taken from
Expand All @@ -894,7 +898,9 @@ function openlayers_get_resolutions($projection, $zoom_start = 0, $zoom_end = FA
0.000171661376953125,
0.0000858306884765625,
0.00004291534423828125,
0.000021457672119140625);
0.000021457672119140625,
0.000010728836059570312,
);
break;
default:
$res = array();
Expand Down Expand Up @@ -991,10 +997,11 @@ class openlayers_layer_type {
'isBaseLayer' => TRUE,
'projection' => array('900913'),
// 'serverResolutions' => openlayers_get_resolutions('900913'),
'maxExtent' => openlayers_get_extent('900913'),
// 'maxExtent' => openlayers_get_extent('900913'),
'resolutions' => openlayers_get_resolutions('900913'),
'base_url' => NULL,
'transitionEffect' => 'resize'
'transitionEffect' => 'resize',
'weight' => 0
);
}

Expand Down
2 changes: 1 addition & 1 deletion plugins/behaviors/openlayers_behavior_layerzoom.inc
Expand Up @@ -42,7 +42,7 @@ class openlayers_behavior_layerzoom extends openlayers_behavior {
'#multiple' => TRUE,
'#options' => array_combine(
array_map('strval', openlayers_get_resolutions('900913')),
range(0, 18)
range(0, 21)
),
'#title' => t('Zoom Level Range for @layer', array('@layer' => $layer)),
'#default_value' => isset($this->options[$layer]['resolutions']) ?
Expand Down
2 changes: 1 addition & 1 deletion plugins/layer_types/openlayers_layer_type_mapbox.inc
Expand Up @@ -77,7 +77,7 @@ class openlayers_layer_type_mapbox extends openlayers_layer_type {
'resolutions' => array(
'#type' => 'select',
'#multiple' => TRUE,
'#options' => array_combine(array_map('strval', openlayers_get_resolutions('900913')), range(0, 18)),
'#options' => array_combine(array_map('strval', openlayers_get_resolutions('900913')), range(0, 21)),
'#title' => t('Zoom Level Range'),
'#default_value' => isset($this->data['resolutions']) ? array_map('strval', $this->data['resolutions']) : array(),
),
Expand Down
2 changes: 1 addition & 1 deletion plugins/layer_types/openlayers_layer_type_maptiler.inc
Expand Up @@ -52,7 +52,7 @@ class openlayers_layer_type_maptiler extends openlayers_layer_type {
'#multiple' => TRUE,
'#options' => array_combine(
array_map('strval', openlayers_get_resolutions('900913')),
range(0, 18)
range(0, 21)
),
'#title' => t('Zoom Level Range'),
'#default_value' => isset($this->data['resolutions']) ?
Expand Down
2 changes: 1 addition & 1 deletion plugins/layer_types/openlayers_layer_type_osm.inc
Expand Up @@ -61,7 +61,7 @@ class openlayers_layer_type_osm extends openlayers_layer_type {
'#multiple' => TRUE,
'#options' => array_combine(
array_map('strval', openlayers_get_resolutions('900913')),
range(0, 18)),
range(0, 21)),
'#title' => t('Zoom Level Range'),
'#default_value' => isset($this->data['resolutions']) ?
$this->data['resolutions'] :
Expand Down
2 changes: 1 addition & 1 deletion plugins/layer_types/openlayers_layer_type_tms.inc
Expand Up @@ -70,7 +70,7 @@ class openlayers_layer_type_tms extends openlayers_layer_type {
'#multiple' => TRUE,
'#options' => array_combine(
array_map('strval', openlayers_get_resolutions('900913')),
range(0, 18)
range(0, 21)
),
'#title' => t('Zoom Level Range'),
'#default_value' => isset($this->data['resolutions']) ?
Expand Down
29 changes: 27 additions & 2 deletions plugins/layer_types/openlayers_layer_type_xyz.inc
Expand Up @@ -34,6 +34,8 @@ class openlayers_layer_type_xyz extends openlayers_layer_type {
'layer_handler' => 'xyz',
'sphericalMercator' => TRUE,
'wrapDateLine' => FALSE,
'zoomOffset' => 0,
'resolutions' => array_slice(openlayers_get_resolutions('900913'), 0, 18)
);
}

Expand All @@ -55,10 +57,31 @@ class openlayers_layer_type_xyz extends openlayers_layer_type {
'#description' => t('Only set this if you need a very specific resolution.'),
'#options' => array_combine(
array_map('strval', openlayers_get_resolutions('900913')),
range(0, 18)),
range(0, 21)),
'#title' => t('Zoom Level Range'),
'#default_value' => isset($this->data['serverResolutions']) ?
$this->data['serverResolutions'] : array(),
array_map('strval', $this->data['serverResolutions']) : array(),
),
'resolutions' => array(
'#type' => 'select',
'#multiple' => TRUE,
'#description' => t('Only set this if you need a very specific resolution.'),
'#options' => array_combine(
array_map('strval', openlayers_get_resolutions('900913')),
range(0, 21)),
'#title' => t('Zoom Level Range'),
'#default_value' => isset($this->data['resolutions']) ?
array_map('strval', $this->data['resolutions']) : array(),
),
'zoomOffset' => array(
'#type' => 'select',
'#description' => t('Zoom offset.'),
'#options' => array_combine(
range(0, 21),
range(0, 21)),
'#title' => t('Zoom offset'),
'#default_value' => isset($this->data['zoomOffset']) ?
$this->data['zoomOffset'] : array(),
),
'wrapDateLine' => array(
'#type' => 'checkbox',
Expand All @@ -73,6 +96,8 @@ class openlayers_layer_type_xyz extends openlayers_layer_type {
$form_state['data']['url'] = explode("\n", $form_state['data']['url']);
$form_state['data']['serverResolutions'] = array_map('floatval', array_values($form_state['data']['serverResolutions']));
$form_state['data']['projection'] = array_values($form_state['data']['projection']);
$form_state['data']['resolutions'] = array_map('floatval', array_values($form_state['data']['resolutions']));
$form_state['data']['zoomOffset'] = (int) $form_state['data']['zoomOffset'];
}

/**
Expand Down

0 comments on commit 115b293

Please sign in to comment.