first import

This commit is contained in:
Bachir Soussi Chiadmi
2015-04-08 11:40:19 +02:00
commit 1bc61b12ad
8435 changed files with 1582817 additions and 0 deletions

View File

@@ -0,0 +1,339 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.

View File

@@ -0,0 +1,17 @@
`openlayers_plus` is a collection of behaviors that work with
[the Drupal OpenLayers module](http://drupal.org/project/openlayers),
version 2 and up. This module requires the OpenLayers module, but not
vice versa.
This provides the following functionality:
* BlockSwitcher: a clone of [LayerSwitcher](http://dev.openlayers.org/docs/files/OpenLayers/Control/LayerSwitcher-js.html), with better themability and positioning via the Drupal block system.
* BlockToggle: a version of BlockSwitcher that toggles between two different layers only. Useful for situations in which layers represent the same data in slightly different ways.
* Legend: a block in a corner of a map that provides information on layers.
* Permalink: a version of [Permalink](http://dev.openlayers.org/docs/files/OpenLayers/Control/Permalink-js.html) optimized to persist layers between pages with different layer setups and without explicitly using the control.
* Popup: an interaction with point-based, clustered maps that allows clicking on points that results in scanning between items.
* Tooltip: an interaction with point-based maps that results in following links on hover.
* Scale Points: dynamic styling, changing point radii based on a certain value
This module does not provide thorough theming or accessory images: it's the
responsibility of the site builder to tune styling.

View File

@@ -0,0 +1,66 @@
<?php
class openlayers_plus_behavior_blockswitcher extends openlayers_behavior {
/**
* Override of options_init().
*/
function options_init() {
$options = array(
'enabled' => FALSE,
'position' => 'se',
);
return $options;
}
/**
* Override of options_form().
*/
function options_form($defaults) {
return array(
'enabled' => array(
'#type' => 'checkbox',
'#title' => t('Show blockswitcher in map'),
'#default_value' => isset($defaults['enabled']) ? $defaults['enabled'] : array(),
),
'open' => array(
'#type' => 'checkbox',
'#title' => t('Show blockswitcher open when the map loads'),
'#default_value' => isset($defaults['open']) ? $defaults['open'] : array(),
),
'overlay_style' => array(
'#type' => 'select',
'#title' => t('Show overlay layers as checkboxes or radio buttons'),
'#options' => array(
'checkbox' => t('Checkboxes'),
'radio' => t('Radio Buttons'),
),
'#default_value' => isset($defaults['overlay_style']) ? $defaults['overlay_style'] : array(),
),
'position' => array(
'#type' => 'select',
'#title' => t('Position'),
'#options' => array(
'ne' => t('Top right'),
'se' => t('Bottom right'),
'sw' => t('Bottom left'),
'nw' => t('Top left'),
),
'#default_value' => isset($defaults['position']) ? $defaults['position'] : array(),
),
);
}
/**
* Render.
*/
function render(&$map) {
drupal_add_js(drupal_get_path('module', 'openlayers_plus')
. '/behaviors/openlayers_plus_behavior_blockswitcher.js');
if ($this->options['enabled']) {
$block = module_invoke('openlayers_plus', 'block_view', 'blockswitcher');
$this->options['block'] = drupal_render($block);
}
return $this->options;
}
}

View File

@@ -0,0 +1,232 @@
/**
* Implementation of Drupal behavior.
*/
(function($) {
/**
* Blockswitcher is **NOT** an OpenLayers control.
*/
Drupal.behaviors.OpenLayersPlusBlockswitcher = {};
/**
* Initializes the */
Drupal.behaviors.OpenLayersPlusBlockswitcher = {
'attach' : function(context, settings) {
/*
* First the support functions
*/
/**
* Checks if the layer state has changed since the last redraw() call.
*
* Returns:
* {Boolean} The layer state changed since the last redraw() call.
*/
Drupal.behaviors.OpenLayersPlusBlockswitcher.needsRedraw = function() {
if ( !this.layerStates.length || (this.map.layers.length != this.layerStates.length) ) {
return true;
}
for (var i=0, len=this.layerStates.length; i<len; i++) {
var layerState = this.layerStates[i];
var layer = this.map.layers[i];
if ( (layerState.name != layer.name) || (layerState.inRange != layer.inRange) || (layerState.id != layer.id) || (layerState.visibility != layer.visibility) ) {
return true;
}
}
return false;
};
/**
* Redraws the blockswitcher to reflect the current state of layers.
*/
Drupal.behaviors.OpenLayersPlusBlockswitcher.redraw = function() {
if (this.needsRedraw()) {
// Clear out previous layers
$('.layers.base .layers-content div', this.blockswitcher).remove();
$('.layers.data .layers-content div', this.blockswitcher).remove();
$('.layers.base', this.blockswitcher).hide();
$('.layers.data', this.blockswitcher).hide();
// Save state -- for checking layer if the map state changed.
// We save this before redrawing, because in the process of redrawing
// we will trigger more visibility changes, and we want to not redraw
// and enter an infinite loop.
var len = this.map.layers.length;
this.layerStates = new Array(len);
for (var i = 0; i < len; i++) {
var layerState = this.map.layers[i];
this.layerStates[i] = {'name': layerState.name, 'visibility': layerState.visibility, 'inRange': layerState.inRange, 'id': layerState.id};
}
var layers = this.map.layers.slice();
for (i = 0, len = layers.length; i < len; i++) {
var layer = layers[i];
var baseLayer = layer.isBaseLayer;
if (layer.displayInLayerSwitcher) {
// Only check a baselayer if it is *the* baselayer, check data layers if they are visible
var checked = baseLayer ? (layer === this.map.baseLayer) : layer.getVisibility();
// Create input element
var inputType = (baseLayer) ? "radio" : this.overlay_style;
var inputElem = $('.factory .'+ inputType, this.blockswitcher).clone();
// Append to container
var container = baseLayer ? $('.layers.base', this.blockswitcher) : $('.layers.data', this.blockswitcher);
$('.layers-content', container).append(inputElem);
// Set label text
$('label', inputElem).append((layer.title !== undefined) ? layer.title : layer.name);
// Add states and click handler
if (baseLayer) {
$(inputElem)
.click(function() { Drupal.behaviors.OpenLayersPlusBlockswitcher.layerClick(this); })
.data('layer', layer)
if (checked) {
$(inputElem).addClass('activated');
}
}
else {
if (this.overlay_style == 'checkbox') {
$('input', inputElem)
.click(function() { Drupal.behaviors.OpenLayersPlusBlockswitcher.layerClick(this); })
.data('layer', layer)
.attr('disabled', !baseLayer && !layer.inRange)
.attr('checked', checked);
}
else if(this.overlay_style == 'radio') {
$(inputElem)
.click(function() { Drupal.behaviors.OpenLayersPlusBlockswitcher.layerClick(this); })
.data('layer', layer)
.attr('disabled', !layer.inRange);
if (checked) {
$(inputElem).addClass('activated');
}
}
// Set key styles
if (layer.styleMap) {
css = Drupal.behaviors.OpenLayersPlusBlockswitcher.styleMapToCSS(layer.styleMap);
$('span.key', inputElem).css(css);
}
}
}
}
/*
* Only show layers when there are more than 1 for baselayers, or 1 for data layers
*/
if ($('.layers.base .layers-content div', this.blockswitcher).lenght > 1) {
$('.layers.base', this.blockswitcher).show();
}
if ($('.layers.data .layers-content div', this.blockswitcher).length > 0) {
$('.layers.data', this.blockswitcher).show();
}
}
};
/**
* Click handler that activates or deactivates a layer.
*/
Drupal.behaviors.OpenLayersPlusBlockswitcher.layerClick = function(element) {
var layer = $(element).data('layer');
if (layer.isBaseLayer) {
$('.layers.base .layers-content .activated').removeClass('activated');
$(element).addClass('activated');
layer.map.setBaseLayer(layer);
}
else if (this.overlay_style == 'radio') {
$('.layers.data .layers-content .activated').removeClass('activated');
$.each(this.map.getLayersBy('isBaseLayer', false),
function() {
if(this.CLASS_NAME !== 'OpenLayers.Layer.Vector.RootContainer' &&
this.displayInLayerSwitcher) {
this.setVisibility(false);
}
}
);
layer.setVisibility(true);
$(element).addClass('activated');
}
else {
layer.setVisibility($(element).is(':checked'));
}
};
/**
* Parameters:
* styleMap {OpenLayers.StyleMap}
*
* Returns:
* {Object} An object with css properties and values that can be applied to an element
*
*/
Drupal.behaviors.OpenLayersPlusBlockswitcher.styleMapToCSS = function(styleMap) {
css = {};
default_style = styleMap.styles['default'].defaultStyle;
if (default_style.fillColor === 'transparent' && typeof default_style.externalGraphic != 'undefined') {
css['background-image'] = 'url('+default_style.externalGraphic+')';
css['background-repeat'] = 'no-repeat';
css['background-color'] = 'transparent';
css.width = default_style.pointRadius * 2;
css.height = default_style.pointRadius * 2;
}
else {
css['background-color'] = default_style.fillColor;
}
if (default_style.strokeWidth > 0) {
css['border-color'] = default_style.strokeColor;
}
return css;
}
this.layerStates = [];
var data = $(context).data('openlayers');
if (data && data.map.behaviors.openlayers_plus_behavior_blockswitcher) {
this.map = data.openlayers;
this.overlay_style = (data.map.behaviors.openlayers_plus_behavior_blockswitcher.overlay_style) ?
data.map.behaviors.openlayers_plus_behavior_blockswitcher.overlay_style : 'checkbox';
// If behavior has requested display inside of map, respect it.
if (data.map.behaviors.openlayers_plus_behavior_blockswitcher.enabled == true) {
var block = $(data.map.behaviors.openlayers_plus_behavior_blockswitcher.block);
block.addClass(data.map.behaviors.openlayers_plus_behavior_blockswitcher.position);
$('.block-title', block).click(function() {
$(this).parents('div.block').toggleClass('expanded');
$(this).siblings('div.block-content').toggle();
});
$(context).find('.olMapViewport').append(block);
if (data.map.behaviors.openlayers_plus_behavior_blockswitcher.open == true) {
$('.block-title', block).click();
}
}
this.blockswitcher = $('div.openlayers_plus-blockswitcher');
// Don't propagate click events to the map
// this doesn't catch events that are below the layer list
$('div.openlayers_plus-blockswitcher').mousedown(function(evt) {
OpenLayers.Event.stop(evt);
});
data.openlayers.events.on({
"addlayer": this.redraw,
"changelayer": this.redraw,
"removelayer": this.redraw,
"changebaselayer": this.redraw,
scope: this
});
this.redraw();
}
}
}
})(jQuery);

View File

@@ -0,0 +1,75 @@
<?php
class openlayers_plus_behavior_blocktoggle extends openlayers_behavior {
/**
* Override of options_init().
*/
function options_init() {
$options = array(
'enabled' => FALSE,
'position' => 'se',
);
return $options;
}
/**
* Override of options_form().
*/
function options_form($defaults) {
return array(
'enabled' => array(
'#type' => 'checkbox',
'#title' => t('Show blocktoggle in map'),
'#default_value' => isset($defaults['enabled']) ? $defaults['enabled'] : array(),
),
'a_label' => array(
'#type' => 'textfield',
'#title' => t('Layer A Label'),
'#description' => t('This can either be the name of the layer, or a shorter name you choose.'),
'#default_value' => isset($defaults['a_label']) ? $defaults['a_label'] : array(),
),
'a' => array(
'#type' => 'select',
'#options' => $this->map['layers'],
'#title' => t('Layer A'),
'#default_value' => isset($defaults['a']) ? $defaults['a'] : array(),
),
'b_label' => array(
'#type' => 'textfield',
'#title' => t('Layer B Label'),
'#description' => t('This can either be the name of the layer, or a shorter name you choose.'),
'#default_value' => isset($defaults['b_label']) ? $defaults['b_label'] : array(),
),
'b' => array(
'#type' => 'select',
'#options' => $this->map['layers'],
'#title' => t('Layer B'),
'#default_value' => isset($defaults['b']) ? $defaults['b'] : array(),
),
'position' => array(
'#type' => 'select',
'#title' => t('Position'),
'#options' => array(
'ne' => t('Top right'),
'se' => t('Bottom right'),
'sw' => t('Bottom left'),
'nw' => t('Top left'),
),
'#default_value' => isset($defaults['position']) ? $defaults['position'] : array(),
),
);
}
/**
* Render.
*/
function render(&$map) {
drupal_add_js(drupal_get_path('module', 'openlayers_plus')
. '/behaviors/openlayers_plus_behavior_blocktoggle.js');
if ($this->options['enabled']) {
$block = module_invoke('openlayers_plus', 'block_view', 'blocktoggle');
$this->options['block'] = drupal_render($block);
}
return $this->options;
}
}

View File

@@ -0,0 +1,121 @@
/**
* Implementation of Drupal behavior.
*/
//Drupal.behaviors.openlayers_plus_behavior_blocktoggle = function(context) {
// Drupal.OpenLayersPlusBlocktoggle.attach(context);
//};
(function($) {
/**
* Implementation of Drupal behavior.
*/
//Drupal.behaviors.openlayers_plus_behavior_blocktoggle = function(context) {
Drupal.openlayers.addBehavior('openlayers_plus_behavior_blocktoggle', function (data, options) {
Drupal.OpenLayersPlusBlocktoggle.attach(data, options);
});
/**
* Blocktoggle is **NOT** an OpenLayers control.
*/
Drupal.OpenLayersPlusBlocktoggle = {};
Drupal.OpenLayersPlusBlocktoggle.layerStates = [];
/**
* Initializes the blocktoggle and attaches to DOM elements.
*/
Drupal.OpenLayersPlusBlocktoggle.attach = function(data, options) {
/**
* Initializes the blocktoggle and attaches to DOM elements.
*/
//Drupal.OpenLayersPlusBlocktoggle.attach = function(context) {
// var data = $(context).data('openlayers');
if (data && data.map.behaviors.openlayers_plus_behavior_blocktoggle) {
this.map = data.openlayers;
this.layer_a = this.map.getLayersBy('drupalID',
options.a)[0];
this.layer_b = this.map.getLayersBy('drupalID',
options.b)[0];
// If behavior has requested display inside of map, respect it.
if (options.enabled == true) {
var block = $(options.block);
block.addClass(options.position);
$(data.openlayers.viewPortDiv).append(block);
}
this.blocktoggle = $('div.block-openlayers_plus-blocktoggle');
this.blocktoggle.data('layer_a', this.layer_a);
this.blocktoggle.data('layer_b', this.layer_b);
// Don't propagate click events to the map
// this doesn't catch events that are below the layer list
$('div.block-openlayers_plus-blocktoggle *').mousedown(function(evt) {
OpenLayers.Event.stop(evt);
});
$('.openlayers-blocktoggle-a').text(
data.map.behaviors.openlayers_plus_behavior_blocktoggle.a_label
);
$('.openlayers-blocktoggle-b').text(
data.map.behaviors.openlayers_plus_behavior_blocktoggle.b_label
);
$('div.block-openlayers_plus-blocktoggle').toggle(
function() {
$(this).data('layer_a').setVisibility(false);
$(this).data('layer_b').setVisibility(true);
$(this).find('.openlayers-blocktoggle-a').removeClass('activated');
$(this).find('.openlayers-blocktoggle-b').addClass('activated');
},
function() {
$(this).data('layer_b').setVisibility(false);
$(this).data('layer_a').setVisibility(true);
$(this).find('.openlayers-blocktoggle-b').removeClass('activated');
$(this).find('.openlayers-blocktoggle-a').addClass('activated');
}
);
data.openlayers.events.on({
"addlayer": this.redraw,
"changelayer": this.redraw,
"removelayer": this.redraw,
scope: this
});
}
};
/**
* Checks if the layer state has changed since the last redraw() call.
*
* Returns:
* {Boolean} The layer state changed since the last redraw() call.
*/
Drupal.OpenLayersPlusBlocktoggle.needsRedraw = function() {
return (
(this.a_vis ==
$(this).find('.openlayers-blocktoggle-a').hasClass('activated')) ? 1 : 0
^
(this.b_vis ==
$(this).find('.openlayers-blocktoggle-b').hasClass('activated')) ? 1 : 0);
};
/**
* Redraws the blocktoggle to reflect the current state of layers.
*/
Drupal.OpenLayersPlusBlocktoggle.redraw = function() {
if (this.needsRedraw()) {
this.a_vis = this.layer_a.visibility;
this.b_vis = this.layer_b.visibility;
// Clear out previous layers
// Save state -- for checking layer if the map state changed.
// We save this before redrawing, because in the process of redrawing
// we will trigger more visibility changes, and we want to not redraw
// and enter an infinite loop.
$('div.openlayers-blocktoggle').click();
}
};
})(jQuery);

View File

@@ -0,0 +1,24 @@
<?php
class openlayers_plus_behavior_legend extends openlayers_behavior {
function options_init() {
return array();
}
/**
* Render.
*/
function render(&$map) {
drupal_add_js(drupal_get_path('module', 'openlayers_plus') . '/behaviors/openlayers_plus_behavior_legend.js');
$options = array();
foreach ($map['layers'] as $layer => $layer_data) {
if (isset($layer_data['options']['legend']) && is_array($layer_data['options']['legend'])) {
$options[$layer] = theme('openlayers_plus_legend', array('legend' => $layer_data['options']['legend'], 'layer' => $layer_data, 'layer_id' => $layer));
}
elseif (isset($layer_data['options']['legend'])) {
$options[$layer] = theme('openlayers_plus_legend_raw', array('raw' => $layer_data['options']['legend'], 'layer' => $layer_data, 'layer_id' => $layer));
}
}
return $options;
}
}

View File

@@ -0,0 +1,45 @@
/**
* Implementation of Drupal behavior.
*/
Drupal.behaviors.openlayers_plus_behavior_legend = function(context) {
Drupal.OpenLayersPlusLegend.attach(context);
};
Drupal.OpenLayersPlusLegend = {};
Drupal.OpenLayersPlusLegend.attach = function(context) {
var data = $(context).data('openlayers');
if (data && data.map.behaviors.openlayers_plus_behavior_legend) {
var layer, i;
for (i in data.openlayers.layers) {
layer = data.openlayers.layers[i];
if (data.map.behaviors.openlayers_plus_behavior_legend[layer.drupalID]) {
if (!$('div.openlayers-legends', context).size()) {
$(context).append("<div class='openlayers-legends'></div>");
}
layer.events.register('visibilitychanged', layer, Drupal.OpenLayersPlusLegend.setLegend);
// Trigger the setLegend() method at attach time. We don't know whether
// our behavior is being called after the map has already been drawn.
Drupal.OpenLayersPlusLegend.setLegend(layer);
}
}
}
};
Drupal.OpenLayersPlusLegend.setLegend = function(layer) {
// The layer param may vary based on the context from which we are called.
layer = layer.object ? layer.object : layer;
var name = layer.drupalID;
var map = $(layer.map.div);
var data = map.data('openlayers');
var legend = data.map.behaviors.openlayers_plus_behavior_legend[name];
var legends = $('div.openlayers-legends', map);
if (layer.visibility && $('#openlayers-legend-'+ name, legends).size() === 0) {
legends.append(legend);
}
else if (!layer.visibility) {
$('#openlayers-legend-'+name, legends).remove();
}
};

View File

@@ -0,0 +1,12 @@
<?php
class openlayers_plus_behavior_permalink extends openlayers_behavior {
function options_init() {
return array();
}
function render(&$map) {
drupal_add_js(drupal_get_path('module', 'openlayers_plus') . '/behaviors/openlayers_plus_behavior_permalink.js');
return $this->options;
}
}

View File

@@ -0,0 +1,275 @@
/**
* Implementation of Drupal behavior.
*/
Drupal.behaviors.openlayers_plus_behavior_permalink = function(context) {
Drupal.OpenLayersPermalink.attach(context);
};
Drupal.OpenLayersPermalink = {};
Drupal.OpenLayersPermalink.attach = function(context) {
var data = $(context).data('openlayers');
if (data && data.map.behaviors.openlayers_plus_behavior_permalink) {
// Doctor link hrefs.
$('#canvas a:not(.processed-permalink)').each(function() {
$(this).addClass('processed-permalink');
$(this).click(function() {
var href = $(this).attr('href');
if (href.indexOf('#') === -1) {
href = Drupal.OpenLayersPermalink.addQuery(href);
$(this).attr('href', href);
}
});
});
// Doctor form submission.
$('form:not(.processed-permalink)').each(function() {
$(this).addClass('processed-permalink');
$(this).submit(function() {
var action = $(this).attr('action');
action = Drupal.OpenLayersPermalink.addQuery(action, '?');
$(this).attr('action', action);
});
});
// Add control
var control = new OpenLayers.Control.PermalinkPlus();
data.openlayers.addControl(control);
control.activate();
}
};
Drupal.OpenLayersPermalink.addQuery = function(href, delimiter) {
delimiter = delimiter ? delimiter : '#';
var processed = false;
$('div.openlayers-map').each(function() {
if (!processed) {
var data = $(this).data('openlayers');
if (data.openlayers) {
// If there is a permalink control present, attempt to persist layer settings when clicking through.
for (var i in data.openlayers.controls) {
if (data.openlayers.controls[i].CLASS_NAME == 'OpenLayers.Control.PermalinkPlus') {
var params = OpenLayers.Util.getParameterString(data.openlayers.controls[i].createParams());
params = params.split('&');
var url = href.split(delimiter);
for (var key in params) {
if (params[key].split('=')[0] == 'layers' || params[key].split('=')[0] == 'baseLayers' ) {
if (url[1]) {
url[1] += '&' + params[key];
}
else {
url[1] = params[key];
}
}
}
href = url.join(delimiter);
}
}
}
}
});
return href;
};
OpenLayers.Control.ArgParserPlus = OpenLayers.Class(OpenLayers.Control.ArgParser, {
/**
* Alternative to OpenLayers.Utils.getParameters() that uses the URL hash.
*/
getParameters: function() {
// Parse out parameters portion of url string
var paramsString = window.location.hash.substring(1);
var parameters = {};
var pairs = paramsString.split(/[&;]/);
for(var i=0, len=pairs.length; i<len; ++i) {
var keyValue = pairs[i].split('=');
if (keyValue[0]) {
var key = decodeURIComponent(keyValue[0]);
var value = keyValue[1] || ''; //empty string if no value
//decode individual values
value = value.split(",");
for(var j=0, jlen=value.length; j<jlen; j++) {
value[j] = decodeURIComponent(value[j]);
}
//if there's only one value, do not return as array
if (value.length == 1) {
value = value[0];
}
parameters[key] = value;
}
}
return parameters;
},
/**
* Override of SetMap.
*/
setMap: function(map) {
OpenLayers.Control.prototype.setMap.apply(this, arguments);
// Make sure we dont already have an arg parser attached
for(var i=0, len=this.map.controls.length; i<len; i++) {
var control = this.map.controls[i];
if ( (control != this) &&
(control.CLASS_NAME == "OpenLayers.Control.ArgParser") ) {
// If a second argparser is added to the map, then we
// override the displayProjection to be the one added to the
// map.
if (control.displayProjection != this.displayProjection) {
this.displayProjection = control.displayProjection;
}
break;
}
}
if (i == this.map.controls.length) {
var args = this.getParameters();
// Be careful to set layer first, to not trigger unnecessary layer loads
if (args.layers) {
this.layers = typeof(args.layers) === 'string' ? this.layers = [args.layers] : args.layers;
}
if (args.baseLayers) {
this.baseLayers = typeof(args.baseLayers) === 'string' ? this.baseLayers = [args.baseLayers] : args.baseLayers;
}
if (this.layers || this.baseLayers) {
// when we add a new layer, set its visibility
this.map.events.register('addlayer', this,
this.configureLayers);
this.configureLayers();
}
if (args.lat && args.lon) {
this.center = new OpenLayers.LonLat(parseFloat(args.lon),
parseFloat(args.lat));
if (args.zoom) {
this.zoom = parseInt(args.zoom, 10);
}
// when we add a new baselayer to see when we can set the center
this.map.events.register('changebaselayer', this,
this.setCenter);
this.setCenter();
}
}
},
/**
* Override of configureLayers().
*/
configureLayers: function() {
this.map.events.unregister('addlayer', this, this.configureLayers);
var hasLayers = false;
var argLayers = {};
var i, j, name, layer;
if (this.layers) {
// Iterate over layers and filter arg layers down to ones that exist.
for (i in this.layers) {
name = this.layers[i];
for (j in this.map.layers) {
layer = this.map.layers[j];
if (!layer.isBaseLayer && layer.name === name) {
argLayers[name] = 1;
hasLayers = true;
}
}
}
// If any query layers exist, disable default layer settings and enable layers.
if (hasLayers) {
for (j in this.map.layers) {
layer = this.map.layers[j];
if (!layer.isBaseLayer) {
layer.setVisibility(layer.name in argLayers);
}
}
}
}
// Iterate over baseLayers. We can safely set the baselayer and bail without
// additional logic since there is only one base layer.
if (this.baseLayers) {
for (i in this.baseLayers) {
name = this.baseLayers[i];
for (j in this.map.layers) {
layer = this.map.layers[j];
if (layer.name === name) {
this.map.setBaseLayer(layer);
break;
}
}
}
}
},
CLASS_NAME: "OpenLayers.Control.ArgParserPlus"
});
OpenLayers.Control.PermalinkPlus = OpenLayers.Class(OpenLayers.Control.Permalink, {
argParserClass: OpenLayers.Control.ArgParserPlus,
/**
* Override of updateLink().
*/
updateLink: function() {
var href = this.base;
if (href.indexOf('#') != -1) {
href = href.substring( 0, href.indexOf('#') );
}
href += '#' + OpenLayers.Util.getParameterString(this.createParams());
this.element.href = href;
},
/**
* Override of createParams(). Generates smarter layer/baselayer query string.
*/
createParams: function(center, zoom, layers) {
center = center || this.map.getCenter();
var params = {};
// If there's still no center, map is not initialized yet.
// Break out of this function, and simply return the params from the
// base link.
if (center) {
//zoom
params.zoom = zoom || this.map.getZoom();
//lon,lat
var lat = center.lat;
var lon = center.lon;
if (this.displayProjection) {
var mapPosition = OpenLayers.Projection.transform(
{ x: lon, y: lat },
this.map.getProjectionObject(),
this.displayProjection );
lon = mapPosition.x;
lat = mapPosition.y;
}
params.lat = Math.round(lat*100000)/100000;
params.lon = Math.round(lon*100000)/100000;
// Handle layers & baselayers separately.
params.layers = [];
params.baseLayers = [];
layers = layers || this.map.layers;
for (var i in layers) {
var layer = layers[i];
if (layer.isBaseLayer) {
if (layer == this.map.baseLayer) {
params.baseLayers.push(layer.name);
}
}
else if (layer.getVisibility() && layer.displayInLayerSwitcher) {
params.layers.push(layer.name);
}
}
}
return params;
},
CLASS_NAME: "OpenLayers.Control.PermalinkPlus"
});

View File

@@ -0,0 +1,45 @@
<?php
class openlayers_plus_behavior_popup extends openlayers_behavior {
/**
* Provide initial values for options.
*/
function options_init() {
return array(
'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 popups to.'),
'#default_value' => isset($defaults['layers']) ?
$defaults['layers'] : array(),
),
);
}
/**
* Render.
*/
function render(&$map) {
drupal_add_js(drupal_get_path('module', 'openlayers_plus') . '/behaviors/openlayers_plus_behavior_popup.js');
return $this->options;
}
}

View File

@@ -0,0 +1,182 @@
(function ($) {
Drupal.behaviors.openlayers_plus_behavior_popup = {
attach: function(context, settings) {
var data = $(context).data('openlayers');
if (data && data.map.behaviors.openlayers_plus_behavior_popup) {
var map = data.openlayers;
var options = data.map.behaviors.openlayers_plus_behavior_popup;
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]);
}
}
}
/*
* Due to a bug in OpenLayers,
* if you pass 1 layer to the SelectFeature control as an array
* the onClick event is not cancelled after the first layer.
* Some people might need that.
*/
if (layers.length == 1) {
layers = layers[0];
}
// Add control
var control = new OpenLayers.Control.SelectFeature(
layers,
{
activeByDefault: true,
highlightOnly: false,
multiple: false,
hover: false,
callbacks: {
'over': Drupal.openlayers_plus_behavior_popup.over,
'out': Drupal.openlayers_plus_behavior_popup.out,
'click': Drupal.openlayers_plus_behavior_popup.openPopup
}
}
);
data.openlayers.addControl(control);
control.activate();
}
else if ($(context).is('.openlayers-popupbox')) {
// Popup close
$('a.popup-close', context).click(function() {
$(this).parents('.openlayers-popupbox').fadeOut('fast', function() { $(this).remove(); });
return false;
});
// Set initial pager state
Drupal.openlayers_plus_behavior_popup.pager(context, 'set');
// Next link
$('ul.popup-links a.next', context).click(function() {
var context = $(this).parents('.openlayers-popupbox');
Drupal.openlayers_plus_behavior_popup.pager(context, 'next');
});
// Prev link
$('ul.popup-links a.prev', context).click(function() {
var context = $(this).parents('.openlayers-popupbox');
Drupal.openlayers_plus_behavior_popup.pager(context, 'prev');
});
}
}
};
Drupal.openlayers_plus_behavior_popup = {
// Pager actions
'pager': function(context, op) {
var active = $('li.openlayers-popupbox-active', context);
var index = $('div.item-list > ul > li', context).index(active);
var total = $('div.item-list > ul > li', context).size();
switch (op) {
case 'set':
if (active.size() === 0) {
index = 0;
$('div.item-list > ul > li', context).hide();
$('div.item-list > ul > li:first', context).addClass('openlayers-popupbox-active').show();
$('ul.popup-links a.prev', context).addClass('disabled');
if (total <= 1) {
$('ul.popup-links', context).hide();
}
}
else {
if (index === 0) {
$('ul.popup-links a.prev', context).addClass('disabled');
$('ul.popup-links a.next', context).removeClass('disabled');
}
else if (index == (total - 1)) {
$('ul.popup-links a.next', context).addClass('disabled');
$('ul.popup-links a.prev', context).removeClass('disabled');
}
else {
$('ul.popup-links a.next', context).removeClass('disabled');
$('ul.popup-links a.prev', context).removeClass('disabled');
}
}
var count = parseInt(index + 1, 10) + ' / ' + parseInt(total, 10);
$('span.count', context).text(count);
break;
case 'next':
if (index < (total - 1)) {
active.removeClass('openlayers-popupbox-active').hide()
.next('li').addClass('openlayers-popupbox-active').show();
Drupal.openlayers_plus_behavior_popup.pager(context, 'set');
}
break;
case 'prev':
if (index > 0) {
active.removeClass('openlayers-popupbox-active').hide()
.prev('li').addClass('openlayers-popupbox-active').show();
Drupal.openlayers_plus_behavior_popup.pager(context, 'set');
}
break;
}
},
// Click state
'openPopup': function(feature) {
var context = $(feature.layer.map.div);
// Initialize popup
if (!$('.openlayers-popupbox', context).size()) {
context.append("<div class='openlayers-popupbox popup'></div>");
}
else {
$('.openlayers-popupbox:not(.popup)').addClass('popup');
}
// Hide the layer switcher if it's open.
for (var key in context.data('openlayers').openlayers.controls) {
if (context.data('openlayers').openlayers.controls[key].CLASS_NAME == "OpenLayers.Control.LayerSwitcherPlus") {
context.data('openlayers').openlayers.controls[key].minimizeControl();
}
}
var text;
text = "<a href='#close' class='popup-close'>X</a>";
text += "<h2 class='popup-title'>" + feature.attributes.name + "</h2>";
if (feature.attributes.description != undefined) {
text += "<div class='popup-content'>" + feature.attributes.description + "</div>";
}
text += "<div class='popup-pager'><ul class='links popup-links'><li><a class='prev' href='#prev'>Prev</a></li><li><a class='next' href='#next'>Next</a></li></ul><span class='count'></span></div>";
$('.openlayers-popupbox', context).html(text).show();
Drupal.attachBehaviors($('.openlayers-popupbox', context));
},
// Callback for hover state
// Only show tooltips on hover if the story popup is not open.
'over': function(feature) {
var context = $(feature.layer.map.div);
if (!$('.openlayers-popupbox.popup', context).size()) {
if (feature.attributes.name) {
var text = "<div class='openlayers-popupbox'>";
text += "<h2 class='popup-title'>" + feature.attributes.name + "</h2>";
text += "<div class='popup-count'>" + parseInt(feature.attributes.count, 10) + "</div>";
text += "</div>";
context.append(text);
}
}
},
// Call back for out state.
'out': function(feature) {
var context = $(feature.layer.map.div);
$('.openlayers-popupbox:not(.popup)', context).fadeOut('fast', function() { $(this).remove(); });
}
};
})(jQuery);

