first import
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Implementation of OpenLayers behavior.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Ctools plugin definition.
|
||||
*/
|
||||
function openlayers_openlayers_behavior_argparser_openlayers_behaviors() {
|
||||
return array(
|
||||
'title' => t('Argument Parser'),
|
||||
'description' => t('Parses Permalink-formatted arguments without adding a
|
||||
Permalink link to the map. Permalink is usually similar to:
|
||||
?zoom=1&lat=11&lon=11&layers=B0F'),
|
||||
'type' => 'layer',
|
||||
'behavior' => array(
|
||||
'file' => 'openlayers_behavior_argparser.inc',
|
||||
'class' => 'openlayers_behavior_argparser',
|
||||
'parent' => 'openlayers_behavior',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Attribution Behavior
|
||||
*/
|
||||
class openlayers_behavior_argparser extends openlayers_behavior {
|
||||
/**
|
||||
* Provide initial values for options.
|
||||
*/
|
||||
function options_init() {
|
||||
return array(
|
||||
'anchor' => FALSE,
|
||||
);
|
||||
}
|
||||
|
||||
function js_dependency() {
|
||||
return array('OpenLayers.Control.ArgParser');
|
||||
}
|
||||
|
||||
function options_form($defaults = array()) {
|
||||
return array(
|
||||
'anchor' => array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Anchor'),
|
||||
'#description' => t('Permalink is in the form of an anchor (#) instead of a query (?).'),
|
||||
'#default_value' => (isset($defaults['anchor'])) ? $defaults['anchor'] : FALSE,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render.
|
||||
*/
|
||||
function render(&$map) {
|
||||
drupal_add_js(drupal_get_path('module', 'openlayers') .
|
||||
'/plugins/behaviors/openlayers_behavior_argparser.js');
|
||||
return $this->options;
|
||||
}
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
/**
|
||||
* @file
|
||||
* JS Implementation of OpenLayers behavior.
|
||||
*/
|
||||
|
||||
/**
|
||||
* ArgParser Behavior. Implements the ArgParser OpenLayers
|
||||
* Control.
|
||||
*/
|
||||
Drupal.openlayers.addBehavior('openlayers_behavior_argparser', function (data, options) {
|
||||
Drupal.openlayers.addControl(data.openlayers, 'ArgParser', options);
|
||||
});
|
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Implementation of OpenLayers behavior.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Ctools plugin definition.
|
||||
*/
|
||||
function openlayers_openlayers_behavior_attribution_openlayers_behaviors() {
|
||||
return array(
|
||||
'title' => t('Layer Attribution'),
|
||||
'description' => t('Allows layers to provide attribution to the map if it exists. Most third-party layer will have some sort of attribution, but this may come with the actual tiles as well.'),
|
||||
'type' => 'layer',
|
||||
'behavior' => array(
|
||||
'file' => 'openlayers_behavior_attribution.inc',
|
||||
'class' => 'openlayers_behavior_attribution',
|
||||
'parent' => 'openlayers_behavior',
|
||||
),
|
||||
);
|
||||
}
|
||||
/**
|
||||
* Attribution Behavior
|
||||
*/
|
||||
class openlayers_behavior_attribution extends openlayers_behavior {
|
||||
/**
|
||||
* Provide initial values for options.
|
||||
*/
|
||||
function options_init() {
|
||||
return array(
|
||||
'seperator' => '',
|
||||
);
|
||||
}
|
||||
|
||||
function js_dependency() {
|
||||
return array('OpenLayers.Control.Attribution');
|
||||
}
|
||||
|
||||
function options_form($defaults = array()) {
|
||||
return array(
|
||||
'seperator' => array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Seperator'),
|
||||
'#description' => t('For multiple layers that need attribution, provide a separation string.'),
|
||||
'#default_value' => (isset($defaults['seperator'])) ? $defaults['seperator'] : FALSE,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render.
|
||||
*/
|
||||
function render(&$map) {
|
||||
drupal_add_js(drupal_get_path('module', 'openlayers') .
|
||||
'/plugins/behaviors/openlayers_behavior_attribution.js');
|
||||
return $this->options;
|
||||
}
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
/**
|
||||
* @file
|
||||
* JS Implementation of OpenLayers behavior.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Attribution Behavior. Implements the Attribution OpenLayers
|
||||
* Control.
|
||||
*/
|
||||
Drupal.openlayers.addBehavior('openlayers_behavior_attribution', function (data, options) {
|
||||
Drupal.openlayers.addControl(data.openlayers, 'Attribution', options);
|
||||
});
|
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Implementation of OpenLayers behavior.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Ctools plugin definition.
|
||||
*/
|
||||
function openlayers_openlayers_behavior_boxselect_openlayers_behaviors() {
|
||||
return array(
|
||||
'title' => t('Bounding Box Select'),
|
||||
'description' => t('Allows the selection and display of a bounding box. Currently hard-coded for the map making interface.'),
|
||||
'type' => 'map',
|
||||
'ui_visibility' => FALSE,
|
||||
'behavior' => array(
|
||||
'file' => 'openlayers_behavior_boxselect.inc',
|
||||
'class' => 'openlayers_behavior_boxselect',
|
||||
'parent' => 'openlayers_behavior',
|
||||
),
|
||||
);
|
||||
}
|
||||
/**
|
||||
* BoxSelect Behavior
|
||||
*/
|
||||
class openlayers_behavior_boxselect extends openlayers_behavior {
|
||||
/**
|
||||
* Provide initial values for options.
|
||||
*/
|
||||
function options_init() {
|
||||
return array(
|
||||
'input_fields' => '',
|
||||
);
|
||||
}
|
||||
|
||||
function js_dependency() {
|
||||
return array(
|
||||
'OpenLayers.Control.DrawFeature',
|
||||
'OpenLayers.Layer.Vector',
|
||||
'OpenLayers.Handler.RegularPolygon'
|
||||
);
|
||||
}
|
||||
|
||||
function options_form($defaults = array()) {
|
||||
return array(
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render.
|
||||
*/
|
||||
function render(&$map) {
|
||||
drupal_add_js(drupal_get_path('module', 'openlayers') .
|
||||
'/plugins/behaviors/openlayers_behavior_boxselect.js');
|
||||
return $this->options;
|
||||
}
|
||||
}
|
@@ -0,0 +1,61 @@
|
||||
/**
|
||||
* @file
|
||||
* JS Implementation of OpenLayers behavior.
|
||||
*/
|
||||
|
||||
// Not the best, but gets around scoping;
|
||||
var selections_layer;
|
||||
|
||||
(function ($) {
|
||||
/**
|
||||
* Box Select Behavior. Allows user to select a bounding box.
|
||||
*
|
||||
* TODO: This is currently hard coded for the center UI form.
|
||||
*/
|
||||
Drupal.openlayers.addBehavior('openlayers_behavior_boxselect', function (data, options) {
|
||||
// Callback to set extent into a specific form item.
|
||||
function setRestrictedExtent(box) {
|
||||
var bounding_box = box.geometry.getBounds().toBBOX();
|
||||
$('#edit-center-restrict-restrictedextent').val(bounding_box);
|
||||
|
||||
// Check box
|
||||
if (!($('#restrictextent').attr('checked'))) {
|
||||
$('#restrictextent')
|
||||
.attr('checked', 'checked')
|
||||
.trigger('change');
|
||||
}
|
||||
|
||||
// Remove any other features.
|
||||
for (var i = 0; i < selections_layer.features.length; i++) {
|
||||
if (selections_layer.features[i] != box) {
|
||||
selections_layer.features[i].destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Create layer to draw with and handle events.
|
||||
var selections_layer = new OpenLayers.Layer.Vector('Temporary Box Layer');
|
||||
var control = new OpenLayers.Control.DrawFeature(selections_layer,
|
||||
OpenLayers.Handler.RegularPolygon, {
|
||||
featureAdded: setRestrictedExtent
|
||||
}
|
||||
);
|
||||
control.handler.setOptions({
|
||||
'keyMask': OpenLayers.Handler.MOD_SHIFT,
|
||||
'sides': 4,
|
||||
'irregular': true
|
||||
});
|
||||
control.events.on({'featureAdded': this.setRestrictedExtent});
|
||||
data.openlayers.addLayer(selections_layer);
|
||||
data.openlayers.addControl(control);
|
||||
|
||||
// If there already is a value, then update the map appropriately.
|
||||
if ($('#edit-center-restrict-restrictedextent').val()) {
|
||||
bounds = $('#edit-center-restrict-restrictedextent').val();
|
||||
geometry = new OpenLayers.Bounds.fromString(bounds).toGeometry();
|
||||
feature = new OpenLayers.Feature.Vector(geometry);
|
||||
selections_layer.addFeatures([feature]);
|
||||
}
|
||||
control.activate();
|
||||
});
|
||||
}(jQuery));
|
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Implementation of OpenLayers Cluster behavior.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Ctools plugin definition.
|
||||
*/
|
||||
function openlayers_openlayers_behavior_cluster_openlayers_behaviors() {
|
||||
return array(
|
||||
'title' => t('Cluster Features'),
|
||||
'description' => t('Provides vector layer features clustering by proximity. This will not always respect the styles that assigned to the layer.'),
|
||||
'type' => 'layer',
|
||||
'behavior' => array(
|
||||
'file' => 'openlayers_behavior_cluster.inc',
|
||||
'class' => 'openlayers_behavior_cluster',
|
||||
'parent' => 'openlayers_behavior',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Cluster behavior
|
||||
*/
|
||||
class openlayers_behavior_cluster extends openlayers_behavior {
|
||||
/**
|
||||
* Provide initial values for options.
|
||||
*/
|
||||
function options_init() {
|
||||
return array(
|
||||
'clusterlayer' => array(),
|
||||
'distance' => '20',
|
||||
'threshold' => NULL,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* OpenLayers library dependency.
|
||||
*/
|
||||
function js_dependency() {
|
||||
return array('OpenLayers.Strategy.Cluster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide form for configurations per map.
|
||||
*/
|
||||
function options_form($defaults = array()) {
|
||||
// Only prompt for vector layers
|
||||
$vector_layers = array();
|
||||
foreach ($this->map['layers'] as $id => $name) {
|
||||
$layer = openlayers_layer_load($id);
|
||||
if (isset($layer->data['vector']) && $layer->data['vector'] == TRUE) {
|
||||
$vector_layers[$id] = $name;
|
||||
}
|
||||
}
|
||||
|
||||
return array(
|
||||
'clusterlayer' => array(
|
||||
'#title' => t('Layers'),
|
||||
'#type' => 'checkboxes',
|
||||
'#options' => $vector_layers,
|
||||
'#description' => t('Select layers to cluster.'),
|
||||
'#default_value' => isset($defaults['clusterlayer']) ?
|
||||
$defaults['clusterlayer'] : array(),
|
||||
),
|
||||
'distance' => array(
|
||||
'#type' => 'textfield',
|
||||
'#default_value' => (isset($defaults['distance'])) ?
|
||||
$defaults['distance'] : 20,
|
||||
'#size' => 5,
|
||||
'#title' => t('Distance'),
|
||||
'#description' => t('Pixel distance between features that should ' .
|
||||
'be considered a single cluster'),
|
||||
),
|
||||
'threshold' => array(
|
||||
'#type' => 'textfield',
|
||||
'#default_value' => (isset($defaults['threshold'])) ?
|
||||
$defaults['threshold'] : NULL,
|
||||
'#size' => 5,
|
||||
'#title' => t('Threshold'),
|
||||
'#description' => t('Optional threshold below which original ' .
|
||||
'features will be added to the layer instead of clusters'),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render.
|
||||
*/
|
||||
function render(&$map) {
|
||||
drupal_add_js(drupal_get_path('module', 'openlayers') .
|
||||
'/plugins/behaviors/openlayers_behavior_cluster.js');
|
||||
return $this->options;
|
||||
}
|
||||
}
|
@@ -0,0 +1,69 @@
|
||||
/**
|
||||
* @file
|
||||
* OpenLayers Behavior implementation for clustering.
|
||||
*/
|
||||
|
||||
/**
|
||||
* OpenLayers Cluster Behavior.
|
||||
*/
|
||||
Drupal.openlayers.addBehavior('openlayers_behavior_cluster', function (data, options) {
|
||||
var map = data.openlayers;
|
||||
var distance = parseInt(options.distance, 10);
|
||||
var threshold = parseInt(options.threshold, 10);
|
||||
var layers = [];
|
||||
for (var i in options.clusterlayer) {
|
||||
var selectedLayer = map.getLayersBy('drupalID', options.clusterlayer[i]);
|
||||
if (typeof selectedLayer[0] != 'undefined') {
|
||||
layers.push(selectedLayer[0]);
|
||||
}
|
||||
}
|
||||
|
||||
// Go through chosen layers
|
||||
for (var i in layers) {
|
||||
var layer = layers[i];
|
||||
// Ensure vector layer
|
||||
if (layer.CLASS_NAME == 'OpenLayers.Layer.Vector') {
|
||||
var cluster = new OpenLayers.Strategy.Cluster(options);
|
||||
layer.addOptions({ 'strategies': [cluster] });
|
||||
cluster.setLayer(layer);
|
||||
cluster.features = layer.features.slice();
|
||||
cluster.activate();
|
||||
cluster.cluster();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Override of callback used by 'popup' behaviour to support clusters
|
||||
*/
|
||||
Drupal.theme.openlayersPopup = function (feature) {
|
||||
if (feature.cluster) {
|
||||
var output = '';
|
||||
var visited = []; // to keep track of already-visited items
|
||||
var classes = [];
|
||||
|
||||
for (var i = 0; i < feature.cluster.length; i++) {
|
||||
var pf = feature.cluster[i]; // pseudo-feature
|
||||
if (typeof pf.drupalFID != 'undefined') {
|
||||
var mapwide_id = feature.layer.drupalID + pf.drupalFID;
|
||||
if (mapwide_id in visited) continue;
|
||||
visited[mapwide_id] = true;
|
||||
}
|
||||
|
||||
classes = ['openlayers-popup', 'openlayers-popup-feature'];
|
||||
if (i == 0) {
|
||||
classes.push('first');
|
||||
}
|
||||
if (i == (feature.cluster.length - 1)) {
|
||||
classes.push('last');
|
||||
}
|
||||
|
||||
output += '<div class="'+classes.join(' ')+'">' +
|
||||
Drupal.theme.prototype.openlayersPopup(pf) + '</div>';
|
||||
}
|
||||
return output;
|
||||
}
|
||||
else {
|
||||
return Drupal.theme.prototype.openlayersPopup(feature);
|
||||
}
|
||||
};
|
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Implementation of OpenLayers behavior.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Ctools plugin definition.
|
||||
*/
|
||||
function openlayers_openlayers_behavior_dragpan_openlayers_behaviors() {
|
||||
return array(
|
||||
'title' => t('Mouse Drag Pan'),
|
||||
'description' => t('Provides the ability to pan in the map interface with the mouse. The Navigation Control includes this control. You should only use this behavior if you want fine control over what interactions you want on your map.'),
|
||||
'type' => 'map',
|
||||
'behavior' => array(
|
||||
'file' => 'openlayers_behavior_dragpan.inc',
|
||||
'class' => 'openlayers_behavior_dragpan',
|
||||
'parent' => 'openlayers_behavior',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* DragPan Behavior
|
||||
*/
|
||||
class openlayers_behavior_dragpan extends openlayers_behavior {
|
||||
/**
|
||||
* Provide initial values for options.
|
||||
*/
|
||||
function options_init() {
|
||||
return array(
|
||||
'enableKinetic' => FALSE,
|
||||
'kineticInterval' => 10,
|
||||
);
|
||||
}
|
||||
|
||||
function js_dependency() {
|
||||
return array('OpenLayers.Control.DragPan');
|
||||
}
|
||||
|
||||
function options_form($defaults = array()) {
|
||||
$form = array();
|
||||
|
||||
// This options seem to be buggy. Shoudl look into more.
|
||||
/*
|
||||
$form = array(
|
||||
'enableKinetic' => array(
|
||||
'#title' => t('Enable Kinetic Dragging'),
|
||||
'#type' => 'checkbox',
|
||||
'#description' => t('Enables dragging and panning to have acceleration.'),
|
||||
'#default_value' => isset($defaults['enableKinetic']) ? $defaults['enableKinetic'] : FALSE,
|
||||
),
|
||||
'kineticInterval' => array(
|
||||
'#title' => t('Kinetic Interval'),
|
||||
'#type' => 'textfield',
|
||||
'#description' => t('An integer of millseconds of time between steps in "Kinetic Scrolling".'),
|
||||
'#default_value' => isset($defaults['kineticInterval']) ? $defaults['kineticInterval'] : 10,
|
||||
),
|
||||
);
|
||||
*/
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render.
|
||||
*/
|
||||
function render(&$map) {
|
||||
drupal_add_js(drupal_get_path('module', 'openlayers') .
|
||||
'/plugins/behaviors/openlayers_behavior_dragpan.js');
|
||||
return $this->options;
|
||||
}
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
/**
|
||||
* @file
|
||||
* JS Implementation of OpenLayers behavior.
|
||||
*/
|
||||
|
||||
/**
|
||||
* DragPan Behavior. Implements the DragPan OpenLayers
|
||||
* Control.
|
||||
*/
|
||||
Drupal.openlayers.addBehavior('openlayers_behavior_dragpan', function (data, options) {
|
||||
Drupal.openlayers.addControl(data.openlayers, 'DragPan', options);
|
||||
});
|
@@ -0,0 +1,12 @@
|
||||
/**
|
||||
* @file
|
||||
* CSS for OpenLayers Draw Features Behavior
|
||||
*/
|
||||
|
||||
.olControlEditingToolbar .olControlModifyFeatureItemActive {
|
||||
background-position: -1px -24px;
|
||||
}
|
||||
|
||||
.olControlEditingToolbar .olControlModifyFeatureItemInactive {
|
||||
background-position: -1px -1px;
|
||||
}
|
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Implementation of OpenLayers behavior.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Ctools plugin definition.
|
||||
*/
|
||||
function openlayers_openlayers_behavior_drawfeatures_openlayers_behaviors() {
|
||||
return array(
|
||||
'title' => t('Draw Features'),
|
||||
'description' => t('Provides functionality for adding features to a map.'),
|
||||
'type' => 'layer',
|
||||
'behavior' => array(
|
||||
'file' => 'openlayers_behavior_drawfeatures.inc',
|
||||
'class' => 'openlayers_behavior_drawfeatures',
|
||||
'parent' => 'openlayers_behavior',
|
||||
),
|
||||
);
|
||||
}
|
||||
/**
|
||||
* Draw Features behavior
|
||||
*/
|
||||
class openlayers_behavior_drawfeatures extends openlayers_behavior {
|
||||
/**
|
||||
* Provide initial values for options.
|
||||
*/
|
||||
function options_init() {
|
||||
return array(
|
||||
'element_id' => '',
|
||||
'feature_types' => array(),
|
||||
'feature_limit' => 0,
|
||||
);
|
||||
}
|
||||
|
||||
function options_form($defaults = array()) {
|
||||
$features = array(
|
||||
'point' => t('Point'),
|
||||
'path' => t('Path'),
|
||||
'polygon' => t('Polygon'),
|
||||
);
|
||||
|
||||
return array(
|
||||
'feature_types' => array(
|
||||
'#title' => t('Available Features'),
|
||||
'#type' => 'checkboxes',
|
||||
'#options' => $features,
|
||||
'#description' => t('Select what features are available to draw.'),
|
||||
'#default_value' => isset($defaults['feature_types']) ? $defaults['feature_types'] : array(),
|
||||
),
|
||||
'feature_limit' => array(
|
||||
'#title' => t('Number of features'),
|
||||
'#type' => 'textfield',
|
||||
'#description' => t('The number of features that are allowed to be
|
||||
drawn. Leave blank or at 0 for unlimited.'),
|
||||
'#default_value' => isset($defaults['feature_limit']) ? $defaults['feature_limit'] : 0,
|
||||
),
|
||||
'element_id' => array(
|
||||
'#type' => 'textfield',
|
||||
'#default_value' => (isset($defaults['element_id'])) ?
|
||||
$defaults['element_id'] : '',
|
||||
'#title' => t('Element ID'),
|
||||
'#description' => t('The DOM element ID that will be passed the value of the features. This will probably be a textfield or textarea.'),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render.
|
||||
*/
|
||||
function render(&$map) {
|
||||
drupal_add_css(drupal_get_path('module', 'openlayers') .
|
||||
'/plugins/behaviors/openlayers_behavior_drawfeatures.css');
|
||||
drupal_add_js(drupal_get_path('module', 'openlayers') .
|
||||
'/plugins/behaviors/openlayers_behavior_drawfeatures.js');
|
||||
return $this->options;
|
||||
}
|
||||
}
|
@@ -0,0 +1,153 @@
|
||||
/**
|
||||
* @file
|
||||
* DrawFeatures Behavior
|
||||
*/
|
||||
|
||||
(function($) {
|
||||
/**
|
||||
* Behavior for Draw Features.
|
||||
*
|
||||
* TODO: Update this to use the addBehaviors helper function.
|
||||
*/
|
||||
Drupal.behaviors.openlayers_behavior_drawfeatures = {
|
||||
'attach': function(context, settings) {
|
||||
|
||||
// Update function to write to element.
|
||||
function openlayers_behavior_drawfeatures_update(features) {
|
||||
WktWriter = new OpenLayers.Format.WKT();
|
||||
while (features.type == 'featureadded' && (this.feature_limit > 0) &&
|
||||
(this.feature_limit < features.object.features.length)) {
|
||||
features.feature.layer.removeFeatures(features.object.features.shift());
|
||||
}
|
||||
|
||||
var features_copy = features.object.clone();
|
||||
for (var i in features_copy.features) {
|
||||
features_copy.features[i].geometry.transform(
|
||||
features.object.map.projection,
|
||||
new OpenLayers.Projection('EPSG:4326')
|
||||
);
|
||||
}
|
||||
if (this.element != undefined) {
|
||||
this.element.val(WktWriter.write(features_copy.features));
|
||||
}
|
||||
}
|
||||
|
||||
// Start behavior process
|
||||
var data = $(context).data('openlayers');
|
||||
var behavior = data && data.map.behaviors['openlayers_behavior_drawfeatures'];
|
||||
if (!$(context).hasClass('openlayers-drawfeatures-processed') && behavior) {
|
||||
// Create element
|
||||
var feature_types = data.map.behaviors['openlayers_behavior_drawfeatures'].feature_types;
|
||||
if (data.map.behaviors['openlayers_behavior_drawfeatures'].element_id != "") {
|
||||
this.element = $('#' + data.map.behaviors['openlayers_behavior_drawfeatures'].element_id);
|
||||
}
|
||||
// Handle vector layer for drawing on
|
||||
this.feature_limit = data.map.behaviors['openlayers_behavior_drawfeatures'].feature_limit;
|
||||
var dataLayer = new OpenLayers.Layer.Vector(Drupal.t('Feature Layer'), {
|
||||
projection: new OpenLayers.Projection('EPSG:4326'),
|
||||
drupalID: 'openlayers_drawfeatures_layer'
|
||||
});
|
||||
dataLayer.styleMap = Drupal.openlayers.getStyleMap(data.map, 'openlayers_drawfeatures_layer');
|
||||
data.openlayers.addLayer(dataLayer);
|
||||
|
||||
if (this.feature_limit == "") {
|
||||
this.feature_limit = 0;
|
||||
}
|
||||
|
||||
// If there is data in there now, use to populate the layer.
|
||||
if ((this.element != undefined) && (this.element.text() != '')) {
|
||||
var wktFormat = new OpenLayers.Format.WKT();
|
||||
var features = wktFormat.read(this.element.text());
|
||||
if (features.constructor == Array) {
|
||||
for (var i in features) {
|
||||
features[i].geometry = features[i].geometry.transform(
|
||||
new OpenLayers.Projection('EPSG:4326'),
|
||||
data.openlayers.projection
|
||||
);
|
||||
}
|
||||
}
|
||||
else {
|
||||
features.geometry = features.geometry.transform(
|
||||
new OpenLayers.Projection('EPSG:4326'),
|
||||
data.openlayers.projection
|
||||
);
|
||||
features = [features];
|
||||
}
|
||||
dataLayer.addFeatures(features);
|
||||
}
|
||||
|
||||
// Registering events late, because adding data
|
||||
// would result in a reprojection loop
|
||||
dataLayer.events.register('featureadded', this,
|
||||
openlayers_behavior_drawfeatures_update);
|
||||
dataLayer.events.register('featureremoved', this,
|
||||
openlayers_behavior_drawfeatures_update);
|
||||
dataLayer.events.register('featuremodified', this,
|
||||
openlayers_behavior_drawfeatures_update);
|
||||
|
||||
// Use the Editing Toolbar for creating features.
|
||||
var control = new OpenLayers.Control.EditingToolbar(dataLayer);
|
||||
data.openlayers.addControl(control);
|
||||
control.activate();
|
||||
|
||||
// Build an array of the requested feature classes
|
||||
var feature_classmap = {
|
||||
'point': 'OpenLayers.Handler.Point',
|
||||
'path': 'OpenLayers.Handler.Path',
|
||||
'polygon': 'OpenLayers.Handler.Polygon'
|
||||
};
|
||||
|
||||
var feature_classes = [];
|
||||
for (var i in feature_types) {
|
||||
if (feature_types[i] !== 0) {
|
||||
feature_classes.push(feature_classmap[feature_types[i]]);
|
||||
}
|
||||
}
|
||||
|
||||
// Reconstruct editing toolbar controls so to only contain
|
||||
// the tools for the requested feature types / classes
|
||||
// plus the navigation tool
|
||||
control.controls = $.map(control.controls,
|
||||
function(control) {
|
||||
return (control.CLASS_NAME == 'OpenLayers.Control.Navigation' ||
|
||||
$.inArray(control.handler.CLASS_NAME, feature_classes) != -1)
|
||||
? control : null;
|
||||
}
|
||||
);
|
||||
|
||||
control.activateControl(control.getControlsByClass('OpenLayers.Control.Navigation')[0]);
|
||||
control.redraw();
|
||||
|
||||
if (this.element != undefined) {
|
||||
this.element.parents('form').bind('submit',
|
||||
{
|
||||
control: control,
|
||||
dataLayer: dataLayer
|
||||
}, function(evt) {
|
||||
$.map(evt.data.control.controls, function(c) { c.deactivate(); });
|
||||
dataLayer.events.triggerEvent('featuremodified');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// Add modify feature tool
|
||||
control.addControls(new OpenLayers.Control.ModifyFeature(
|
||||
dataLayer, {
|
||||
displayClass: 'olControlModifyFeature',
|
||||
deleteCodes: [46, 68, 100],
|
||||
handleKeypress: function(evt) {
|
||||
if (this.feature && $.inArray(evt.keyCode, this.deleteCodes) > -1) {
|
||||
// We must unselect the feature before we delete it
|
||||
var feature_to_delete = this.feature;
|
||||
this.selectControl.unselectAll();
|
||||
this.layer.removeFeatures([feature_to_delete]);
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
);
|
||||
$(context).addClass('openlayers-drawfeatures-processed');
|
||||
}
|
||||
}
|
||||
};
|
||||
})(jQuery);
|
@@ -0,0 +1,25 @@
|
||||
.openlayers_map_fullscreen {
|
||||
position: fixed;
|
||||
z-index: 9999;
|
||||
background-color: #fff;
|
||||
top: 0;
|
||||
left: 0;
|
||||
height: 100% !important;
|
||||
width: 100% !important;
|
||||
}
|
||||
|
||||
.openlayers_behavior_fullscreen_button_panel {
|
||||
position: absolute;
|
||||
top: 5px;
|
||||
right: 5px;
|
||||
}
|
||||
|
||||
.openlayers_behavior_fullscreen_buttonItemInactive {
|
||||
background:url(openlayers_behavior_fullscreen.png);
|
||||
width:20px;
|
||||
height:20px;
|
||||
}
|
||||
|
||||
.openlayers_map_fullscreen .openlayers_behavior_fullscreen_buttonItemInactive {
|
||||
background-position:20px 0;
|
||||
}
|
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Implementation of OpenLayers behavior.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Ctools plugin definition.
|
||||
*/
|
||||
function openlayers_openlayers_behavior_fullscreen_openlayers_behaviors() {
|
||||
return array(
|
||||
'title' => t('Fullscreen'),
|
||||
'description' => t('Provides a button that expands maps to the size of the page.'),
|
||||
'type' => 'map',
|
||||
'behavior' => array(
|
||||
'file' => 'openlayers_behavior_fullscreen.inc',
|
||||
'class' => 'openlayers_behavior_fullscreen',
|
||||
'parent' => 'openlayers_behavior',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fullscreen Behavior
|
||||
*/
|
||||
class openlayers_behavior_fullscreen extends openlayers_behavior {
|
||||
/**
|
||||
* Provide initial values for options.
|
||||
*/
|
||||
function options_init() {
|
||||
return array(
|
||||
'activated' => FALSE
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide form for configurations per map.
|
||||
*/
|
||||
function options_form($defaults = array()) {
|
||||
return array(
|
||||
'activated' => array(
|
||||
'#title' => t('Initially activated'),
|
||||
'#type' => 'checkbox',
|
||||
'#description' => t('Select to be in fullscreen by default.'),
|
||||
'#default_value' => isset($defaults['activated']) ? $defaults['activated'] : FALSE
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
function js_dependency() {
|
||||
return array(
|
||||
'OpenLayers.Control.Button'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render.
|
||||
*/
|
||||
function render(&$map) {
|
||||
drupal_add_css(drupal_get_path('module', 'openlayers') .
|
||||
'/plugins/behaviors/openlayers_behavior_fullscreen.css');
|
||||
drupal_add_js(drupal_get_path('module', 'openlayers') .
|
||||
'/plugins/behaviors/openlayers_behavior_fullscreen.js');
|
||||
return $this->options;
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
* @file
|
||||
* JS Implementation of OpenLayers behavior.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Attribution Behavior
|
||||
*/
|
||||
Drupal.openlayers.addBehavior('openlayers_behavior_fullscreen', function (data, options) {
|
||||
// Create new panel control and add.
|
||||
var fullscreenPanel = new OpenLayers.Control.Panel({
|
||||
displayClass: 'openlayers_behavior_fullscreen_button_panel'
|
||||
});
|
||||
data.openlayers.addControl(fullscreenPanel);
|
||||
|
||||
// Create toggleing control and cutton.
|
||||
var toggler = OpenLayers.Function.bind(
|
||||
Drupal.openlayers.fullscreenToggle, data);
|
||||
var button = new OpenLayers.Control.Button({
|
||||
displayClass: 'openlayers_behavior_fullscreen_button',
|
||||
title: Drupal.t('Fullscreen'),
|
||||
trigger: toggler
|
||||
});
|
||||
fullscreenPanel.addControls([button]);
|
||||
|
||||
// Make fullscreen by default if activited.
|
||||
if (options.activated == true) {
|
||||
toggler();
|
||||
}
|
||||
});
|
||||
|
||||
(function ($) {
|
||||
/**
|
||||
* Toggling function for FullScreen control.
|
||||
*/
|
||||
Drupal.openlayers.fullscreenToggle = function () {
|
||||
var map = this.openlayers;
|
||||
var $map = $(this.openlayers.div);
|
||||
var extent = map.getExtent();
|
||||
|
||||
$map.parent().toggleClass('openlayers_map_fullscreen');
|
||||
$map.toggleClass('openlayers_map_fullscreen');
|
||||
$map.data('openlayers').openlayers.updateSize();
|
||||
$map.data('openlayers').openlayers.zoomToExtent(extent, true);
|
||||
};
|
||||
}(jQuery));
|
Binary file not shown.
After Width: | Height: | Size: 663 B |
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Implementation of OpenLayers behavior.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Ctools plugin definition.
|
||||
*/
|
||||
function openlayers_openlayers_behavior_geolocate_openlayers_behaviors() {
|
||||
return array(
|
||||
'title' => t('Geolocate Client'),
|
||||
'description' => t('Provides the geolcoation control that simply zooms to users location on map load. Based on HTML5 geolocation, so this will not be supported in all browsers.'),
|
||||
'type' => 'map',
|
||||
'behavior' => array(
|
||||
'file' => 'openlayers_behavior_geolocate.inc',
|
||||
'class' => 'openlayers_behavior_geolocate',
|
||||
'parent' => 'openlayers_behavior',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Zoom Panel Behavior
|
||||
* http://dev.openlayers.org/docs/files/OpenLayers/Control/Geolocate-js.html
|
||||
*/
|
||||
class openlayers_behavior_geolocate extends openlayers_behavior {
|
||||
/**
|
||||
* Provide initial values for options.
|
||||
*/
|
||||
function options_init() {
|
||||
return array(
|
||||
'bind' => TRUE,
|
||||
'watch' => FALSE,
|
||||
'geolocationOptions' => array(
|
||||
'enableHighAccuracy' => FALSE,
|
||||
'maximumAge' => 0,
|
||||
'timeout' => 7000,
|
||||
),
|
||||
'zoom_level' => 12,
|
||||
);
|
||||
}
|
||||
|
||||
function options_form($defaults = array()) {
|
||||
$intials = $this->options_init();
|
||||
|
||||
return array(
|
||||
'bind' => array(
|
||||
'#title' => t('Center when located'),
|
||||
'#type' => 'select',
|
||||
'#options' => array(
|
||||
TRUE => t('Yes'),
|
||||
FALSE => t('No'),
|
||||
),
|
||||
'#description' => t('When enabled, if the geolocation control finds a location, it will set the center of the map at this point.'),
|
||||
'#default_value' => isset($defaults['bind']) ? $defaults['bind'] : $intials['bind'],
|
||||
),
|
||||
'zoom_level' => array(
|
||||
'#title' => t('Zoom level'),
|
||||
'#type' => 'textfield',
|
||||
'#description' => t('An integer zoom level for when a location is found. 0 is the most zoomed out and higher numbers mean more zoomed in (the number of zoom levels depends on your map).'),
|
||||
'#default_value' => isset($defaults['zoom_level']) ? $defaults['zoom_level'] : $intials['zoom_level'],
|
||||
),
|
||||
'watch' => array(
|
||||
'#title' => t('Watch'),
|
||||
'#type' => 'select',
|
||||
'#options' => array(
|
||||
TRUE => t('Yes'),
|
||||
FALSE => t('No'),
|
||||
),
|
||||
'#description' => t('When enabled, the map will continue to try to update the location of the device.'),
|
||||
'#default_value' => isset($defaults['watch']) ? $defaults['watch'] : $intials['watch'],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
function js_dependency() {
|
||||
return array(
|
||||
'OpenLayers.Control.Geolocate'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render.
|
||||
*/
|
||||
function render(&$map) {
|
||||
drupal_add_js(drupal_get_path('module', 'openlayers') .
|
||||
'/plugins/behaviors/openlayers_behavior_geolocate.js');
|
||||
return $this->options;
|
||||
}
|
||||
}
|
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* @file
|
||||
* JS Implementation of OpenLayers behavior.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Geolocate Control. Implements the Geolocate OpenLayers
|
||||
* Control.
|
||||
*/
|
||||
Drupal.openlayers.addBehavior('openlayers_behavior_geolocate', function (data, options) {
|
||||
// Create Geolocate control
|
||||
var geolocate = new OpenLayers.Control.Geolocate(options);
|
||||
data.openlayers.addControl(geolocate);
|
||||
|
||||
// Adding the watch options.
|
||||
// {Boolean} If true, position will be update regularly.
|
||||
geolocate.watch = (options.watch == 1) ? true : false;
|
||||
|
||||
// Add some event handling
|
||||
geolocate.events.register('locationupdated', this, function(e) {
|
||||
data.openlayers.setCenter(new OpenLayers.Geometry.Point(e.point.x, e.point.y), options.zoom_level);
|
||||
});
|
||||
geolocate.events.register('locationfailed', this, function(e) {
|
||||
OpenLayers.Console.log(Drupal.t('Location detection failed'));
|
||||
});
|
||||
|
||||
// Activate!
|
||||
geolocate.activate();
|
||||
});
|
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Implementation of OpenLayers behavior.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Ctools plugin definition.
|
||||
*/
|
||||
function openlayers_openlayers_behavior_graticule_openlayers_behaviors() {
|
||||
return array(
|
||||
'title' => t('Graticule'),
|
||||
'description' => t('Adds a graticule control to the map to display a grid of latitude and longitude.'),
|
||||
'type' => 'layer',
|
||||
'behavior' => array(
|
||||
'file' => 'openlayers_behavior_graticule.inc',
|
||||
'class' => 'openlayers_behavior_graticule',
|
||||
'parent' => 'openlayers_behavior',
|
||||
),
|
||||
);
|
||||
}
|
||||
/**
|
||||
* Attribution Behavior
|
||||
*/
|
||||
class openlayers_behavior_graticule extends openlayers_behavior {
|
||||
/**
|
||||
* Provide initial values for options.
|
||||
*/
|
||||
function options_init() {
|
||||
return array(
|
||||
'labelled' => TRUE,
|
||||
'numPoints' => 50,
|
||||
'targetSize' => 200,
|
||||
'displayInLayerSwitcher' => TRUE,
|
||||
'lineSymbolizer' => array(
|
||||
'strokeColor' => '#333',
|
||||
'strokeWidth' => 1,
|
||||
'strokeOpacity' => 0.5
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
function options_form($defaults = array()) {
|
||||
return array(
|
||||
'displayInLayerSwitcher' => array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Display in layer switcher ?'),
|
||||
'#description' => t('Allows the Graticule control to be switched on and off by LayerSwitcher control. Default is true.'),
|
||||
'#default_value' => (isset($defaults['displayInLayerSwitcher'])) ? $defaults['displayInLayerSwitcher'] : TRUE,
|
||||
),
|
||||
'labelled' => array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Labelled'),
|
||||
'#description' => t('Should the graticule lines be labelled ? Default is true.'),
|
||||
'#default_value' => (isset($defaults['labelled'])) ? $defaults['labelled'] : TRUE,
|
||||
),
|
||||
'numPoints' => array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Number of points'),
|
||||
'#description' => t('The number of points to use in each graticule line. Higher numbers result in a smoother curve for projected maps '),
|
||||
'#default_value' => (isset($defaults['numPoints'])) ? $defaults['numPoints'] : 50,
|
||||
),
|
||||
'targetSize' => array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Target size'),
|
||||
'#description' => t('The maximum size of the grid in pixels on the map.'),
|
||||
'#default_value' => (isset($defaults['targetSize'])) ? $defaults['targetSize'] : 200,
|
||||
),
|
||||
'lineSymbolizer' => array(
|
||||
'strokeColor' => array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Stroke color'),
|
||||
'#description' => t('The color code to use for the lines. Example: #333'),
|
||||
'#default_value' => (isset($defaults['lineSymbolizer']['strokeColor'])) ? $defaults['lineSymbolizer']['strokeColor'] : '#333',
|
||||
),
|
||||
'strokeWidth' => array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Stroke width'),
|
||||
'#description' => t('The width of the lines. Example: 1'),
|
||||
'#default_value' => (isset($defaults['lineSymbolizer']['strokeWidth'])) ? $defaults['lineSymbolizer']['strokeWidth'] : 1,
|
||||
),
|
||||
'strokeOpacity' => array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Stroke opacity'),
|
||||
'#description' => t('The opacity of the line, from 0 to 1. Example: 0.5'),
|
||||
'#default_value' => (isset($defaults['lineSymbolizer']['strokeOpacity'])) ? $defaults['lineSymbolizer']['strokeOpacity'] : 0.5,
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render.
|
||||
*/
|
||||
function render(&$map) {
|
||||
drupal_add_js(drupal_get_path('module', 'openlayers') .
|
||||
'/plugins/behaviors/openlayers_behavior_graticule.js');
|
||||
return $this->options;
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
/**
|
||||
* @file
|
||||
* JS Implementation of OpenLayers behavior.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Graticule Behavior. Implements the Graticule Control.
|
||||
*/
|
||||
Drupal.openlayers.addBehavior('openlayers_behavior_graticule', function (data, options) {
|
||||
Drupal.openlayers.addControl(data.openlayers, 'Graticule', options);
|
||||
});
|
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Implementation of OpenLayers behavior.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Ctools plugin definition.
|
||||
*/
|
||||
function openlayers_openlayers_behavior_keyboarddefaults_openlayers_behaviors() {
|
||||
return array(
|
||||
'title' => t('Keyboard Controls'),
|
||||
'description' => t('Provides keyboard shortcuts to pan and zoom the map, such as the up, down, left, and right arrows. This is included with the Navigation control. This should not be enabled unless you want to have finer control on how the user interacts with the map.'),
|
||||
'type' => 'layer',
|
||||
'behavior' => array(
|
||||
'file' => 'openlayers_behavior_keyboarddefaults.inc',
|
||||
'class' => 'openlayers_behavior_keyboarddefaults',
|
||||
'parent' => 'openlayers_behavior',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Keyboard Defaults Behavior
|
||||
*/
|
||||
class openlayers_behavior_keyboarddefaults extends openlayers_behavior {
|
||||
/**
|
||||
* Provide initial values for options.
|
||||
*/
|
||||
function options_init() {
|
||||
return array(
|
||||
'keyboarddefaults' => '',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render.
|
||||
*/
|
||||
function render(&$map) {
|
||||
drupal_add_js(drupal_get_path('module', 'openlayers') .
|
||||
'/plugins/behaviors/openlayers_behavior_keyboarddefaults.js');
|
||||
return $this->options;
|
||||
}
|
||||
}
|
@@ -0,0 +1,13 @@
|
||||
|
||||
/**
|
||||
* @file
|
||||
* JS Implementation of OpenLayers behavior.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Keyboard Defaults Behavior. Implements the KeyboardDefaults OpenLayers
|
||||
* Control.
|
||||
*/
|
||||
Drupal.openlayers.addBehavior('openlayers_behavior_keyboarddefaults', function (data, options) {
|
||||
Drupal.openlayers.addControl(data.openlayers, 'KeyboardDefaults');
|
||||
});
|
@@ -0,0 +1,104 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Implementation of OpenLayers behavior.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Ctools plugin definition.
|
||||
*/
|
||||
function openlayers_openlayers_behavior_layerswitcher_openlayers_behaviors() {
|
||||
return array(
|
||||
'title' => t('Layer Switcher'),
|
||||
'description' => t('Provides the ability to switch layers in the map interface. This provides an expandable box on the map to enable and disable layers.'),
|
||||
'type' => 'map',
|
||||
'behavior' => array(
|
||||
'file' => 'openlayers_behavior_layerswitcher.inc',
|
||||
'class' => 'openlayers_behavior_layerswitcher',
|
||||
'parent' => 'openlayers_behavior',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Layer Switcher Behavior
|
||||
*/
|
||||
class openlayers_behavior_layerswitcher extends openlayers_behavior {
|
||||
/**
|
||||
* Provide initial values for options.
|
||||
*/
|
||||
function options_init() {
|
||||
return array(
|
||||
'layerswitcher' => '',
|
||||
'ascending' => TRUE,
|
||||
'sortBaseLayer' => '0',
|
||||
'roundedCorner' => TRUE,
|
||||
'roundedCornerColor' => '#222222',
|
||||
'maximizeDefault' => FALSE,
|
||||
);
|
||||
}
|
||||
|
||||
function js_dependency() {
|
||||
return array('OpenLayers.Control.LayerSwitcher');
|
||||
}
|
||||
|
||||
function options_form($defaults = array()) {
|
||||
return array(
|
||||
'ascending' => array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Show layers in ascending order'),
|
||||
'#description' => t('Higher layers shown toward the bottom'),
|
||||
'#default_value' => isset($defaults['ascending']) ? $defaults['ascending'] : TRUE,
|
||||
),
|
||||
'sortBaseLayer' => array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Sort Base Layers by Title'),
|
||||
'#description' => t('Display the layers in the layer switcher by title'),
|
||||
'#default_value' => isset($defaults['sortBaseLayer']) ? $defaults['sortBaseLayer'] : 0,
|
||||
'#options' => array('0' => t('- None -'), 'ASC' => t('ASC'), 'DESC' => 'DESC'),
|
||||
),
|
||||
'roundedCorner' => array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Rounded corners'),
|
||||
'#description' => t('If true the Rico library is used for rounding the corners of the layer switcher box.'),
|
||||
'#default_value' => isset($defaults['roundedCorner']) ? $defaults['roundedCorner'] : TRUE,
|
||||
),
|
||||
'roundedCornerColor' => array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Rounded corners color'),
|
||||
'#description' => t('For rounded corners, this is the CSS color to use for the corners.'),
|
||||
'#default_value' => isset($defaults['roundedCornerColor']) ? $defaults['roundedCornerColor'] : '#222222',
|
||||
),
|
||||
'maximizeDefault' => array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Maximize by Default'),
|
||||
'#description' => t('Turn on to have the Layer Switcher open by default.'),
|
||||
'#default_value' => isset($defaults['maximizeDefault']) ? $defaults['maximizeDefault'] : FALSE,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render.
|
||||
*/
|
||||
function render(&$map) {
|
||||
// Legacy code for maps not using the default images now
|
||||
// provided with the code, or for maps that dont have images
|
||||
// set. We have to set the rounded corner color and add a
|
||||
// class for CSS to style
|
||||
if (empty($map['image_path'])) {
|
||||
$this->options['roundedCornerColor'] = 'darkblue';
|
||||
$this->options['displayClass'] = 'olControlLayerSwitcher legacy';
|
||||
}
|
||||
if ($this->options['sortBaseLayer'] == 'ASC' || $this->options['sortBaseLayer'] == 'DESC') {
|
||||
uasort($map['layers'], 'drupal_sort_title');
|
||||
if ($this->options['sortBaseLayer'] == 'ASC') {
|
||||
$map['layers'] = array_reverse ($map['layers'], TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
drupal_add_js(drupal_get_path('module', 'openlayers') .
|
||||
'/plugins/behaviors/openlayers_behavior_layerswitcher.js');
|
||||
return $this->options;
|
||||
}
|
||||
}
|
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* @file
|
||||
* JS Implementation of OpenLayers behavior.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Layer Switcher Behavior
|
||||
*/
|
||||
Drupal.openlayers.addBehavior('openlayers_behavior_layerswitcher', function (data, options) {
|
||||
options.ascending = !! options.ascending;
|
||||
Drupal.openlayers.addControl(data.openlayers, 'LayerSwitcher', options);
|
||||
|
||||
// Maximize if needed.
|
||||
if (!! options.maximizeDefault == true) {
|
||||
data.openlayers.getControlsByClass('OpenLayers.Control.LayerSwitcher')[0].maximizeControl();
|
||||
}
|
||||
});
|
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Implementation of OpenLayers behavior.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Ctools plugin definition.
|
||||
*/
|
||||
|
||||
function openlayers_openlayers_behavior_layerzoom_openlayers_behaviors() {
|
||||
return array(
|
||||
'title' => t('Zoom restrictions for non-base layers.'),
|
||||
'description' => t('Enables restriction of layer display based on zoom level.'),
|
||||
'type' => 'layer',
|
||||
'behavior' => array(
|
||||
'file' => 'openlayers_behavior_layerzoom.inc',
|
||||
'class' => 'openlayers_behavior_layerzoom',
|
||||
'parent' => 'openlayers_behavior',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Attribution Behavior
|
||||
*/
|
||||
class openlayers_behavior_layerzoom extends openlayers_behavior {
|
||||
|
||||
function options_form($defaults = array()) {
|
||||
$options = array();
|
||||
|
||||
foreach ($this->map['layers'] as $layer) {
|
||||
if ($layer != $this->map['default_layer']) {
|
||||
$options[$layer] = array(
|
||||
'enable' => array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Enable dynamic zoom levels for @layer', array('@layer' => $layer)),
|
||||
'#default_value' => isset($this->options[$layer]['enable']) ? $this->options[$layer]['enable'] : 0,
|
||||
),
|
||||
'resolutions' => array(
|
||||
'#type' => 'select',
|
||||
'#multiple' => TRUE,
|
||||
'#options' => array_combine(
|
||||
array_map('strval', openlayers_get_resolutions('900913')),
|
||||
range(0, 21)
|
||||
),
|
||||
'#title' => t('Zoom Level Range for @layer', array('@layer' => $layer)),
|
||||
'#default_value' => isset($this->options[$layer]['resolutions']) ?
|
||||
$this->options[$layer]['resolutions'] :
|
||||
array_map('strval', openlayers_get_resolutions('900913')),
|
||||
'#description' => t('The zoom levels at which this layer will display.'),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render.
|
||||
*/
|
||||
function render(&$map) {
|
||||
drupal_add_js(drupal_get_path('module', 'openlayers') .
|
||||
'/plugins/behaviors/openlayers_behavior_layerzoom.js');
|
||||
return $this->options;
|
||||
}
|
||||
}
|
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* @file
|
||||
* JS Implementation of OpenLayers behavior.
|
||||
*/
|
||||
|
||||
/**
|
||||
* OpenLayers Zoom to Layer Behavior
|
||||
*/
|
||||
Drupal.openlayers.addBehavior('openlayers_behavior_layerzoom', function (data, options) {
|
||||
var map = data.openlayers;
|
||||
for (var layerName in options) {
|
||||
if (options[layerName].enable) {
|
||||
var layers = map.getLayersBy('drupalID', layerName);
|
||||
// Go through selected layers to get full extent.
|
||||
for (var i in layers) {
|
||||
layer = layers[i];
|
||||
// Restrict zoom levels.
|
||||
var keys = Object.keys(options[layerName].resolutions);
|
||||
layer.alwaysInRange = false;
|
||||
layer.minResolution = options[layerName].resolutions[keys[keys.length-1]];
|
||||
layer.maxResolution = options[layerName].resolutions[keys[0]];
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Implementation of OpenLayers behavior.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Ctools plugin definition.
|
||||
*/
|
||||
function openlayers_openlayers_behavior_mapformvalues_openlayers_behaviors() {
|
||||
return array(
|
||||
'title' => t('Map Form Values'),
|
||||
'description' => t('Provides a way of updating form elements with zoom level and centering from a map.'),
|
||||
'type' => 'map',
|
||||
'ui_visibility' => FALSE,
|
||||
'behavior' => array(
|
||||
'file' => 'openlayers_behavior_mapformvalues.inc',
|
||||
'class' => 'openlayers_behavior_mapformvalues',
|
||||
'parent' => 'openlayers_behavior',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Map Form Values Behavior
|
||||
*/
|
||||
class openlayers_behavior_mapformvalues extends openlayers_behavior {
|
||||
/**
|
||||
* Provide initial values for options.
|
||||
*/
|
||||
function options_init() {
|
||||
return array(
|
||||
'center_form' => '#edit-center-initial-centerpoint',
|
||||
'zoom_form' => '#edit-center-initial-zoom'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render.
|
||||
*/
|
||||
function render(&$map) {
|
||||
drupal_add_js(drupal_get_path('module', 'openlayers') .
|
||||
'/plugins/behaviors/openlayers_behavior_mapformvalues.js');
|
||||
return $this->options;
|
||||
}
|
||||
}
|
@@ -0,0 +1,44 @@
|
||||
/**
|
||||
* @file
|
||||
* JS Implementation of OpenLayers behavior.
|
||||
*/
|
||||
|
||||
(function ($) {
|
||||
/**
|
||||
* Map Form Values Behavior
|
||||
*/
|
||||
Drupal.openlayers.addBehavior('openlayers_behavior_mapformvalues', function (data, options) {
|
||||
function updateForm(evt) {
|
||||
if (evt.object.centerpoint_form) {
|
||||
center = evt.object.getCenter().transform(
|
||||
evt.object.projection,
|
||||
new OpenLayers.Projection('EPSG:4326')).toShortString();
|
||||
evt.object.centerpoint_form.val(center);
|
||||
}
|
||||
if (evt.object.zoom_form) {
|
||||
zoom = evt.object.getZoom();
|
||||
evt.object.zoom_form.val(zoom);
|
||||
}
|
||||
}
|
||||
centerpoint_form = $(options.center_form);
|
||||
zoom_form = $(options.zoom_form);
|
||||
|
||||
if (centerpoint_form.length) {
|
||||
data.openlayers.centerpoint_form = centerpoint_form;
|
||||
center_point = centerpoint_form.val();
|
||||
data.openlayers.setCenter(
|
||||
OpenLayers.LonLat.fromString(center_point).transform(
|
||||
new OpenLayers.Projection('EPSG:4326'),
|
||||
data.openlayers.projection)
|
||||
);
|
||||
}
|
||||
|
||||
if (zoom_form.length) {
|
||||
data.openlayers.zoom_form = zoom_form;
|
||||
zoom = zoom_form.val();
|
||||
data.openlayers.zoomTo(parseInt(zoom));
|
||||
}
|
||||
|
||||
data.openlayers.events.on({'moveend': updateForm});
|
||||
});
|
||||
}(jQuery));
|
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Implementation of OpenLayers behavior.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Ctools plugin definition.
|
||||
*/
|
||||
function openlayers_openlayers_behavior_mouseposition_openlayers_behaviors() {
|
||||
return array(
|
||||
'title' => t('Mouse Position'),
|
||||
'description' => t('Provides a visual indication of the mouse position to the user.'),
|
||||
'type' => 'map',
|
||||
'behavior' => array(
|
||||
'file' => 'openlayers_behavior_mouseposition.inc',
|
||||
'class' => 'openlayers_behavior_mouseposition',
|
||||
'parent' => 'openlayers_behavior',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Mouse Position Behavior
|
||||
*/
|
||||
class openlayers_behavior_mouseposition extends openlayers_behavior {
|
||||
/**
|
||||
* Provide initial values for options.
|
||||
*/
|
||||
function options_init() {
|
||||
return array(
|
||||
'prefix' => '',
|
||||
'separator' => ', ',
|
||||
'suffix' => '',
|
||||
'numDigits' => 4,
|
||||
'emptyString' => '',
|
||||
);
|
||||
}
|
||||
|
||||
function js_dependency() {
|
||||
return array('OpenLayers.Control.MousePosition');
|
||||
}
|
||||
|
||||
function options_form($defaults = array()) {
|
||||
return array(
|
||||
'prefix' => array(
|
||||
'#title' => t('Prefix'),
|
||||
'#type' => 'textfield',
|
||||
'#description' => t('A textual prefix to the mouse position.'),
|
||||
'#default_value' => isset($defaults['prefix']) ? $defaults['prefix'] : '',
|
||||
),
|
||||
'separator' => array(
|
||||
'#title' => t('Separator'),
|
||||
'#type' => 'textfield',
|
||||
'#description' => t('A textual separator between the first and second value.'),
|
||||
'#default_value' => isset($defaults['separator']) ? $defaults['separator'] : ', ',
|
||||
),
|
||||
'suffix' => array(
|
||||
'#title' => t('Suffix'),
|
||||
'#type' => 'textfield',
|
||||
'#description' => t('A textual suffix to the mouse position.'),
|
||||
'#default_value' => isset($defaults['suffix']) ? $defaults['suffix'] : '',
|
||||
),
|
||||
'numDigits' => array(
|
||||
'#title' => t('Number of Decimal Digits'),
|
||||
'#type' => 'textfield',
|
||||
'#description' => t('Number of decimal digits to show.'),
|
||||
'#default_value' => isset($defaults['numDigits']) ? $defaults['numDigits'] : '',
|
||||
),
|
||||
'emptyString' => array(
|
||||
'#title' => t('Empty Value'),
|
||||
'#type' => 'textfield',
|
||||
'#description' => t('What will be seen if there is no value for the mouse position.'),
|
||||
'#default_value' => isset($defaults['emptyString']) ? $defaults['emptyString'] : '',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render.
|
||||
*/
|
||||
function render(&$map) {
|
||||
drupal_add_js(drupal_get_path('module', 'openlayers') .
|
||||
'/plugins/behaviors/openlayers_behavior_mouseposition.js');
|
||||
return $this->options;
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
/**
|
||||
* @file
|
||||
* JS Implementation of OpenLayers behavior.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Mouse Position Behavior
|
||||
*/
|
||||
Drupal.openlayers.addBehavior('openlayers_behavior_mouseposition', function (data, options) {
|
||||
Drupal.openlayers.addControl(data.openlayers, 'MousePosition', options);
|
||||
});
|
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Implementation of OpenLayers behavior.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Ctools plugin definition.
|
||||
*/
|
||||
function openlayers_openlayers_behavior_navigation_openlayers_behaviors() {
|
||||
return array(
|
||||
'title' => t('Navigation'),
|
||||
'description' => t('Provides the ability to navigate the map interface. This is just for user interactions and does not show any visual controls. This behavior automatically includes the Pan Zoom, Zoom Box, and Pinch Zoom controls.'),
|
||||
'type' => 'map',
|
||||
'behavior' => array(
|
||||
'file' => 'openlayers_behavior_navigation.inc',
|
||||
'class' => 'openlayers_behavior_navigation',
|
||||
'parent' => 'openlayers_behavior',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Navigation Behavior
|
||||
*/
|
||||
class openlayers_behavior_navigation extends openlayers_behavior {
|
||||
/**
|
||||
* Provide initial values for options.
|
||||
*/
|
||||
function options_init() {
|
||||
return array(
|
||||
'navigation' => '',
|
||||
'zoomWheelEnabled' => TRUE,
|
||||
'zoomBoxEnabled' => TRUE,
|
||||
'documentDrag' => FALSE,
|
||||
);
|
||||
}
|
||||
|
||||
function js_dependency() {
|
||||
return array('OpenLayers.Control.Navigation');
|
||||
}
|
||||
|
||||
function options_form($defaults = array()) {
|
||||
return array(
|
||||
'zoomWheelEnabled' => array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Enable Zoom Wheel'),
|
||||
'#description' => t('Enable zooming via the mouse scroll wheel. This can
|
||||
interfere with page scrolling.'),
|
||||
'#default_value' => isset($defaults['zoomWheelEnabled']) ? $defaults['zoomWheelEnabled'] : TRUE
|
||||
),
|
||||
'zoomBoxEnabled' => array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Enable Zoom Box'),
|
||||
'#description' => t('Enable zooming with selecting a box by <em>SHIFT + clicking</em>.'),
|
||||
'#default_value' => isset($defaults['zoomBoxEnabled']) ? $defaults['zoomBoxEnabled'] : TRUE
|
||||
),
|
||||
'documentDrag' => array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Document Drag'),
|
||||
'#description' => t('Allow panning of the map by dragging outside map viewport.'),
|
||||
'#default_value' => isset($defaults['documentDrag']) ? $defaults['documentDrag'] : FALSE
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render.
|
||||
*/
|
||||
function render(&$map) {
|
||||
drupal_add_js(drupal_get_path('module', 'openlayers') .
|
||||
'/plugins/behaviors/openlayers_behavior_navigation.js');
|
||||
return $this->options;
|
||||
}
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
/**
|
||||
* @file
|
||||
* JS Implementation of OpenLayers behavior.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Navigation Behavior
|
||||
*/
|
||||
Drupal.openlayers.addBehavior('openlayers_behavior_navigation', function (data, options) {
|
||||
options.documentDrag = !!options.documentDrag;
|
||||
Drupal.openlayers.addControl(data.openlayers, 'Navigation', options);
|
||||
});
|
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Implementation of OpenLayers behavior.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Ctools plugin definition.
|
||||
*/
|
||||
function openlayers_openlayers_behavior_panzoom_openlayers_behaviors() {
|
||||
return array(
|
||||
'title' => t('Pan and Zoom Control'),
|
||||
'description' => t('Provides controls with the ability to pan and zoom in the map interface. Do not use with the Pan Zoom Bar Control or the Zoom Panel Control.'),
|
||||
'type' => 'map',
|
||||
'behavior' => array(
|
||||
'file' => 'openlayers_behavior_panzoom.inc',
|
||||
'class' => 'openlayers_behavior_panzoom',
|
||||
'parent' => 'openlayers_behavior',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Pan Zoom Bar Behavior
|
||||
*/
|
||||
class openlayers_behavior_panzoom extends openlayers_behavior {
|
||||
/**
|
||||
* Provide initial values for options.
|
||||
*/
|
||||
function options_init() {
|
||||
return array(
|
||||
'panzoom' => '',
|
||||
);
|
||||
}
|
||||
|
||||
function options_form($defaults = array()) {
|
||||
return array(
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render.
|
||||
*/
|
||||
function render(&$map) {
|
||||
drupal_add_js(drupal_get_path('module', 'openlayers') .
|
||||
'/plugins/behaviors/openlayers_behavior_panzoom.js');
|
||||
return $this->options;
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
/**
|
||||
* @file
|
||||
* JS Implementation of OpenLayers behavior.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Pan Zoom Bar Behavior
|
||||
*/
|
||||
Drupal.openlayers.addBehavior('openlayers_behavior_panzoom', function (data, options) {
|
||||
Drupal.openlayers.addControl(data.openlayers, 'PanZoom');
|
||||
});
|
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Implementation of OpenLayers behavior.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Ctools plugin definition.
|
||||
*/
|
||||
function openlayers_openlayers_behavior_panzoombar_openlayers_behaviors() {
|
||||
return array(
|
||||
'title' => t('Pan and Zoom Bar Controls'),
|
||||
'description' => t('Gives user ability to pan and zoom, with a full zoom bar in the map interface. Do not use with Pan Zoom Contols or Zoom Panel Controls.'),
|
||||
'type' => 'map',
|
||||
'behavior' => array(
|
||||
'file' => 'openlayers_behavior_panzoombar.inc',
|
||||
'class' => 'openlayers_behavior_panzoombar',
|
||||
'parent' => 'openlayers_behavior',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Pan Zoom Bar Behavior
|
||||
*/
|
||||
class openlayers_behavior_panzoombar extends openlayers_behavior {
|
||||
/**
|
||||
* Provide initial values for options.
|
||||
*/
|
||||
function options_init() {
|
||||
return array(
|
||||
'zoomWorldIcon' => FALSE,
|
||||
'panIcons' => TRUE,
|
||||
);
|
||||
}
|
||||
|
||||
function js_dependency() {
|
||||
return array('OpenLayers.Control.PanZoomBar');
|
||||
}
|
||||
|
||||
function options_form($defaults = array()) {
|
||||
return array(
|
||||
'zoomWorldIcon' => array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('World Icon'),
|
||||
'#description' => t('This puts the world icon in the pan controls. This button will zoom to the max extent when it is pressed.'),
|
||||
'#default_value' => isset($defaults['zoomWorldIcon']) ? $defaults['zoomWorldIcon'] : FALSE
|
||||
),
|
||||
'panIcons' => array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Pan Icons'),
|
||||
'#description' => t('Enable the pan controls. Without it, then the user will only see a zoom bar.'),
|
||||
'#default_value' => isset($defaults['panIcons']) ? $defaults['panIcons'] : TRUE
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render.
|
||||
*/
|
||||
function render(&$map) {
|
||||
drupal_add_js(drupal_get_path('module', 'openlayers') .
|
||||
'/plugins/behaviors/openlayers_behavior_panzoombar.js');
|
||||
return $this->options;
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
/**
|
||||
* @file
|
||||
* JS Implementation of OpenLayers behavior.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Pan Zoom Bar Behavior
|
||||
*/
|
||||
Drupal.openlayers.addBehavior('openlayers_behavior_panzoombar', function (data, options) {
|
||||
Drupal.openlayers.addControl(data.openlayers, 'PanZoomBar', options);
|
||||
});
|
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Implementation of OpenLayers behavior.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Ctools plugin definition.
|
||||
*/
|
||||
function openlayers_openlayers_behavior_permalink_openlayers_behaviors() {
|
||||
return array(
|
||||
'title' => t('Permalink'),
|
||||
'description' => t('Provides a link that will create an URL that will link to a specific map position. Permalink is usually similar to: ?zoom=1&lat=11&lon=11&layers=B0F'),
|
||||
'type' => 'map',
|
||||
'behavior' => array(
|
||||
'file' => 'openlayers_behavior_permalink.inc',
|
||||
'class' => 'openlayers_behavior_permalink',
|
||||
'parent' => 'openlayers_behavior',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* PermaLink Behavior
|
||||
*/
|
||||
class openlayers_behavior_permalink extends openlayers_behavior {
|
||||
/**
|
||||
* Provide initial values for options.
|
||||
*/
|
||||
function options_init() {
|
||||
return array(
|
||||
'anchor' => FALSE,
|
||||
);
|
||||
}
|
||||
|
||||
function js_dependency() {
|
||||
return array('OpenLayers.Control.Permalink');
|
||||
}
|
||||
|
||||
function options_form($defaults = array()) {
|
||||
return array(
|
||||
'anchor' => array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Anchor'),
|
||||
'#description' => t('Permalink is in the form of an anchor (#) instead of a query (?). Also, this means that the URL location will be constantly updated, and no link will appear.'),
|
||||
'#default_value' => (isset($defaults['anchor'])) ? $defaults['anchor'] : FALSE,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render.
|
||||
*/
|
||||
function render(&$map) {
|
||||
drupal_add_js(drupal_get_path('module', 'openlayers') .
|
||||
'/plugins/behaviors/openlayers_behavior_permalink.js');
|
||||
return $this->options;
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
/**
|
||||
* @file
|
||||
* JS Implementation of OpenLayers behavior.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Permalink Behavior
|
||||
*/
|
||||
Drupal.openlayers.addBehavior('openlayers_behavior_permalink', function (data, options) {
|
||||
Drupal.openlayers.addControl(data.openlayers, 'Permalink', options);
|
||||
});
|
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Implementation of OpenLayers behavior.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Ctools plugin definition.
|
||||
*/
|
||||
function openlayers_openlayers_behavior_popup_openlayers_behaviors() {
|
||||
return array(
|
||||
'title' => t('Pop Up for Features'),
|
||||
'description' => t('Adds clickable info boxes to points or shapes on maps. This does not work with the Tooltip behavior due to limitation of event handling in the OpenLayers library.'),
|
||||
'type' => 'layer',
|
||||
'behavior' => array(
|
||||
'file' => 'openlayers_behavior_popup.inc',
|
||||
'class' => 'openlayers_behavior_popup',
|
||||
'parent' => 'openlayers_behavior',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Attribution Behavior
|
||||
*/
|
||||
class openlayers_behavior_popup extends openlayers_behavior {
|
||||
/**
|
||||
* Provide initial values for options.
|
||||
*/
|
||||
function options_init() {
|
||||
return array(
|
||||
'layers' => array(),
|
||||
'panMapIfOutOfView' => FALSE,
|
||||
'keepInMap' => TRUE,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Form defintion for per map customizations.
|
||||
*/
|
||||
function options_form($defaults = array()) {
|
||||
// Only prompt for vector layers
|
||||
$vector_layers = array();
|
||||
foreach ($this->map['layers'] as $id => $name) {
|
||||
$layer = openlayers_layer_load($id);
|
||||
if (isset($layer->data['vector']) && $layer->data['vector'] == TRUE) {
|
||||
$vector_layers[$id] = $name;
|
||||
}
|
||||
}
|
||||
|
||||
return array(
|
||||
'layers' => array(
|
||||
'#title' => t('Layers'),
|
||||
'#type' => 'checkboxes',
|
||||
'#options' => $vector_layers,
|
||||
'#description' => t('Select layer to apply popups to.'),
|
||||
'#default_value' => isset($defaults['layers']) ?
|
||||
$defaults['layers'] : array(),
|
||||
),
|
||||
'panMapIfOutOfView' => array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Pan map if popup out of view'),
|
||||
'#description' => t('When drawn, pan map such that the entire popup is visible in the current viewport (if necessary).'),
|
||||
'#default_value' => isset($defaults['panMapIfOutOfView']) ? $defaults['panMapIfOutOfView'] : FALSE
|
||||
),
|
||||
'keepInMap' => array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Keep in map'),
|
||||
'#description' => t('If panMapIfOutOfView is false, and this property is true, contrain the popup such that it always fits in the available map space.'),
|
||||
'#default_value' => isset($defaults['keepInMap']) ? $defaults['keepInMap'] : TRUE
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render.
|
||||
*/
|
||||
function render(&$map) {
|
||||
// Put weight on JS so that we know navigation is included already as this
|
||||
// will affect touch devices.
|
||||
drupal_add_js(drupal_get_path('module', 'openlayers') .
|
||||
'/plugins/behaviors/openlayers_behavior_popup.js', array('weight' => 10));
|
||||
return $this->options;
|
||||
}
|
||||
}
|
@@ -0,0 +1,95 @@
|
||||
/**
|
||||
* @file
|
||||
* JS Implementation of OpenLayers behavior.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Javascript Drupal Theming function for inside of Popups
|
||||
*
|
||||
* To override
|
||||
*
|
||||
* @param feature
|
||||
* OpenLayers feature object.
|
||||
* @return
|
||||
* Formatted HTML.
|
||||
*/
|
||||
Drupal.theme.prototype.openlayersPopup = function(feature) {
|
||||
var output = '';
|
||||
|
||||
if (feature.attributes.name) {
|
||||
output += '<div class="openlayers-popup openlayers-tooltip-name">' + feature.attributes.name + '</div>';
|
||||
}
|
||||
if (feature.attributes.description) {
|
||||
output += '<div class="openlayers-popup openlayers-tooltip-description">' + feature.attributes.description + '</div>';
|
||||
}
|
||||
|
||||
return output;
|
||||
};
|
||||
|
||||
// Make sure the namespace exists
|
||||
Drupal.openlayers.popup = Drupal.openlayers.popup || {};
|
||||
|
||||
/**
|
||||
* OpenLayers Popup Behavior
|
||||
*/
|
||||
Drupal.openlayers.addBehavior('openlayers_behavior_popup', function (data, options) {
|
||||
var map = data.openlayers;
|
||||
var layers = [];
|
||||
var selectedFeature;
|
||||
|
||||
// For backwards compatiability, if layers is not
|
||||
// defined, then include all vector layers
|
||||
if (typeof options.layers == 'undefined' || options.layers.length == 0) {
|
||||
layers = map.getLayersByClass('OpenLayers.Layer.Vector');
|
||||
}
|
||||
else {
|
||||
for (var i in options.layers) {
|
||||
var selectedLayer = map.getLayersBy('drupalID', options.layers[i]);
|
||||
if (typeof selectedLayer[0] != 'undefined') {
|
||||
layers.push(selectedLayer[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if only 1 layer exists, do not add as an array. Kind of a
|
||||
// hack, see https://drupal.org/node/1393460
|
||||
if (layers.length == 1) {
|
||||
layers = layers[0];
|
||||
}
|
||||
|
||||
var popupSelect = new OpenLayers.Control.SelectFeature(layers,
|
||||
{
|
||||
onSelect: function(feature) {
|
||||
// Create FramedCloud popup.
|
||||
popup = new OpenLayers.Popup.FramedCloud(
|
||||
'popup',
|
||||
feature.geometry.getBounds().getCenterLonLat(),
|
||||
null,
|
||||
Drupal.theme('openlayersPopup', feature),
|
||||
null,
|
||||
true,
|
||||
function(evt) {
|
||||
Drupal.openlayers.popup.popupSelect.unselect(selectedFeature);
|
||||
}
|
||||
);
|
||||
|
||||
// Assign popup to feature and map.
|
||||
popup.panMapIfOutOfView = options.panMapIfOutOfView;
|
||||
popup.keepInMap = options.keepInMap;
|
||||
selectedFeature = feature;
|
||||
feature.popup = popup;
|
||||
Drupal.attachBehaviors();
|
||||
map.addPopup(popup);
|
||||
},
|
||||
onUnselect: function(feature) {
|
||||
map.removePopup(feature.popup);
|
||||
feature.popup.destroy();
|
||||
feature.popup = null;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
map.addControl(popupSelect);
|
||||
popupSelect.activate();
|
||||
Drupal.openlayers.popup.popupSelect = popupSelect;
|
||||
});
|
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Implementation of OpenLayers behavior.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Ctools plugin definition.
|
||||
*/
|
||||
function openlayers_openlayers_behavior_scaleline_openlayers_behaviors() {
|
||||
return array(
|
||||
'title' => t('Scale Line'),
|
||||
'description' => t('Provides a line of scale in the map interface.'),
|
||||
'type' => 'map',
|
||||
'behavior' => array(
|
||||
'file' => 'openlayers_behavior_scaleline.inc',
|
||||
'class' => 'openlayers_behavior_scaleline',
|
||||
'parent' => 'openlayers_behavior',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scaleline Behavior
|
||||
*/
|
||||
class openlayers_behavior_scaleline extends openlayers_behavior {
|
||||
/**
|
||||
* Provide initial values for options.
|
||||
*/
|
||||
function options_init() {
|
||||
return array(
|
||||
'scaleline' => '',
|
||||
);
|
||||
}
|
||||
|
||||
function js_dependency() {
|
||||
return array('OpenLayers.Control.ScaleLine');
|
||||
}
|
||||
|
||||
function options_form($defaults = array()) {
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Render.
|
||||
*/
|
||||
function render(&$map) {
|
||||
drupal_add_js(drupal_get_path('module', 'openlayers') .
|
||||
'/plugins/behaviors/openlayers_behavior_scaleline.js');
|
||||
return $this->options;
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
/**
|
||||
* @file
|
||||
* JS Implementation of OpenLayers behavior.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Scale Line Behavior
|
||||
*/
|
||||
Drupal.openlayers.addBehavior('openlayers_behavior_scaleline', function (data, options) {
|
||||
Drupal.openlayers.addControl(data.openlayers, 'ScaleLine');
|
||||
});
|
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Implementation of OpenLayers behavior for tooltips.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Ctools plugin definition.
|
||||
*/
|
||||
function openlayers_openlayers_behavior_tooltip_openlayers_behaviors() {
|
||||
return array(
|
||||
'title' => t('Tooltip for Features'),
|
||||
'description' => t('Adds info boxes on hover to points or shapes on maps. This does not work with the Popup behavior due to limitation of event handling in the OpenLayers library.'),
|
||||
'type' => 'layer',
|
||||
'behavior' => array(
|
||||
'file' => 'openlayers_behavior_tooltip.inc',
|
||||
'class' => 'openlayers_behavior_tooltip',
|
||||
'parent' => 'openlayers_behavior',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Attribution Behavior
|
||||
*/
|
||||
class openlayers_behavior_tooltip extends openlayers_behavior {
|
||||
/**
|
||||
* Provide initial values for options.
|
||||
*/
|
||||
function options_init() {
|
||||
return array(
|
||||
'attribution' => '',
|
||||
'layers' => array(),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Form defintion for per map customizations.
|
||||
*/
|
||||
function options_form($defaults = array()) {
|
||||
// Only prompt for vector layers
|
||||
$vector_layers = array();
|
||||
foreach ($this->map['layers'] as $id => $name) {
|
||||
$layer = openlayers_layer_load($id);
|
||||
if (isset($layer->data['vector']) && $layer->data['vector'] == TRUE) {
|
||||
$vector_layers[$id] = $name;
|
||||
}
|
||||
}
|
||||
|
||||
return array(
|
||||
'layers' => array(
|
||||
'#title' => t('Layers'),
|
||||
'#type' => 'checkboxes',
|
||||
'#options' => $vector_layers,
|
||||
'#description' => t('Select layer to apply tooltips to.'),
|
||||
'#default_value' => isset($defaults['layers']) ?
|
||||
$defaults['layers'] : array(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render.
|
||||
*/
|
||||
function render(&$map) {
|
||||
drupal_add_js(drupal_get_path('module', 'openlayers') .
|
||||
'/plugins/behaviors/openlayers_behavior_tooltip.js');
|
||||
return $this->options;
|
||||
}
|
||||
}
|
@@ -0,0 +1,93 @@
|
||||
/**
|
||||
* @file
|
||||
* JS Implementation of OpenLayers behavior.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Javascript Drupal Theming function for inside of Tooltips
|
||||
*
|
||||
* To override
|
||||
*
|
||||
* @param feature
|
||||
* OpenLayers feature object.
|
||||
* @return
|
||||
* Formatted HTML.
|
||||
*/
|
||||
Drupal.theme.prototype.openlayersTooltip = function(feature) {
|
||||
var output = '';
|
||||
|
||||
if (feature.attributes.name) {
|
||||
output += '<div class="openlayers-popup openlayers-tooltip-name">' + feature.attributes.name + '</div>';
|
||||
}
|
||||
if (feature.attributes.description) {
|
||||
output += '<div class="openlayers-popup openlayers-tooltip-description">' + feature.attributes.description + '</div>';
|
||||
}
|
||||
|
||||
return output;
|
||||
};
|
||||
|
||||
/**
|
||||
* OpenLayers Tooltip Behavior
|
||||
*/
|
||||
Drupal.openlayers.addBehavior('openlayers_behavior_tooltip', function (data, options) {
|
||||
var map = data.openlayers;
|
||||
var layers = [];
|
||||
|
||||
// For backwards compatiability, if layers is not
|
||||
// defined, then include all vector layers
|
||||
if (typeof options.layers == 'undefined' || options.layers.length == 0) {
|
||||
layers = map.getLayersByClass('OpenLayers.Layer.Vector');
|
||||
}
|
||||
else {
|
||||
for (var i in options.layers) {
|
||||
var selectedLayer = map.getLayersBy('drupalID', options.layers[i]);
|
||||
if (typeof selectedLayer[0] != 'undefined') {
|
||||
layers.push(selectedLayer[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if only 1 layer exists, do not add as an array. Kind of a
|
||||
// hack, see https://drupal.org/node/1393460
|
||||
if (layers.length == 1) {
|
||||
layers = layers[0];
|
||||
}
|
||||
|
||||
// Define feature select events for selected layers.
|
||||
var popupSelect = new OpenLayers.Control.SelectFeature(layers,
|
||||
{
|
||||
hover: true,
|
||||
clickout: false,
|
||||
multiple: false,
|
||||
onSelect: function(feature) {
|
||||
// Create FramedCloud popup for tooltip.
|
||||
var output = Drupal.theme('openlayersTooltip', feature);
|
||||
if (typeof output != 'undefined') {
|
||||
popup = new OpenLayers.Popup.FramedCloud(
|
||||
'tooltip',
|
||||
feature.geometry.getBounds().getCenterLonLat(),
|
||||
null,
|
||||
output,
|
||||
null,
|
||||
true
|
||||
);
|
||||
feature.popup = popup;
|
||||
feature.layer.map.addPopup(popup);
|
||||
Drupal.attachBehaviors();
|
||||
}
|
||||
},
|
||||
onUnselect: function(feature) {
|
||||
// Remove popup.
|
||||
if (typeof feature.popup != 'undefined') {
|
||||
feature.layer.map.removePopup(feature.popup);
|
||||
feature.popup.destroy();
|
||||
feature.popup = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
// Actiate the popups
|
||||
map.addControl(popupSelect);
|
||||
popupSelect.activate();
|
||||
});
|
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Implementation of OpenLayers behavior.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Ctools plugin definition.
|
||||
*/
|
||||
function openlayers_openlayers_behavior_touch_navigation_openlayers_behaviors() {
|
||||
return array(
|
||||
'title' => t('Touch Navigation'),
|
||||
'description' => t('Provides specific navigation controls for touch enabled devices only. <strong>This is included with the Navigation behavior</strong>. Only enable this if you are targeting only touch enabled devices.'),
|
||||
'type' => 'map',
|
||||
'behavior' => array(
|
||||
'file' => 'openlayers_behavior_touch_navigation.inc',
|
||||
'class' => 'openlayers_behavior_touch_navigation',
|
||||
'parent' => 'openlayers_behavior',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Touch Navigation Behavior
|
||||
*/
|
||||
class openlayers_behavior_touch_navigation extends openlayers_behavior {
|
||||
/**
|
||||
* Provide initial values for options.
|
||||
*/
|
||||
function options_init() {
|
||||
return array(
|
||||
'documentDrag' => FALSE,
|
||||
);
|
||||
}
|
||||
|
||||
function js_dependency() {
|
||||
return array('OpenLayers.Control.TouchNavigation');
|
||||
}
|
||||
|
||||
function options_form($defaults = array()) {
|
||||
return array(
|
||||
'documentDrag' => array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Document Drag'),
|
||||
'#description' => t('Allow panning of the map by dragging outside map viewport.'),
|
||||
'#default_value' => isset($defaults['documentDrag']) ? $defaults['documentDrag'] : FALSE
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render.
|
||||
*/
|
||||
function render(&$map) {
|
||||
drupal_add_js(drupal_get_path('module', 'openlayers') .
|
||||
'/plugins/behaviors/openlayers_behavior_touch_navigation.js');
|
||||
return $this->options;
|
||||
}
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
/**
|
||||
* @file
|
||||
* JS Implementation of OpenLayers behavior.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Touch Navigation Behavior
|
||||
*/
|
||||
Drupal.openlayers.addBehavior('openlayers_behavior_touch_navigation', function (data, options) {
|
||||
options.documentDrag = !!options.documentDrag;
|
||||
Drupal.openlayers.addControl(data.openlayers, 'TouchNavigation', options);
|
||||
});
|
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Implementation of OpenLayers behavior.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Ctools plugin definition.
|
||||
*/
|
||||
function openlayers_openlayers_behavior_zoombox_openlayers_behaviors() {
|
||||
return array(
|
||||
'title' => t('Zoom Box Clicking'),
|
||||
'description' => t('Provides a zoom box that can be drawn on SHIFT + click. Please note that by default the Navigation control behavior includes this, so there is no need to have both.'),
|
||||
'type' => 'map',
|
||||
'behavior' => array(
|
||||
'file' => 'openlayers_behavior_zoombox.inc',
|
||||
'class' => 'openlayers_behavior_zoombox',
|
||||
'parent' => 'openlayers_behavior',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Zoom Box Behavior
|
||||
*/
|
||||
class openlayers_behavior_zoombox extends openlayers_behavior {
|
||||
/**
|
||||
* Provide initial values for options.
|
||||
*/
|
||||
function options_init() {
|
||||
return array(
|
||||
'zoombox' => '',
|
||||
);
|
||||
}
|
||||
|
||||
function js_dependency() {
|
||||
return array('OpenLayers.Control.ZoomBox');
|
||||
}
|
||||
|
||||
function options_form($defaults = array()) {
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Render.
|
||||
*/
|
||||
function render(&$map) {
|
||||
drupal_add_js(drupal_get_path('module', 'openlayers') .
|
||||
'/plugins/behaviors/openlayers_behavior_zoombox.js');
|
||||
return $this->options;
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
/**
|
||||
* @file
|
||||
* JS Implementation of OpenLayers behavior.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Zoom Box Behavior
|
||||
*/
|
||||
Drupal.openlayers.addBehavior('openlayers_behavior_zoombox', function (data, options) {
|
||||
Drupal.openlayers.addControl(data.openlayers, 'ZoomBox');
|
||||
});
|
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Implementation of OpenLayers behavior.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Ctools plugin definition.
|
||||
*/
|
||||
function openlayers_openlayers_behavior_zoompanel_openlayers_behaviors() {
|
||||
return array(
|
||||
'title' => t('Zoom Control'),
|
||||
'description' => t('Provides a control that can Zoom In, Zoom Out, and Zoom to Max Extent Button. Do not use with Pan Zoom Bar Control or Pan Zoom Control.'),
|
||||
'type' => 'map',
|
||||
'behavior' => array(
|
||||
'file' => 'openlayers_behavior_zoompanel.inc',
|
||||
'class' => 'openlayers_behavior_zoompanel',
|
||||
'parent' => 'openlayers_behavior',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Zoom Panel Behavior
|
||||
*/
|
||||
class openlayers_behavior_zoompanel extends openlayers_behavior {
|
||||
/**
|
||||
* Provide initial values for options.
|
||||
*/
|
||||
function options_init() {
|
||||
return array(
|
||||
'panzoom' => '',
|
||||
);
|
||||
}
|
||||
|
||||
function js_dependency() {
|
||||
return array(
|
||||
'OpenLayers.Control.ZoomPanel'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render.
|
||||
*/
|
||||
function render(&$map) {
|
||||
drupal_add_js(drupal_get_path('module', 'openlayers') .
|
||||
'/plugins/behaviors/openlayers_behavior_zoompanel.js');
|
||||
return $this->options;
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
/**
|
||||
* @file
|
||||
* JS Implementation of OpenLayers behavior.
|
||||
*/
|
||||
|
||||
/**
|
||||
* ZoomPanel Behavior
|
||||
*/
|
||||
Drupal.openlayers.addBehavior('openlayers_behavior_zoompanel', function (data, options) {
|
||||
Drupal.openlayers.addControl(data.openlayers, 'ZoomPanel');
|
||||
});
|
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Implementation of OpenLayers behavior.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Ctools plugin definition.
|
||||
*/
|
||||
function openlayers_openlayers_behavior_zoomtolayer_openlayers_behaviors() {
|
||||
return array(
|
||||
'title' => t('Zoom to Layer'),
|
||||
'description' => t('Zooms to the extent of a given layer(s) on map loading. If multiple layers are chosen, zooms to the extent that includes all chosen layers.'),
|
||||
'type' => 'layer',
|
||||
'behavior' => array(
|
||||
'file' => 'openlayers_behavior_zoomtolayer.inc',
|
||||
'class' => 'openlayers_behavior_zoomtolayer',
|
||||
'parent' => 'openlayers_behavior',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Attribution Behavior
|
||||
*/
|
||||
class openlayers_behavior_zoomtolayer extends openlayers_behavior {
|
||||
/**
|
||||
* Provide initial values for options.
|
||||
*/
|
||||
function options_init() {
|
||||
return array(
|
||||
'point_zoom_level' => '5',
|
||||
'zoomtolayer_scale' => 1,
|
||||
);
|
||||
}
|
||||
|
||||
function options_form($defaults = array()) {
|
||||
return array(
|
||||
'zoomtolayer' => array(
|
||||
'#type' => 'checkboxes',
|
||||
'#options' => $this->map['layers'],
|
||||
'#description' => t('Select layer(s) to which to zoom when the map is loaded.'),
|
||||
'#default_value' => isset($defaults['zoomtolayer']) ? $defaults['zoomtolayer'] : array(),
|
||||
),
|
||||
'point_zoom_level' => array(
|
||||
'#title' => t('Point Zoom Level'),
|
||||
'#type' => 'textfield',
|
||||
'#default_value' => (isset($defaults['point_zoom_level'])) ?
|
||||
$defaults['point_zoom_level'] : 5,
|
||||
'#size' => 5,
|
||||
),
|
||||
'zoomtolayer_scale' => array(
|
||||
'#title' => t('Zoom to Layer Scale'),
|
||||
'#type' => 'textfield',
|
||||
'#size' => 5,
|
||||
'#description' => t('Additional scaling to apply to the calculated bounds before zooming. See <a href="http://dev.openlayers.org/docs/files/OpenLayers/BaseTypes/Bounds-js.html#OpenLayers.Bounds.scale">OpenLayers docs</a>.'),
|
||||
'#default_value' => isset($defaults['zoomtolayer_scale']) ? $defaults['zoomtolayer_scale'] : 1
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render.
|
||||
*/
|
||||
function render(&$map) {
|
||||
drupal_add_js(drupal_get_path('module', 'openlayers') .
|
||||
'/plugins/behaviors/openlayers_behavior_zoomtolayer.js');
|
||||
return $this->options;
|
||||
}
|
||||
}
|
@@ -0,0 +1,62 @@
|
||||
/**
|
||||
* @file
|
||||
* JS Implementation of OpenLayers behavior.
|
||||
*/
|
||||
|
||||
/**
|
||||
* OpenLayers Zoom to Layer Behavior
|
||||
*/
|
||||
Drupal.openlayers.addBehavior('openlayers_behavior_zoomtolayer', function (data, options) {
|
||||
var map = data.openlayers;
|
||||
var layers = map.getLayersBy('drupalID', {
|
||||
test: function(id) {
|
||||
for (var i in options.zoomtolayer) {
|
||||
if (options.zoomtolayer[i] == id) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
// Go through selected layers to get full extent.
|
||||
map.fullExtent = new OpenLayers.Bounds();
|
||||
for (var i in layers) {
|
||||
if (layers[i].features !== undefined) {
|
||||
var zoomtolayer_scale = data.map.behaviors['openlayers_behavior_zoomtolayer'].zoomtolayer_scale;
|
||||
// For KML layers, we need to wait until layer is loaded. Ideally
|
||||
// we could check for any layer that is loading from an external
|
||||
// source, but for now, just check KML
|
||||
if (layers[i].layer_handler == 'kml') {
|
||||
layers[i].events.register('loadend', layers[i], function() {
|
||||
layerextent = layers[i].getDataExtent().scale(zoomtolayer_scale);
|
||||
map.fullExtent.extend(layerextent);
|
||||
map.zoomToExtent(map.fullExtent);
|
||||
|
||||
// If unable to find width due to single point,
|
||||
// zoom in with point_zoom_level option.
|
||||
if (layerextent.getWidth() == 0.0) {
|
||||
map.zoomTo(options.point_zoom_level);
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
layerextent = layers[i].getDataExtent();
|
||||
// Check for valid layer extent
|
||||
if (layerextent != null) {
|
||||
map.fullExtent.extend(layerextent);
|
||||
map.zoomToExtent(map.fullExtent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If unable to find width due to single point,
|
||||
// zoom in with point_zoom_level option.
|
||||
if (map.fullExtent.getWidth() == 0.0) {
|
||||
map.zoomTo(options.point_zoom_level);
|
||||
}
|
||||
else {
|
||||
map.zoomToExtent(map.fullExtent.scale(zoomtolayer_scale));
|
||||
}
|
||||
});
|
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Implementation of OpenLayers behavior.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Ctools plugin definition.
|
||||
*/
|
||||
function openlayers_openlayers_behavior_zoomtomaxextent_openlayers_behaviors() {
|
||||
return array(
|
||||
'title' => t('Zoom to Max Extent'),
|
||||
'description' => t('Provides button to zoom to the maximum extent of the map.'),
|
||||
'type' => 'map',
|
||||
'behavior' => array(
|
||||
'file' => 'openlayers_behavior_zoomtomaxextent.inc',
|
||||
'class' => 'openlayers_behavior_zoomtomaxextent',
|
||||
'parent' => 'openlayers_behavior',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Zoom to Max Extent Behavior
|
||||
*/
|
||||
class openlayers_behavior_zoomtomaxextent extends openlayers_behavior {
|
||||
/**
|
||||
* Provide initial values for options.
|
||||
*/
|
||||
function options_init() {
|
||||
return array(
|
||||
'zoomtomaxextent' => '',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render.
|
||||
*/
|
||||
function render(&$map) {
|
||||
drupal_add_js(drupal_get_path('module', 'openlayers') .
|
||||
'/plugins/behaviors/openlayers_behavior_zoomtomaxextent.js');
|
||||
return $this->options;
|
||||
}
|
||||
}
|
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
* @file
|
||||
* JS Implementation of OpenLayers behavior.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Zoom Max Extent Behavior
|
||||
*/
|
||||
Drupal.openlayers.addBehavior('openlayers_behavior_zoomtomaxextent', function (data, options) {
|
||||
options.allowSelection = options.allowSelection || true;
|
||||
var panel = Drupal.openlayers.addControl(data.openlayers, 'Panel', options);
|
||||
|
||||
var button = new OpenLayers.Control.ZoomToMaxExtent();
|
||||
panel.addControls([button]);
|
||||
});
|
Reference in New Issue
Block a user