View File

@@ -0,0 +1,267 @@
<?php
class openlayers_plus_behavior_scalepoints extends openlayers_behavior {
/**
* Override of options_init().
*/
function options_init() {
$options['min'] = array(
'pointRadius' => 5,
'value' => 0,
);
$options['max'] = array(
'pointRadius' => 20,
'value' => '',
);
$options['distinct'] = 5;
$options['min_label'] = -1;
$options['method'] = 'area';
// @TODO: This sucks. Get a submission/validation handling into the behaviors base class and fix this.
$options['fields'] = array('count, weight');
return $options;
}
/**
* Override of options_form().
*/
function options_form($defaults) {
$options = array (
'min' => array(
'#tree' => TRUE,
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#type' => 'fieldset',
'#title' => t('Minimum values'),
),
'max' => array(
'#tree' => TRUE,
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#type' => 'fieldset',
'#title' => t('Maximum values'),
)
);
foreach (array('min', 'max') as $key) {
$options[$key]['value'] = array(
'#title' => t('Value'),
'#description' => t('Enter a fixed value for this field or leave empty to autoscale points.'),
'#type' => 'textfield',
'#size' => 4,
'#default_value' => isset($defaults[$key]['value']) ? $defaults[$key]['value'] : array(),
);
$options[$key]['pointRadius'] = array(
'#title' => t('Radius'),
'#type' => 'textfield',
'#size' => 4,
'#default_value' => isset($defaults[$key]['pointRadius']) ? $defaults[$key]['pointRadius'] : array(),
);
$options[$key]['fillOpacity'] = array(
'#title' => t('Fill opacity'),
'#type' => 'textfield',
'#size' => 4,
'#maxlength' => 4,
'#default_value' => isset($defaults[$key]['fillOpacity']) ? $defaults[$key]['fillOpacity'] : array(),
);
$options[$key]['strokeWidth'] = array(
'#title' => t('Stroke width'),
'#type' => 'textfield',
'#size' => 4,
'#maxlength' => 4,
'#default_value' => isset($defaults[$key]['strokeWidth']) ? $defaults[$key]['strokeWidth'] : array(),
);
// @TODO: Handle color gradation using API functions in color module
/*
$form[$key]['fillColor'] = array(
'#title' => t('Fill color'),
'#type' => 'textfield',
'#size' => 7,
'#maxlength' => 7,
'#default_value' => $this->options[$key]['fillColor'],
);
$form[$key]['strokeColor'] = array(
'#title' => t('Stroke color'),
'#type' => 'textfield',
'#size' => 7,
'#maxlength' => 7,
'#default_value' => $this->options[$key]['strokeColor'],
);
*/
};
$options['method'] = array(
'#title' => t('Scaling method'),
'#type' => 'select',
'#options' => array(
'area' => t('Circle area'),
'radius' => t('Circle radius'),
),
'#default_value' => isset($defaults['method']) ? $defaults['method'] : array(),
);
$options['distinct'] = array(
'#title' => t('Number of distinct sizes'),
'#type' => 'textfield',
'#default_value' => isset($defaults['distinct']) ? $defaults['distinct'] : array(),
);
$options['fields'] = array(
'#title' => t('Fields'),
'#description' => t('Enter a comma separated list of attribute fields that can be used for scaling points. The first found attribute will be used.'),
'#type' => 'textfield',
'#default_value' => isset($defaults['fields']) ? $defaults['fields'] : array(),
);
$options['min_label'] = array(
'#tree' => TRUE,
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#type' => 'textfield',
'#title' => t('Minimum weight point to label'),
'#default_value' => isset($defaults['min_label']) ? $defaults['min_label'] : array(),
'#description' => t('Don\'t show labels below a certain point weight'),
);
return $options;
}
/**
* Generate weight segments from the number of distinct values.
*/
function get_weights() {
if (!is_numeric($this->options['distinct']) || $this->options['distinct'] < 1) {
$this->options['distinct'] = 5;
}
$size = number_format(1 / $this->options['distinct'], 2);
$weights = array();
for ($i = 1; $i < $this->options['distinct']; $i++) {
$key = (string) ($i * $size);
$weights[$key] = $i;
}
$weights[1] = $this->options['distinct'];
return $weights;
}
/**
* Generate a weight => pointRadius mapping.
*/
function get_styles() {
$weights = array_values($this->get_weights());
$styles = array();
foreach (array_keys($this->options['min']) as $key) {
if ($key !== 'value' && (!empty($this->options['min'][$key]) || !empty($this->options['max'][$key]))) {
$pointdiff = ($this->options['max'][$key] - $this->options['min'][$key]) / $this->options['distinct'];
$pointdiff = number_format($pointdiff, 2);
foreach ($weights as $weight) {
$styles[$weight][$key] = $this->options['min'][$key] + ($weight - 1) * $pointdiff;
if ($weight <= $this->options['min_label']) {
$styles[$weight]['label'] = '';
}
}
$styles[$this->options['distinct']][$key] = $this->options['max'][$key];
}
}
return $styles;
}
/**
* Retrieve the first found usable field from a set of features.
*/
protected function get_field($features) {
$fields = explode(',', $this->options['fields']);
foreach ($fields as $k => $v) {
$fields[$k] = trim($v);
}
foreach ($features as $feature) {
foreach ($fields as $field) {
if (isset($feature['attributes'][$field])) {
return $field;
}
}
}
return FALSE;
}
protected function get_layers($layers) {
$vector_layers = array();
foreach ($layers as $key => $layer) {
// get type == Vector for backwards-compatibility.
// TODO: After OpenLayers alpha8 it should be removed
if (((isset($layer['vector']) && $layer['vector'] == 1)) && !empty($layer['features'])) {
$vector_layers[$key] = $layer;
}
}
return $vector_layers;
}
protected function process_weight($ratio, $method) {
switch ($method) {
case 'radius':
return $ratio;
case 'area':
default:
return sqrt($ratio);
}
}
/**
* Render.
*/
function render(&$map) {
// Get the layers we are going to use.
$layers = $this->get_layers($map['layers']);
$get_min = $this->options['min']['value'] === '' || !isset($this->options['min']['value']);
$get_max = $this->options['max']['value'] === '' || !isset($this->options['max']['value']);
$weights = $this->get_weights();
foreach ($layers as $k => $layer) {
// Get the field we are going to use.
if ($field = $this->get_field($layer['features'])) {
// Get min/max per layer.
$min = isset($this->options['min']['value']) && is_numeric($this->options['min']['value']) ? $this->options['min']['value'] : 1000000;
$max = isset($this->options['max']['value']) && is_numeric($this->options['max']['value']) ? $this->options['max']['value'] : 0;
$count_min = 1000000;
$count_max = 0;
if ($get_min || $get_max) {
foreach ($layer['features'] as $j => $feature) {
if ($field && isset($feature['attributes'][$field]) && $count = $feature['attributes'][$field]) {
// Replace the count attribute with the selected one.
if ($field !== 'count') {
$map['layers'][$k]['features'][$j]['attributes']['count'] = $count;
}
$max = ($count > $max) && $get_max ? $count : $max;
$min = ($count < $min) && $get_min ? $count : $min;
$count_max = ($count > $count_max) ? $count : $count_max;
$count_min = ($count < $count_min) ? $count : $count_min;
}
}
}
// Sensible defaults code right here: If count_max & count_min are both under 1,
// assume data source is doing a ratio calc for us. Set max to 1.
if ($count_max < 1 && $count_min < 1) {
$max = 1;
}
foreach ($layer['features'] as $j => $feature) {
if ($field && isset($feature['attributes'][$field]) && $count = $feature['attributes'][$field]) {
// For layers with only a single value always use the smallest weight.
if ($count_max === $count_min) {
$map['layers'][$k]['features'][$j]['attributes']['weight'] = 1;
}
// Otherwise iterate through to find the right weight.
else {
$calculated = $this->process_weight(($count - $min) / ($max - $min), $this->options['method']);
foreach ($weights as $percentile => $weight) {
if ($calculated <= $percentile) {
$map['layers'][$k]['features'][$j]['attributes']['weight'] = $weight;
break;
}
}
}
}
}
}
}
drupal_add_js(drupal_get_path('module', 'openlayers_plus') . '/behaviors/openlayers_plus_behavior_scalepoints.js');
$options = array();
$options['styles'] = $this->get_styles();
return $options;
}
}

View File

@@ -0,0 +1,36 @@
/**
* Implementation of Drupal behavior.
*/
Drupal.behaviors.openlayers_plus_behavior_scalepoints = function(context) {
var data = $(context).data('openlayers');
if (data && data.map.behaviors.openlayers_plus_behavior_scalepoints) {
var styles = data.map.behaviors.openlayers_plus_behavior_scalepoints.styles;
// Collect vector layers
var vector_layers = [];
for (var key in data.openlayers.layers) {
var layer = data.openlayers.layers[key];
if (layer.isVector === true) {
var styleMap = layer.styleMap;
styleMap.addUniqueValueRules("default", "weight", styles);
layer.redraw();
vector_layers.push(layer);
}
}
/**
* This attempts to fix a problem in IE7 in which points
* are not displayed until the map is moved.
*
* Since namespaces is filled neither on window.load nor
* document.ready, and testing it is unsafe, this renders
* map layers after 500 milliseconds.
*/
if($.browser.msie) {
setTimeout(function() {
$.each(data.openlayers.getLayersByClass('OpenLayers.Layer.Vector'),
function() {
this.redraw();
});
}, 500);
}
}
};

View File

@@ -0,0 +1,48 @@
<?php
class openlayers_plus_behavior_themeregion extends openlayers_behavior {
/**
* Override of options_init().
*/
function options_init() {
$options = array(
);
return $options;
}
/**
* Override of options_form().
*/
function options_form($defaults) {
return array(
'regions' => array(
'#type' => 'checkboxes',
'#title' => t('Select Regions'),
'#options' => system_region_list(variable_get('theme_default'), REGIONS_ALL),
'#default_value' => isset($defaults['regions']) ? $defaults['regions'] : array(),
'#description' => t('Select the region(s) you want to move in the map. You will have to edit the CSS to make this work nicely with more than 1 region.')
),
'prefix' => array(
'#type' => 'textfield',
'#title' => t('CSS Prefix'),
'#default_value' => isset($defaults['prefix']) ? $defaults['prefix'] : '#',
'#description' => t('Prefix for the CSS identifier of the Regions div in your theme.')
),
'suffix' => array(
'#type' => 'textfield',
'#title' => t('CSS Suffix'),
'#default_value' => isset($defaults['suffix']) ? $defaults['suffix'] : '',
'#description' => t('Suffix for the CSS identifier of the Regions div in your theme.')
),
);
}
/**
* Render.
*/
function render(&$map) {
drupal_add_js(drupal_get_path('module', 'openlayers_plus')
. '/behaviors/openlayers_plus_behavior_themeregion.js');
return $this->options;
}
}

View File

@@ -0,0 +1,58 @@
/**
* Implementation of Drupal behavior.
*/
//Drupal.behaviors.openlayers_plus_behavior_themeregion = function(context) {
// Drupal.OpenLayersPlusthemeregion.attach(context);
//};
(function($) {
/**
* Implementation of Drupal behavior.
*/
//Drupal.behaviors.openlayers_plus_behavior_themeregion = function(context) {
Drupal.openlayers.addBehavior('openlayers_plus_behavior_themeregion', function (data, options) {
Drupal.OpenLayersPlusthemeregion.attach(data, options);
});
/**
* themeregion is **NOT** an OpenLayers control.
*/
Drupal.OpenLayersPlusthemeregion = {};
Drupal.OpenLayersPlusthemeregion.layerStates = [];
/**
* Initializes the themeregion and attaches to DOM elements.
*/
Drupal.OpenLayersPlusthemeregion.attach = function(data, options) {
/**
* Initializes the themeregion and attaches to DOM elements.
*/
if (data && data.map.behaviors.openlayers_plus_behavior_themeregion) {
for (regionkey in options.regions) {
if (regionkey != 0) {
if (options.regions[regionkey]) {
region = options.regions[regionkey].replace('_', '-').toLowerCase();
var cssid = options.prefix + region + options.suffix;
if ($(cssid).length > 0) {
$(data.openlayers.viewPortDiv).append($(cssid));
$(cssid).addClass('olControlNoSelect');
$(cssid).addClass('openlayers_plus-themeregion');
$(cssid).css('position', 'absolute'); // we need to do this because some themes override this with the id of the region
}
}
}
}
// Don't propagate click events to the map
// this doesn't catch events that are below the layer list
$('div.block-openlayers_plus-themeregion *').mousedown(function(evt) {
OpenLayers.Event.stop(evt);
});
}
};
})(jQuery);

View File

@@ -0,0 +1,31 @@
<?php
class openlayers_plus_behavior_tooltips extends openlayers_behavior {
/**
* Override of options_init().
*/
function options_init() {
return array('positioned' => FALSE);
}
/**
* Override of options_form().
*/
function options_form($defaults) {
return array(
'positioned' => array(
'#type' => 'checkbox',
'#title' => t('Position tooltip over feature'),
'#default_value' => isset($defaults['positioned']) ? $defaults['positioned'] : array(),
),
);
}
/**
* Render.
*/
function render(&$map) {
drupal_add_js(drupal_get_path('module', 'openlayers_plus') . '/behaviors/openlayers_plus_behavior_tooltips.js');
return $this->options;
}
}

View File

@@ -0,0 +1,104 @@
(function ($) {
/**
* Implementation of Drupal behavior.
*/
Drupal.behaviors.openlayers_plus_behavior_tooltips = function(context) {
Drupal.OpenLayersTooltips.attach(context);
};
Drupal.OpenLayersTooltips = {};
Drupal.OpenLayersTooltips.attach = function(context) {
var data = $(context).data('openlayers');
if (data && data.map.behaviors.openlayers_plus_behavior_tooltips) {
// Options
var select_method = 'select';
if (data.map.behaviors.openlayers_plus_behavior_tooltips.positioned) {
select_method = 'positionedSelect';
}
// Collect vector layers
var vector_layers = [];
for (var key in data.openlayers.layers) {
var layer = data.openlayers.layers[key];
if (layer.isVector === true) {
vector_layers.push(layer);
}
}
// Add control
var control = new OpenLayers.Control.SelectFeature(vector_layers, {
activeByDefault: true,
highlightOnly: false,
onSelect: Drupal.OpenLayersTooltips.select,
onUnselect: Drupal.OpenLayersTooltips.unselect,
multiple: false,
hover: true,
callbacks: {
'click': Drupal.OpenLayersTooltips.click,
'over': Drupal.OpenLayersTooltips[select_method],
'out': Drupal.OpenLayersTooltips.unselect
}
});
data.openlayers.addControl(control);
control.activate();
}
};
Drupal.OpenLayersTooltips.click = function(feature) {
var html = '';
if (feature.attributes.name) {
html += feature.attributes.name;
}
if (feature.attributes.description) {
html += feature.attributes.description;
}
// @TODO: Make this a behavior option and allow interaction with other
// behaviors like the MN story popup.
var link;
if ($(html).is('a')) {
link = $(html);
}
else if ($(html).children('a').size() > 0) {
link = $(html).children('a')[0];
}
if (link) {
var href = $(link).attr('href');
if (Drupal.OpenLayersPermalink && Drupal.OpenLayersPermalink.addQuery) {
href = Drupal.OpenLayersPermalink.addQuery(href);
}
window.location = href;
return false;
}
return;
};
Drupal.OpenLayersTooltips.getToolTip = function(feature) {
var text = "<div class='openlayers-tooltip'>";
if (feature.attributes.name) {
text += "<div class='openlayers-tooltip-name'>" + feature.attributes.name + "</div>";
}
if (feature.attributes.description) {
text += "<div class='openlayers-tooltip-description'>" + feature.attributes.description + "</div>";
}
text += "</div>";
return $(text);
}
Drupal.OpenLayersTooltips.select = function(feature) {
var tooltip = Drupal.OpenLayersTooltips.getToolTip(feature);
$(feature.layer.map.div).append(tooltip);
};
Drupal.OpenLayersTooltips.positionedSelect = function(feature) {
var tooltip = Drupal.OpenLayersTooltips.getToolTip(feature);
var point = new OpenLayers.LonLat(feature.geometry.x, feature.geometry.y);
var offset = feature.layer.getViewPortPxFromLonLat(point);
$(tooltip).css({zIndex: '1000', position: 'absolute', left: offset.x, top: offset.y});
$(feature.layer.map.div).css({position:'relative'}).append(tooltip);
};
Drupal.OpenLayersTooltips.unselect = function(feature) {
$(feature.layer.map.div).children('div.openlayers-tooltip').fadeOut('fast', function() { $(this).remove(); });
};
})(jQuery);

View File

@@ -0,0 +1,45 @@
<?php
class openlayers_plus_behavior_tooltips_field extends openlayers_behavior {
/**
* Override of options_init().
*/
function options_init() {
return array('positioned' => FALSE);
}
/**
* Override of options_form().
*/
function options_form() {
$form = parent::options_form();
$form['positioned'] = array(
'#type' => 'checkbox',
'#title' => t('Position tooltip over feature displaying specific field'),
'#default_value' => $this->options['positioned'],
);
$form['field_displayed'] = array(
'#type' => 'textfield',
'#title' => t('Field to Display'),
'#description' => t('Field from openlayers view to be displayed. (usually field_your_special_field)'),
'#default_value' => isset($this->options['field_displayed'])
? $this->options['field_displayed'] : NULL
);
return $form;
}
/**
* Render.
*/
function render(&$map) {
$settings = array(
'openlayers_plus_behavior_tooltips_field' => array(
'field' => "field_category",
),
);
drupal_add_js($settings, array('type' => 'setting'));
drupal_add_js(drupal_get_path('module', 'openlayers_plus')
. '/behaviors/openlayers_plus_behavior_tooltips_field.js');
return $this->options;
}
}

View File

@@ -0,0 +1,129 @@
(function($) {
/**
* Implementation of Drupal behavior.
*/
Drupal.behaviors.openlayers_plus_behavior_tooltips_field = {
'attach': function(context, settings) {
Drupal.OpenLayersTooltips.attach(context);
}
};
Drupal.OpenLayersTooltips = {};
Drupal.OpenLayersTooltips.attach = function(context) {
var data = $(context).data('openlayers');
var isVector = function(layer) {
if (layer.__proto__) {
return layer.__proto__.CLASS_NAME === 'OpenLayers.Layer.Vector';
}
else if (layer.CLASS_NAME) {
return layer.CLASS_NAME === 'OpenLayers.Layer.Vector';
}
};
if (data && data.map.behaviors.openlayers_plus_behavior_tooltips_field) {
// Options
var select_method = (data.map.behaviors
.openlayers_plus_behavior_tooltips_field.positioned) ?
'positionedSelect' : 'select';
// Collect vector layers
var vector_layers = [];
for (var key in data.openlayers.layers) {
var layer = data.openlayers.layers[key];
if (isVector(layer)) {
vector_layers.push(layer);
}
}
Drupal.settings.openlayers_plus_behavior_tooltips_field.field = data.map.behaviors.openlayers_plus_behavior_tooltips_field.field_displayed;
// Add control
var control = new OpenLayers.Control.SelectFeature(vector_layers, {
activeByDefault: true,
highlightOnly: false,
onSelect: Drupal.OpenLayersTooltips.select,
onUnselect: Drupal.OpenLayersTooltips.unselect,
multiple: false,
hover: true,
callbacks: {
'click': Drupal.OpenLayersTooltips.click,
'over': Drupal.OpenLayersTooltips[select_method],
'out': Drupal.OpenLayersTooltips.unselect
}
});
data.openlayers.addControl(control);
control.activate();
}
};
Drupal.OpenLayersTooltips.click = function(feature) {
var html = '';
if (feature.attributes.name) {
html += feature.attributes.name;
}
if (feature.attributes.description) {
html += feature.attributes.description;
}
// @TODO: Make this a behavior option and allow interaction with other
// behaviors like the MN story popup.
var link;
if ($(html).is('a')) {
link = $(html);
}
else if ($('a', html).size() > 0) {
link = $('a', html);
}
if (link) {
var href = $(link).attr('href');
if (Drupal.OpenLayersPermalink &&
Drupal.OpenLayersPermalink.addQuery) {
href = Drupal.OpenLayersPermalink.addQuery(href);
}
window.location = href;
return false;
}
return;
};
Drupal.OpenLayersTooltips.getToolTip = function(feature) {
var field = Drupal.settings.openlayers_plus_behavior_tooltips_field.field
var text = "<div class='openlayers-tooltip'>";
if (typeof feature.cluster != 'undefined') {
text += "<div class='openlayers-tooltip-name'>" +
feature.cluster[0].attributes[field] + " (" + feature.attributes.count + ")</div>";
}
else if (typeof feature.attributes[field] != 'undefined') {
text += "<div class='openlayers-tooltip-name'>" +
feature.attributes[field] + "</div>";
}
text += "</div>";
return $(text);
}
Drupal.OpenLayersTooltips.select = function(feature) {
var tooltip = Drupal.OpenLayersTooltips.getToolTip(feature);
$(feature.layer.map.div).append(tooltip);
};
Drupal.OpenLayersTooltips.positionedSelect = function(feature) {
var tooltip = Drupal.OpenLayersTooltips.getToolTip(feature);
var point = new OpenLayers.LonLat(
feature.geometry.x,
feature.geometry.y);
var offset = feature.layer.getViewPortPxFromLonLat(point);
$(tooltip).css({
zIndex: '1000',
position: 'absolute',
left: (offset.x - 60),
top: (offset.y - 50)});
$(feature.layer.map.div).css({position:'relative'})
.append(tooltip);
};
Drupal.OpenLayersTooltips.unselect = function(feature) {
$(feature.layer.map.div).children('div.openlayers-tooltip')
.fadeOut('fast', function() {
$(this).remove();
});
};
})(jQuery);

View File

@@ -0,0 +1,21 @@
; $Id$
core = 7.x
name = "OpenLayers Plus"
dependencies[] = "openlayers"
description = "Additional tools and behaviors for OpenLayers"
package = "OpenLayers"
files[] = behaviors/openlayers_plus_behavior_blockswitcher.inc
files[] = behaviors/openlayers_plus_behavior_blocktoggle.inc
files[] = behaviors/openlayers_plus_behavior_legend.inc
files[] = behaviors/openlayers_plus_behavior_permalink.inc
files[] = behaviors/openlayers_plus_behavior_popup.inc
files[] = behaviors/openlayers_plus_behavior_scalepoints.inc
files[] = behaviors/openlayers_plus_behavior_tooltips.inc
; Information added by drupal.org packaging script on 2012-09-12
version = "7.x-1.x-dev"
core = "7.x"
project = "openlayers_plus"
datestamp = "1347454371"

View File

@@ -0,0 +1,175 @@
<?php
/**
* Implements hook_block_info().
*/
function openlayers_plus_block_info() {
$blocks = array(
'blockswitcher' => array('info' => t('OL+ Blockswitcher')),
'blocktoggle' => array('info' => t('OL+ BlockToggle'))
);
return $blocks;
}
/**
* Implements hook_block_view().
*/
function openlayers_plus_block_view($delta) {
switch ($delta) {
case 'blockswitcher':
return array(
'subject' => t('Map layers'),
'content' => Array('#theme' =>'openlayers_plus_blockswitcher'),
);
case 'blocktoggle':
// TODO Please change this theme call to use an associative array for the $variables parameter.
return array(
'subject' => t('Map layers'),
'content' => Array('#theme' =>'openlayers_plus_blocktoggle'),
);
}
}
/**
* Implements hook_theme().
*/
function openlayers_plus_theme() {
return array(
'openlayers_plus_blockswitcher' => array(
'variables' => array(),
'path' => drupal_get_path('module', 'openlayers_plus') . '/theme',
'template' => 'openlayers-plus-blockswitcher',
'file' => 'theme.inc',
),
'openlayers_plus_blocktoggle' => array(
'variables' => array(
'a_label' => '',
'b_label' => '',
),
'path' => drupal_get_path('module', 'openlayers_plus') . '/theme',
'template' => 'openlayers-plus-blocktoggle',
'file' => 'theme.inc',
),
'openlayers_plus_legend_raw' => array(
'variables' => array(
'raw' => '',
'layer' => array(),
'layer_id' => array(),
),
'path' => drupal_get_path('module', 'openlayers_plus') . '/theme',
'template' => 'openlayers-plus-legend-raw',
'file' => 'theme.inc',
),
'openlayers_plus_legend' => array(
'variables' => array(
'legend' => array(),
'layer' => array(),
'layer_id' => array(),
),
'path' => drupal_get_path('module', 'openlayers_plus') . '/theme',
'template' => 'openlayers-plus-legend',
'file' => 'theme.inc',
),
);
}
/**
* Implements hook_openlayers_behaviors().
*
* This is a ctools plugins hook.
*/
function openlayers_plus_openlayers_behaviors() {
return array(
'openlayers_plus_behavior_blockswitcher' => array(
'title' => t('OL+: Blockswitcher'),
'description' => t('A clone of LayerSwitcher, with better themability and positioning via the Drupal block system.'),
'behavior' => array(
'path' => drupal_get_path('module', 'openlayers_plus') . '/behaviors',
'file' => 'openlayers_plus_behavior_blockswitcher.inc',
'class' => 'openlayers_plus_behavior_blockswitcher',
'parent' => 'openlayers_behavior',
),
),
'openlayers_plus_behavior_blocktoggle' => array(
'title' => t('OL+: Blocktoggle'),
'description' => t('A version of BlockSwitcher that toggles between two different layers only. Useful for situations in which layers represent the same data in slightly different ways.'),
'behavior' => array(
'path' => drupal_get_path('module', 'openlayers_plus') . '/behaviors',
'file' => 'openlayers_plus_behavior_blocktoggle.inc',
'class' => 'openlayers_plus_behavior_blocktoggle',
'parent' => 'openlayers_behavior',
),
),
'openlayers_plus_behavior_themeregion' => array(
'title' => t('OL+: Theme Region'),
'description' => t('Inserts Drupal Theme Regions on top of the map.'),
'behavior' => array(
'path' => drupal_get_path('module', 'openlayers_plus') . '/behaviors',
'file' => 'openlayers_plus_behavior_themeregion.inc',
'class' => 'openlayers_plus_behavior_themeregion',
'parent' => 'openlayers_behavior',
),
),
'openlayers_plus_behavior_legend' => array(
'title' => t('OL+: Map legend'),
'description' => t('A block in a corner of a map that provides information on layers.'),
'behavior' => array(
'path' => drupal_get_path('module', 'openlayers_plus') . '/behaviors',
'file' => 'openlayers_plus_behavior_legend.inc',
'class' => 'openlayers_plus_behavior_legend',
'parent' => 'openlayers_behavior',
),
),
'openlayers_plus_behavior_permalink' => array(
'title' => t('OL+: Permalink'),
'description' => t('A version of Permalink optimized to persist layers between pages with different layer setups and without explicitly using the control.'),
'behavior' => array(
'path' => drupal_get_path('module', 'openlayers_plus') . '/behaviors',
'file' => 'openlayers_plus_behavior_permalink.inc',
'class' => 'openlayers_plus_behavior_permalink',
'parent' => 'openlayers_behavior',
),
),
'openlayers_plus_behavior_scalepoints' => array(
'title' => t('OL+: Scalepoints'),
'description' => t('Dynamic styling, changing point radii based on a certain value.'),
'behavior' => array(
'path' => drupal_get_path('module', 'openlayers_plus') . '/behaviors',
'file' => 'openlayers_plus_behavior_scalepoints.inc',
'class' => 'openlayers_plus_behavior_scalepoints',
'parent' => 'openlayers_behavior',
),
),
'openlayers_plus_behavior_tooltips' => array(
'title' => t('OL+: Tooltips'),
'description' => t('An interaction with point-based maps that results in following links on hover.'),
'behavior' => array(
'path' => drupal_get_path('module', 'openlayers_plus') . '/behaviors',
'file' => 'openlayers_plus_behavior_tooltips.inc',
'class' => 'openlayers_plus_behavior_tooltips',
'parent' => 'openlayers_behavior',
),
),
'openlayers_plus_behavior_tooltips_field' => array(
'title' => t('OL+: Tooltips Field'),
'description' => t('An interaction with point-based maps that results in following links on hover that you specify the field.'),
'behavior' => array(
'path' => drupal_get_path('module', 'openlayers_plus') . '/behaviors',
'file' => 'openlayers_plus_behavior_tooltips_field.inc',
'class' => 'openlayers_plus_behavior_tooltips_field',
'parent' => 'openlayers_behavior',
),
),
'openlayers_plus_behavior_popup' => array(
'title' => t('OL+: Popups'),
'description' => t('An interaction with point-based, clustered maps that allows clicking on points that results in scanning between items.'),
'behavior' => array(
'path' => drupal_get_path('module', 'openlayers_plus') . '/behaviors',
'file' => 'openlayers_plus_behavior_popup.inc',
'class' => 'openlayers_plus_behavior_popup',
'parent' => 'openlayers_behavior',
),
),
);
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 318 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 291 B

View File

@@ -0,0 +1,21 @@
<div class='openlayers_plus-blockswitcher olControlNoSelect clear-block'>
<div class='layers base'>
<h2 class='layers-title'><?php print t('Base layers') ?></h2>
<div class='layers-content'>
</div>
</div>
<div class='layers data'>
<h2 class='layers-title'><?php print t('Data layers') ?></h2>
<div class='layers-content'>
</div>
</div>
<div style='display:none' class='factory'>
<div class='form-item form-option radio'>
<label class='option'></label>
</div>
<div class='form-item form-option checkbox'>
<label class='option'><span class='key'></span><input class='form-checkbox' type='checkbox'/></label>
</div>
</div>
</div>

View File

@@ -0,0 +1,13 @@
<?php
// $Id$
/**
* @param $a_label first layer text
* @param $b_label second layer text
*/
?>
<div class='olControlNoSelect block-openlayers_plus-blocktoggle clear-block'>
<div class='openlayers-blocktoggle-a activated'>
</div>
<div class='openlayers-blocktoggle-b'>
</div>
</div>

View File

@@ -0,0 +1,11 @@
<?php
// $Id$
/**
* @param $layer_id The layer's id
* @param $layer layer array
* @param $raw raw html for the legend
*/
?>
<div class='legend legend-count-<?php print count($legend) ?> clear-block' id='openlayers-legend-<?php print $layer_id ?>'>
<?php print $raw; ?>
</div>

View File

@@ -0,0 +1,19 @@
<?php
// $Id$
/**
* @param $layer_id The layer's id
* @param $layer layer array
* @param $legend an array of legend items
*/
?>
<div class='legend legend-count-<?php print count($legend) ?> clear-block' id='openlayers-legend-<?php print $layer_id ?>'>
<?php if (!empty($layer['title'])): ?>
<h2 class='legend-title'><?php print check_plain($layer['title']) ?></h2>
<?php endif; ?>
<?php foreach ($legend as $key => $item): ?>
<div class='legend-item clear-block'>
<span class='swatch' style='background-color:<?php print check_plain($item['color']) ?>'></span>
<?php print check_plain($item['title']) ?>
</div>
<?php endforeach; ?>
</div>

View File

@@ -0,0 +1,27 @@
/**
* Blockswitcher ======================================================
*/
.openlayers-blockswitcher span.key {
float:right;
margin-right:0px;
margin-left:5px;
}
.openlayers-blockswitcher input.form-radio,
.openlayers-blockswitcher input.form-checkbox {
margin-right:0px;
margin-left:5px;
}
div.openlayers-map #block-openlayers_plus-blockswitcher.ne { right:auto; left:0px; }
div.openlayers-map #block-openlayers_plus-blockswitcher.nw { left:auto; right:0px; }
div.openlayers-map #block-openlayers_plus-blockswitcher.se { right:auto; left:0px; }
div.openlayers-map #block-openlayers_plus-blockswitcher.sw { left:auto; right:0px; }
/**
* Blocktoggle ========================================================
*/
div.openlayers-map #block-openlayers_plus-blocktoggle.ne { right:auto; left:0px; }
div.openlayers-map #block-openlayers_plus-blocktoggle.nw { left:auto; right:0px; }
div.openlayers-map #block-openlayers_plus-blocktoggle.se { right:auto; left:0px; }
div.openlayers-map #block-openlayers_plus-blocktoggle.sw { left:auto; right:0px; }

View File

@@ -0,0 +1,130 @@
/**
* Legend =============================================================
*/
.openlayers-legends {
position:absolute;
left:5px;
bottom:5px;
z-index:3000;
}
.openlayers-legends .legend {
background:#fff;
-moz-border-radius:3px;
-webkit-border-radius:3px;
}
.openlayers-legends .swatch {
float:left;
display:block;
width:15px;
height:15px;
margin-right:5px;
}
/**
* Blockswitcher ======================================================
*/
.openlayers-blockswitcher span.key {
display:block;
float:left;
height:20px;
width:20px;
margin-right:5px;
}
.openlayers-blockswitcher input.form-radio,
.openlayers-blockswitcher input.form-checkbox { margin-right:5px; }
div.openlayers-map .openlayers_plus-blockswitcher {
position:absolute;
z-index:3000;
background:#fff;
width:auto;
}
div.openlayers-map .openlayers_plus-blockswitcher.ne { top:0px; right:0px; }
div.openlayers-map .openlayers_plus-blockswitcher.nw { top:0px; left:0px; }
div.openlayers-map .openlayers_plus-blockswitcher.se { bottom:0px; right:0px; }
div.openlayers-map .openlayers_plus-blockswitcher.sw { bottom:0px; left:0px; }
.openlayers_plus-blockswitcher h2.block-title { cursor:pointer; }
.openlayers_plus-blockswitcher div.block-content { display:none; }
.openlayers_plus-blockswitcher div.radio {
background: #fff url('inactive.png');
background-repeat: no-repeat;
padding: 3px 0 3px 25px;
}
.openlayers_plus-blockswitcher div.activated {
background: #fff url('active.png');
background-repeat: no-repeat;
padding: 3px 0 3px 25px;
}
/**
* Blocktoggle ========================================================
*/
div.openlayers-map .block-openlayers_plus-blocktoggle {
position:absolute;
z-index:3001;
background:transparent;
width:auto;
padding: 0;
-moz-border-radius:3px;
-webkit-border-radius:3px;
}
div.openlayers-map .block-openlayers_plus-blocktoggle.ne { top:0px; right:0px; }
div.openlayers-map .block-openlayers_plus-blocktoggle.nw { top:0px; left:0px; }
div.openlayers-map .block-openlayers_plus-blocktoggle.se { bottom:0px; right:0px; }
div.openlayers-map .block-openlayers_plus-blocktoggle.sw { bottom:0px; left:0px; }
.block-openlayers_plus-blocktoggle h2.block-title { display:none; }
.block-openlayers_plus-blocktoggle .openlayers-blocktoggle-a,
.block-openlayers_plus-blocktoggle .openlayers-blocktoggle-b {
float:left;
color:#666;
background:url('point-button.png') #fff 5px 50% no-repeat;
padding:0px 5px 0px 20px;
line-height:20px;
width:50px;
cursor:pointer;
}
.block-openlayers_plus-blocktoggle .openlayers-blocktoggle-a {
-moz-border-radius: 3px 0 0 3px;
-webkit-border-radius: 3px 0 0 3px;
border-right:1px solid #ccc;
}
.block-openlayers_plus-blocktoggle .openlayers-blocktoggle-b {
-moz-border-radius: 0 3px 3px 0;
-webkit-border-radius: 0 3px 3px 0;
background-image:url('point-choro.png');
}
.block-openlayers_plus-blocktoggle .activated {
background-color:#eee;
color:#222;
}
/**
* Sample themeregion css. You probably want to override this *
*/
.openlayers_plus-themeregion {
z-index: 1000; /* this is tricky, the layers are 999, the first OpenLayers control is 1001 */
position: absolute; /* We do this in code, too, as some themes position the region by ID, so we lose */
}
/*
** For sample purposes, place the selected region at the top of the map
** If you select more regions, that wont work too well.
*/
.openlayers_plus-themeregion.olControlNoSelect {
top:0px; right:0px;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 291 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 166 B

View File

@@ -0,0 +1,24 @@
<?php
/**
* Preprocessor for theme('openlayers_plus_blockswitcher').
*/
function template_preprocess_openlayers_plus_blockswitcher(&$vars) {
drupal_add_css(drupal_get_path('module', 'openlayers_plus') . '/theme/openlayers_plus.css');
}
/**
* Preprocessor for theme('openlayers_plus_legend').
*/
function template_preprocess_openlayers_plus_legend(&$vars) {
drupal_add_css(drupal_get_path('module', 'openlayers_plus') . '/theme/openlayers_plus.css');
}
/**
* Preprocessor for theme('openlayers_plus_legend').
*/
function template_preprocess_openlayers_plus_blocktoggle(&$vars) {
drupal_add_css(drupal_get_path('module', 'openlayers_plus') . '/theme/openlayers_plus.css');
$vars['points'] = t('Points');
$vars['shading'] = t('Shading');
}