diff --git a/README.txt b/README.txt deleted file mode 100644 index a136cfc11af2eaeab81cfb5e2ce5d8ec58d40245..0000000000000000000000000000000000000000 --- a/README.txt +++ /dev/null @@ -1,123 +0,0 @@ -Current for 7.x-2.0-beta1 -updated on 2012-08-24 - -# Description - -OpenLayers is a suite of module to help integrate the -OpenLayers Javascript library within Drupal. - -# Requirements - -OpenLayers Requires - -* CTools: http://drupal.org/project/ctools -* Libraries: https://drupal.org/project/libraries - Use the 2.x version, and make sure to create your sites/all/libraries subdirectory. -* GeoPhP https://drupal.org/project/geophp - -Sub-modules require - -* OpenLayers Views requires Views: http://drupal.org/project/views - -OpenLayers can use Features to package maps into modules - -* Features: http://drupal.org/project/features - -# Sub-Modules - -You'll most likely want to enable OpenLayers UI and OpenLayers Views modules for typical uses of OpenLayers. - -* OpenLayers UI - Creates a user interface to make map - arrays which can be used in various places -* Views - Allows data to be displayed on a map - via Views -* Filters - Creates a filter to replace - [openlayers map_name] with a map. - -# Basic Concepts - -## Maps - -An OpenLayers map in Drupal is a combination of decisions about which -layers to show, what styles to apply, the minimum and maximum zoom levels, -and how the user can interact with the map. A map object is where -the options for these settings are combined and stored. Maps can be -rendered through OpenLayers views of the type "OpenLayers Map," through -filters provided by the OpenLayers Filters module, or directly in your -modules using the api function openlayers_render_map() - -## Layers - -OpenLayers allows for the display of a variety of raster and vector data on -maps. These are divided into two categories: basemaps and overlays. -Basemaps, like those from OpenStreetMap or Google Maps, provide a background -for your data. Overlays can be data from OpenLayers data views, KML layers, -or other types of data from external sources. - -For more information on layer types, see docs/LAYER_TYPES.txt - -## Styles - -The OpenLayers module currently allows users to define custom styles for -vector overlays. The primary use-case here will be data from OpenLayers -data views but this could also include KML files. Styles define things like -stroke width, background and outline colors, and point size and allow the -use of icons if desired. They must be associated with layers on a per- -map basis. - -## Behaviors - -Behaviors can be enabled on maps to control how users interact with -the map. Examples of behaviors include navigation, which, when enabled, -allows users to zoom and pan, and Layer Switcher, which provides a UI that -allows users to toggle on and off the layers available on the map. - -## OpenLayers Views - -OpenLayers views come in two varieties. The first is a display type called -OpenLayers Data. This is what allows users to control which pieces of -content show up on the map and in what manner. Each OpenLayers data view -provides a layer that can be added to maps when configuring a map. The -second is a style called OpenLayers Map that can be applied to pages, -blocks, attachments, and so on and give users an easy way of rendering -maps. - -# Installation - -1. Normal Drupal module installation - -2. Set OpenLayers Source at: admin/structure/openlayers - It is suggested to download the library and use it locally for performance. - -3. A tutorial - - -# Documentation - -More documentation is available in the docs/ directory of this module: - -* CUSTOMIZATION.txt: a cookbook for common customizations users might want - to make for performance and tweaking - -* API.txt: a technical description of the main map-generating API - -* LAYER_TYPES.txt: a technical description of how layer types work and - guide for implementation of new layer types - -* KML.txt: an explanation of how KML support works in OpenLayers - -* JAVASCRIPT.txt: a technical explanation of how the Javascript included - in the OpenLayers module (not the code in the actual OpenLayers library) - operates - -A [tutorial is available on Drupal.org] (https://drupal.org/node/1481374) - -# Authors/Credits - -* [zzolo](http://drupal.org/user/147331) -* [phayes](http://drupal.org/user/47098) -* [tmcw](http://drupal.org/user/12664) -* [brynbellomy](http://drupal.org/user/537416) -* [bdragon](http://drupal.org/user/53081) -* [OpenLayers monster by Saman Bemel Benrud](http://www.flickr.com/photos/samanpwbb/) -* [strk](http://drupal.org/user/781486) -* [pol](https://drupal.org/user/47194) diff --git a/css/openlayers.css b/css/openlayers.css index 4737b98dc291bee5b6b49cf89fcda00538e4bffd..c434e1fc3f8ffdd899080058e38a3abb70754984 100644 --- a/css/openlayers.css +++ b/css/openlayers.css @@ -1,75 +1,12 @@ - -/** - * @file - * OpenLayers Main CSS - * - * This file holds the base CSS for the openlayers module - * - * @ingroup openlayers - */ - -.openlayers-cck-feature-selected { border: 2px solid blue; } - -.openlayers-map { - z-index:0; - position:relative; -} - -/** - * prevent rtl translations from mirroring - * vector layers - */ -.openlayers-map .olLayerDiv { - direction: ltr -} - -/** - * Controls - */ -.openlayers-controls { - z-index: 1000; -} - -body .olControlLayerSwitcher .layersDiv { - background-color: #222222; -} -body .olControlLayerSwitcher.legacy .layersDiv { - background-color: darkblue; -} - -body .olControlAttribution { - right: 5px; - bottom: 5px; -} - -/** - * This is a 'sensible default' for a weird decision - * by OpenLayers to make 404 tiles pink. - */ -body .olImageLoadError { - background: transparent; -} - -/* - * Do not display the close button on tooltips. - * See #1875844 - */ -.openlayers-container #tooltip #tooltip_close { - display: none; -} - -/* - * Make OpenLayers img tag behave correctly with responsive stuff. - * See #1816826 - */ -div.olPopup img, -div.olLayerDiv img.olTileImage { - max-width: none; +.openlayers-map .ol-mouse-position { + top: auto; + right: auto; + bottom: 0px; + left: 8px; + position: absolute; } -/* - * Fix #1904424 and #1646646. - */ -label.olButton { - display: inline; +.openlayers-map .ol-attribution ul { + margin: 0 0 0 0; + padding: 0 0 0 0; } diff --git a/docs/API.txt b/docs/API.txt deleted file mode 100644 index 65b3884a51d1e9eaf7defe7b1dda0abf9b55f657..0000000000000000000000000000000000000000 --- a/docs/API.txt +++ /dev/null @@ -1,36 +0,0 @@ - -Current for 6.x-2.0-alpha2 - -This file contains the main API functions for OpenLayers and its sub-modules. -Please refer to the project page for more up to date information and -documentation: - -* http://drupal.org/project/openlayers - - -# Advanced Help - -Browsable documentation is available through the [Advanced Help -module.](http://drupal.org/project/advanced_help) - - -# Map Build Process - -The parts to build a map - layers, behaviors, maps, and styles - are loaded -with menu loaders, like `openlayers_layer_export_load`. They should not be -loaded manually because menu loaders do the necessary instantiation and -cache-clearing. - -In 2.x, layers, behaviors, and styles contain more logic for 'rendering -themselves' than before, but cannot completely exist on their own. The functions -that iterate over included layers, behaviors, and styles are in -`openlayers.render.inc`. - -`openlayers_build_map` and `openlayers_render_map` are the two essential parts -of the actual map building and rendering, and are included in -`openlayers.module`. - -The map building process does not directly deal with map data: in the case that -Drupal is rendering data (as in openlayers_views), this functionality is -encapsulated in the `render()` method of the layer type. See -`modules/openlayers_views` for an example of how this works. diff --git a/docs/BEHAVIORS.txt b/docs/BEHAVIORS.txt deleted file mode 100644 index 09cc8c18a62ffb7129620fc3bc7fd2fd6201f148..0000000000000000000000000000000000000000 --- a/docs/BEHAVIORS.txt +++ /dev/null @@ -1,124 +0,0 @@ - -Current for 6.x-2.0-alpha6 - - -# Creating a new OpenLayers Behavior from Scratch - -First, you'll need to create a module. Of course, skip through this step if -there's already a module that exists to which this behavior will be added. But -if not, create a file called `modulename.info` with the contents - - core = "6.x" - dependencies[] = "openlayers" - name = "modulename" - package = "OpenLayers" - project = "modulename" - -In this case, you're creating a module just for this feature. So you'll need to -implement a hook to notify OpenLayers that your module can do something for it. -There's a hook called `hook_openlayers_behaviors` for this, and since your -module is called modulename, its implementation should be -`modulename_openlayers_behaviors`. A basic implementation would be - - function modulename_openlayers_behaviors() { - return array( - 'openlayers_behavior_mybehavior' => array( - 'title' => t('My Behavior'), - 'description' => t('Does something'), - 'type' => 'layer', - 'path' => drupal_get_path('module', 'modulename') - .'/includes/behaviors', - 'file' => 'openlayers_behavior_mybehavior.inc', - 'behavior' => array( - 'class' => 'openlayers_behavior_mybehavior', - 'parent' => 'openlayers_behavior', - ), - ), - ); - } - -Note the essentials here: this tells the OpenLayers module that there is a file -in `modules/modulename/includes/behaviors/` which implements a class called -`openlayers_behavior_mybehavior`. It isn't strictly necessary to create an -includes folder and a behaviors folder under it, but it's good practice so that -your module doesn't become cluttered. - -So on to the PHP that this hook refers to: usually there's only a small amount -of PHP written for each behavior. On the first level, the file simply must -include a class that extends the class openlayers_behavior: - - class openlayers_behavior_mybehavior extends openlayers_behavior {} - -There'll be a little bit for this one, but it's not very functional - only -adding JavaScript code and declaring forms. - -Here's what you'll write for this behavior: - - class openlayers_behavior_mybehavior extends openlayers_behavior {} - - function options_init() { - return array( - ); - } - - function options_form($defaults) { - return array( - 'filteredlayer' => array( - '#type' => 'select', - '#options' => $this->map['layers'], - '#description' => t('Select layer to filter'), - '#default_value' => isset($defaults['filteredlayer']) ? - $defaults['filteredlayer'] : NULL - ), - ); - } - - function render(&$map) { - drupal_add_js(drupal_get_path('module', 'mybehavior') - .'/includes/behaviors/js/openlayers_behavior_mybehavior.js'); - return $this->options; - } - } - -As you can see, there's an options_form method which is called when the list of -behaviors is generated for each map, and given a `$defaults` array if there -have already been values saved. It isn't required to implement this method, -although many behaviors will need it. And at this level - in the options_form, -you have access to the map object with $this - so you can get layers, styles, -and other parts of the map to play around with The `render(&$map)` function -is indeed required, since it is called for every behavior. - -There's quite a bit of Javascript to write for this behavior: - - /** - * Maptimeline Behavior - */ - Drupal.behaviors.openlayers_behavior_mybehavior = function(context) { - - var data = $(context).data('openlayers'); - var slider_div = {}; - if (data && data.map.behaviors['openlayers_behavior_mybehavior']) { - behavior = data.map.behaviors['openlayers_behavior_mybehavior']; - layer = data.openlayers.getLayersBy( - 'drupalID', - behavior.filteredlayer)[0]; - // Do things with this feature, etc. - }); - } - } - -Note the essentials of this file: all of the functionality needed is contained -in a single function, `Drupal.behaviors.openlayers_behavior_mybehavior`. The -facts that the containing function is called `openlayers_behavior_mybehavior` -and that it receives a single argument, `context`, are essential, but besides -those restrictions, behaviors can contain any Javascript code whatsoever. -Behaviors are called after all layers and styles are added to the map and the -map is rendered. - -This code demonstrates a few core concepts of behavior-writing: - -* The OpenLayers [Map object](http://dev.openlayers.org/releases/OpenLayers-2.8/doc/apidocs/files/OpenLayers/Map-js.html) - is accessible via `$(context).data('openlayers').openlayers` -* The [jQuery Data function](http://api.jquery.com/jQuery.data/) is used in the - OpenLayers module to simplify variable scope and avoid the possibility of - memory leaks. diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt deleted file mode 100644 index ff045ece2ccfad93299ba48f6a9087f2a85d9fe7..0000000000000000000000000000000000000000 --- a/docs/CHANGELOG.txt +++ /dev/null @@ -1,2 +0,0 @@ -This is maintained on Drupal.org at the following URL: -http://drupal.org/node/177400/release \ No newline at end of file diff --git a/docs/CUSTOMIZATION.txt b/docs/CUSTOMIZATION.txt deleted file mode 100644 index 147c28fac284be34dff186cca890512065b4eea3..0000000000000000000000000000000000000000 --- a/docs/CUSTOMIZATION.txt +++ /dev/null @@ -1,46 +0,0 @@ - -Current for 6.x-2.0-alpha3 - -Obviously there are many points at which advanced users will want to push the -limits of what the OpenLayers module can do. In many cases, these changes can be -make without any 'hacks' to the module, and before hacking, it is highly -recommended to think about ways that changes could be incorporated into the -module proper via patches. - -# Performance - -The largest performance hit of OpenLayers at the moment seems to be in the very -large size of the OpenLayers.js library. The real route to fixing this problem -is by narrowing down the set of components included in the Javascript file. In -order to do this: - -## Manually - - svn checkout http://svn.openlayers.org/trunk/openlayers/ cd openlayers/build - -edit full.cfg or lite.cfg to include the components your map uses. - - python build.py [yourcustomized.cfg] - -This will produce a compacted, slimmed OpenLayers.js file. - -After doing this, make sure to set the ImgPath and ThemePath in the OpenLayers -administration - these are per-map settings. The OpenLayers library guesses -the location of its style.css and images, so if you make a compacted -OpenLayers.js in an otherwise empty folder, it will fail in this task and have -blank images and a nonfunctional ZoomBox control (the red 'zooming box') will -not appear. - -## Map Performance - -Using multiple domain names for layers will [dodge the browser connection -limit](http://trac.openlayers.org/wiki/OpenLayersOptimization) and allow more -tiles to load in parallel. However, this has a bad interaction with the default -buffer setting, making tiles outside the viewport load first in many cases, so -buffer should be set to 0 if multiple urls are enabled. - -# Custom Behaviors - -If behaviors similar to those included are necessary, just clone the behaviors -and create a tiny new module that includes the copy. The same goes for layers, -etc. diff --git a/docs/IE.txt b/docs/IE.txt deleted file mode 100644 index 11501cd6e5475e9cf03e75c2818c858da7d270fa..0000000000000000000000000000000000000000 --- a/docs/IE.txt +++ /dev/null @@ -1,61 +0,0 @@ - -Using the OpenLayers Javascript from the OpenLayers module can present some -problems with rendering vector layers in IE. - -The root cause of the issue: - -Internet Explorer has a thing called VML: Vector Markup Language, which it uses -to draw graphics. VML is what you use in IE: canvas4ie is way slow, google maps -uses VML to draw routes, and OpenLayers uses it to draw vectors. - -VML elements are styled by creating CSS-like styles in a namespace. OpenLayers -creates an ol: namespace and then creates styles like ol:line ol:circle, etc. - -To do this, it has to access document.namespaces. Document.namespaces is not -always around: notably, you can't depend on it being around before -document.ready. - -But, sometimes document.namespaces *is* around before document.ready and that's -the thing that messed up my worldview. So, the theory was, there are modes. -Something in HTML can prevent document.namespaces being filled in before -document.ready. - -Here's how it goes. - -### $( or $(document).ready() - -* If there is a broken image on the page, then namespaces is not filled in. -* If the page has no broken images, then document.namespaces is accessible - -### document.load() - -* document.namespaces is always filled in. - -### 31 stylesheets - -IE cannot handle more than 31 stylesheets on a page at a time. This is clearly -the devil's work, but it persists beyond IE8. If there are 31 stylesheets and -you run an OpenLayers map, it cannot add another stylesheet to initialize its -VML namespace. Therefore, the map breaks. You must aggregate your CSS. - -### The Fix - -We can't move openlayers to document.load() because it is dependent on the -Drupal behaviors stack, that runs on document.ready(). We need to just define -document.namespaces before OpenLayers asks its VML renderer whether the current -browser is capable of rendering VML (a task it tries to complete by calling -!!(document.namespaces)) - -### Other Fixes - -Adding a tag - -will allow IE8 to render vectors if it doesn't render them correctly on a normal -pageload. Note that this must be the first element inside the header tag. - -### Image Opacity - -The opacity of image pointers are created with IE filters, which do not function -correctly when combined with semi-transparent PNG images. Thus it is necessary -to set opacity of such elements to 1.0 in order for alpha-transparent PNG images -to appear correctly. diff --git a/docs/JAVASCRIPT.txt b/docs/JAVASCRIPT.txt deleted file mode 100644 index 0393f405b6cd3b3a167b0c807a32f45bd271d487..0000000000000000000000000000000000000000 --- a/docs/JAVASCRIPT.txt +++ /dev/null @@ -1,34 +0,0 @@ - -Current for 6.x-2.0-alpha3 - -The OpenLayers module aims to add minimal abstraction in Javascript to what is -already provided by the [OpenLayers](http://openlayers.org/) Javascript library. -However, it does create certain structures that may not be immediately obvious. - -# Data Storage - -The module stores all settings initially under Drupal.settings.openlayers. It -does this in a slightly modified way if your server supports native JSON writing -- this basically means that, instead of using Drupal to encode the settings -array, it uses a PHP extension (written in C). This greatly increases -performance for displaying many points on maps. - -# Keeping Track of Maps - -The OpenLayers map object, which contains pointers to all layers, etc., is -stored with the [jQuery data() method](http://api.jquery.com/jQuery.data/), -which provides the phenomenal convenience of storing arbitrary data within the -DOM itself. This means that the map object is attached to the openlayers-map-0, -or so on, div element in your page. So, to access it, one could use a line like - - $('#openlayers-map-0').data('openlayers') - -In FireBug, Safari, or Chrome. - -Note that the 2.x branch strives to not duplicate map information: it exists in -the Drupal settings array and then is transformed into a map object, but after -that point, the canonical location for data about maps is in the map object. -This is for purposes of both flexibility, since the map object lets developers -access objects by better getter methods, and for the purpose of keeping -OpenLayers behaviors and layer initialization code less tied to Drupal than -before. diff --git a/docs/KML.txt b/docs/KML.txt deleted file mode 100644 index 8d600f3d3c736c98c36a854048a57288ed2669d6..0000000000000000000000000000000000000000 --- a/docs/KML.txt +++ /dev/null @@ -1,29 +0,0 @@ - -Current for 2.x - -# KML - -Many users find it necessary to include KML files on their websites, and often -KML files are located on remote servers; especially dynamic KML. However, the -core of the [XMLHttpRequest](http://en.wikipedia.org/wiki/XMLHttpRequest) -object, the Javascript convenience that allows AJAX to happen, prevents requests -across domains. - -This means that a site - - http://www.hello.com/ - -cannot load KML from - - http://world.com/ - -Without a special workaround. - -# Proxy Host - -For this, there is a special setting in every map called "Proxy Host." It is -in the 'General information' tab, at the bottom of the page. You can use any of -a number of [PHP -proxies](http://www.google.com/search?sourceid=chrome&ie=UTF-8&q=php+proxy) for -this purpose, or you can use the [proxy -module](http://drupal.org/project/proxy), which integrates with Drupal. diff --git a/docs/LAYER_TYPES.txt b/docs/LAYER_TYPES.txt deleted file mode 100644 index b984506ecac98c98a9bffdc6132332af46b5a001..0000000000000000000000000000000000000000 --- a/docs/LAYER_TYPES.txt +++ /dev/null @@ -1,78 +0,0 @@ - -Current for 6.x-2.x - -# Layer Types - -Layer types are one of the fundamental building blocks of the OpenLayers module. -They are factories for layers themselves - a layer type is like a wrapper around -an OpenLayers (javascript) object which lets you configure settings through the -UI and also encapsulate other tasks that layers need to do, like loading -information. - -## Structure - -Typically a layer type is a class that extends `openlayers_layer_type`, although -it can extend another layer type class if necessary. All that's really needed is -that it implements the right methods. Which are... - -* `render`: The `render(&$map)` function is called on each layer type when a map - is rendered. Since the map array is passed by reference, this function can - modify it in any way it wishes. However, typically render functions just - include layer javascript and then return their options array. -* `settings_form`: The settings form of a layer type is different from the - options form in two very important ways. The first, practical reason for their - separation is that layer type settings are settings that you'll want to set - for an entire website, like a Google Maps API key or javascript location. So, - these settings are not attached to individual layers. The other, technical - difference, is that, while layer *options* end up in the data array, which is - serialized and exported, etc., layer *settings* are saved as Drupal variables, - so that they can optionally intercepted by modules like Spaces, which allow - users to customize domain-specific settings (like API keys) by space. -* `options_form`: The options form of the layer is what the user sees when they - land on the layer add form. The results of this form submission are - automatically saved as the contents of the layer's 'data' property, which is - then sent to javascript and, depending on layer type, pushed into the - Javascript layer constructor. This means that exported layers can have more - properties than the OpenLayers Drupal Module knows about, and they will be - seamlessly pushed into Javascript and serve their function in Javascript-land. -* `options_init`: The options_init function defines the default options of any - given layer. This is used for options that will not be set in the options - form, but would be awkward to code as hidden fields. If your layer type class - has the correct __construct implementation (like those in the OpenLayers - Module), then these settings will be added whenever you initialize a layer - -## Vector - -* Map objects can contain an attribute called 'vector', defined in options_init(): - - function options_init() { - return array( - 'vector' => TRUE, - ); - } - -* This is an important attribute - it designates layers that are derived from - the OpenLayers Vector layer class [1]. Unlike tile or image-based layers - - like OpenStreetMap or Google Maps, these will typically be from data files - like KML, GML, or OpenLayers Data layers. And also unlike image-based maps, - they don't need to be in the projection of the rest of the map, since they are - easily reprojected by the OpenLayers Javascript library. So, it is possible to - have a WMS layer in the EPSG:4326 projection with KML data on it, and also put - that KML data on a Google Maps map in the EPSG:900913 projection, and the data - will be displayed on both. Thus setting the vector attribute allows certain - layers to be added to maps of any projection. - -[^1]: http://dev.openlayers.org/releases/OpenLayers-2.9.1/doc/apidocs/files/OpenLayers/Layer/Vector-js.html - -## Javascript - -OpenLayers Layer Types typically have a bit of Javascript accompanying them -which follows a certain form. It will provide a method in the -`Drupal.openlayers.layer` namespace, like `Drupal.openlayers.layer.cloudmade`, -takes arguments `(name, map, options)`, and will return a fully initialized map -object. These are basically factories for OpenLayers Layer Type objects, and are -usually under 50 lines long. Note that if you plan on making a distinctly -different layer type, it's best not to do it within this javascript file, but to -create a new OpenLayers Layer Type (in javascript) - see the MapBox module for -an example of a new OpenLayers Layer Type (`OpenLayers.Layer.MapBox`), which is -entirely independent of the Drupal module. \ No newline at end of file diff --git a/docs/OPENLAYERS_VIEWS.txt b/docs/OPENLAYERS_VIEWS.txt deleted file mode 100644 index 0bab140f723a5bcc4c3808ba45d04d71b5e0b69c..0000000000000000000000000000000000000000 --- a/docs/OPENLAYERS_VIEWS.txt +++ /dev/null @@ -1,11 +0,0 @@ - -Current for 6.x-2.x - -# Filtering map views - -The best way to handle filtering the points on maps is to use normal OpenLayers -exposed filters, whose input is passed through to the underlying Data -view. If there are no other views on the same page, like tabular listings, -that can 'own' and display the exposed filters, it is recommended to make the -filters blocks via the views interface and make sure that they appear on -the specified page with the block system or context module. diff --git a/docs/RAW_LAYERS.txt b/docs/RAW_LAYERS.txt deleted file mode 100644 index 54640fcd482c909c598e6773376fa8e4608a5390..0000000000000000000000000000000000000000 --- a/docs/RAW_LAYERS.txt +++ /dev/null @@ -1,65 +0,0 @@ - -Raw layers are an addition to OpenLayers post-alpha7 which allow users to -manually add points to a layer type. In comparison to the layer_type -method of pulling in custom data, this allows you to 'push' data into the -layer data array itself. In any case where reusability is a priority, -layer_types should be utilized (as documented in LAYER_TYPES.txt). However, -this is a quick method for success that may be more accessible to more -developers. - -A brief, example-only implementation of an arbitrary layer is below. - -/** - * Implementation of hook_ctools_plugin_api(). - * Required to provide layers - */ -function geolocator_ctools_plugin_api($module, $api) { - if ($module == "openlayers") { - switch ($api) { - case 'openlayers_layers': - return array('version' => 1); - } - } -} - -/** - * One can have the 'features' => element point to a function - * or be built on the fly within the _layers method. However, - * close attention must be paid to ctools caching in order to - * insure that dynamic data stays dynamic - */ -function geolocator_openlayers_layers() { - $layers = array(); - $layer = new stdClass(); - $layer->api_version = 1; - $layer->name = 'afghanistan'; - $layer->title = 'One Point on Afghanistan'; - $layer->description = ''; - $layer->data = array( - 'layer_type' => 'openlayers_layer_type_raw', - 'projection' => array('EPSG:900913'), - 'features' => array( - array( - "wkt"=> "POINT(65 33)", - "projection"=> "EPSG:4326", - "attributes"=> - array( - "name"=> "Afghanistan", - "description"=> "248" - ) - ) - ) - ); - $layers[$layer->name] = $layer; - return $layers; -} - -/** - * map_preprocess_alter allows one to add a new layer to a map - * before layers are rendered and data is pulled from them. - */ -function geolocator_openlayers_map_preprocess_alter(&$map) { - $map['layers']['afghanistan'] = 'afghanistan'; - $map['layer_activated']['afghanistan'] = 'afghanistan'; - $map['layer_switcher']['afghanistan'] = 'afghanistan'; -} diff --git a/docs/UPGRADE.txt b/docs/UPGRADE.txt deleted file mode 100644 index f763941f5b90cbf9d9ff22871968eee7834caca1..0000000000000000000000000000000000000000 --- a/docs/UPGRADE.txt +++ /dev/null @@ -1,13 +0,0 @@ -Documentation for upgrading is managed on Drupal.org. - - -For Upgrading from 6.x-2.x -> 7.x-2.x: -========================================== - - * http://drupal.org/node/1136810 - - -For Upgrading from 6.x-1.x -> 6.x-2.x: -========================================== - - * http://drupal.org/node/714366 \ No newline at end of file diff --git a/docs/openlayers.api.php b/docs/openlayers.api.php deleted file mode 100644 index adf860292593abe37fd5810b10bba0157e546fc8..0000000000000000000000000000000000000000 --- a/docs/openlayers.api.php +++ /dev/null @@ -1,280 +0,0 @@ - array( - 'title' => t('Google'), - 'description' => t('Google Maps API Map'), - 'layer_type' => array( - 'path' => drupal_get_path('module', 'openlayers') .'/includes/layer_types', - 'file' => 'google.inc', - 'class' => 'openlayers_layer_type_google', - 'parent' => 'openlayers_layer_type', - ), - ), - ); -} - -/** - * CTools Registration Hook - * - * IMPORTANT: - * - * In order to support styles, maps, and layers in an external module, - * one must notify the CTools module that that module provides implementations - * of the hooks for styles, maps, and/or layers. - * - * This function is just an example implementation of - * hook_ctools_plugin_api() and should be alter according to - * your module's name. - * - * @param $module - * Name of a module that supports CTools exportables. - * @param $api - * Name of the kind of exportable supported. - * @return - * If $module is 'openlayers', and $api is a type of exportable that - * your module provides, and you are using Openlayers 2.x, then - * return array with the following values: - * - version => 1 - */ -function openlayers_example_ctools_plugin_api($module, $api) { - if ($module == "openlayers") { - switch ($api) { - case 'openlayers_maps': - return array('version' => 1); - - case 'openlayers_layers': - return array('version' => 1); - - case 'openlayers_styles': - return array('version' => 1); - - } - } -} - -/** - * OpenLayers Layers - * - * This hook tells OpenLayers about the available layers - * that can be used by name in maps. - * - * Ensure that you are telling CTools about this as well. - * @see openlayers_example_ctools_plugin_api(). - * - * Please note, that to support translation for exportable - * code for potx extraction, you should include separate code - * of translatable string. - * - * @return - * Return an associative array with index being a unique string - * identifier, and simple objects with the following properties: - * - "api_version": - * - "name": - * - "title": - * - "data": - */ -function hook_openlayers_layers() { - // Taken from openlayers.layers.inc - - $layers = array(); - $layer = new stdClass(); - $layer->api_version = 1; - $layer->name = 'google_satellite'; - $layer->title = 'Google Maps Satellite'; - $layer->description = 'Google Maps Satellite Imagery.'; - $layer->data = array( - 'isBaseLayer' => TRUE, - 'type' => 'satellite', - 'projection' => array('EPSG:900913'), - 'layer_type' => 'openlayers_layer_type_google', - ); - $layers[$layer->name] = $layer; - return $layers; - - // Extra code to support potx extractors - $potx = array( - t('Google Maps Satellite'), - t('Google Maps Satellite Imagery.'), - ); -} - -/** - * OpenLayers Behaviors - * - * This hook tells OpenLayers about the available behaviors - * that can be used in maps. - * - * Ensure that you are telling CTools about this as well. - * @see openlayers_example_ctools_plugin_api(). - * - * @return - * Return a nested associative array with the top level - * being a unique string identifier, and the nested array - * containing the following key/pairs: - * - "title": - * - "description": - * - "file": - * - "type": - * - "behavior": - */ -function hook_openlayers_behaviors() { - // Taken from openlayers.behaviors.inc - - return array( - 'openlayers_behavior_attribution' => array( - 'title' => t('Attribution'), - 'description' => t('Allows layers to provide attribution to the map if it exists.'), - 'type' => 'layer', - 'path' => drupal_get_path('module', 'openlayers') .'/includes/behaviors', - 'file' => 'openlayers_behavior_attribution.inc', - 'behavior' => array( - 'class' => 'openlayers_behavior_attribution', - 'parent' => 'openlayers_behavior', - ), - ), - ); -} - -/** - * OpenLayers Styles - * - * This hook tells OpenLayers about the available styles - * that can be used in maps. - * - * Ensure that you are telling CTools about this as well. - * @see openlayers_example_ctools_plugin_api(). - * - * @return - * Return an associative array with index being a unique string - * identifier, and simple objects with the following properties: - * - "api_version": - * - "name": - * - "title": - * - "data": - */ -function hook_openlayers_styles() { - // Taken from openlayers.styles.inc - - $styles = array(); - - $style = new stdClass(); - $style->api_version = 1; - $style->name = 'default'; - $style->title = t('Default style'); - $style->description = t('Basic default style.'); - $style->data = array( - 'pointRadius' => '5', - 'fillColor' => '#FFCC66', - 'strokeColor' => '#FF9933', - 'strokeWidth' => '4', - 'fillOpacity' => '0.5' - ); - $styles[$style->name] = $style; - - return $styles; -} - -/** - * OpenLayers maps - * - * Define map objects. - * - * @return - * Return an associative array with index being a unique string - * identifier, and simple objects with the following properties: - * - "api_version": - * - "name": - * - "title": - * - "data": - */ -function hook_openlayers_maps() { - // Taken from openlayers.maps.inc - - $default = new stdClass(); - $default->api_version = 1; - $default->name = 'default'; - $default->title = t('Default Map'); - $default->description = t('This is the default map that comes with the OpenLayers module.'); - $default->data = array( - 'projection' => 'EPSG:900913', - 'displayProjection' => 'EPSG:4326', - 'width' => 'auto', - 'default_layer' => 'osm_mapnik', - 'height' => '400px', - 'center' => array( - 'initial' => array( - 'centerpoint' => '0,0', - 'zoom' => '2' - ) - ), - 'behaviors' => array( - 'openlayers_behavior_panzoombar' => array(), - 'openlayers_behavior_layerswitcher' => array(), - 'openlayers_behavior_attribution' => array(), - 'openlayers_behavior_keyboarddefaults' => array(), - 'openlayers_behavior_navigation' => array(), - ), - 'layers' => array( - 'osm_mapnik' => 'osm_mapnik', - ) - ); - return array('default' => $default); -} diff --git a/drush/openlayers.drush.inc b/drush/openlayers.drush.inc index 46c66474aeb402f5d636071a82de8bd863f84af2..1991cac0d6fb8e771df0a9ccc75c5d646d02db03 100644 --- a/drush/openlayers.drush.inc +++ b/drush/openlayers.drush.inc @@ -8,7 +8,7 @@ /** * The OpenLayers library URI. */ -define('OPENLAYERS_DOWNLOAD_URI', 'http://github.com/openlayers/openlayers/releases/download/release-2.13.1/OpenLayers-2.13.1.zip'); +define('OPENLAYERS_DOWNLOAD_URI', 'https://github.com/openlayers/ol3/releases/download/v3.0.0/v3.0.0.zip'); /** * Implementation of hook_drush_command(). @@ -88,16 +88,16 @@ function drush_openlayers_plugin() { $dirname = basename($filepath, '.zip'); // Remove any existing OpenLayers library directory - if (is_dir($dirname) || is_dir('openlayers') ) { + if (is_dir($dirname) || is_dir('openlayers3') ) { drush_delete_dir($dirname, TRUE); - drush_delete_dir('openlayers', TRUE); + drush_delete_dir('openlayers3', TRUE); drush_log(dt('A existing OpenLayers library was deleted from @path', array('@path' => $path)), 'notice'); } // Decompress the archive drush_tarball_extract($filename); - drush_move_dir($dirname, 'openlayers', TRUE); - $dirname = 'openlayers'; + drush_move_dir($dirname, 'openlayers3', TRUE); + $dirname = 'openlayers3'; } if (is_dir($dirname)) { diff --git a/images/druplicon.png b/images/druplicon.png new file mode 100755 index 0000000000000000000000000000000000000000..f8ced552148ef8767f1a3e8265dc897f96126dd0 Binary files /dev/null and b/images/druplicon.png differ diff --git a/includes/openlayers.behaviors.inc b/includes/openlayers.behaviors.inc deleted file mode 100644 index 99fabab57ba4ebacb62178875d5dbd196076e4fb..0000000000000000000000000000000000000000 --- a/includes/openlayers.behaviors.inc +++ /dev/null @@ -1,167 +0,0 @@ - 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', - ); - $behaviors['openlayers_behavior_attribution'] = 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', - ); - $behaviors['openlayers_behavior_boxselect'] = 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, - ); - $behaviors['openlayers_behavior_cluster'] = 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', - ); - $behaviors['openlayers_behavior_dragpan'] = 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', - ); - $behaviors['openlayers_behavior_drawfeatures'] = array( - 'title' => t('Draw Features'), - 'description' => t('Provides functionality for adding features to a map.'), - 'type' => 'layer', - ); - $behaviors['openlayers_behavior_fullscreen'] = array( - 'title' => t('Fullscreen'), - 'description' => t('Provides a button that expands maps to the size of the page.'), - 'type' => 'map', - ); - $behaviors['openlayers_behavior_geolocate'] = 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', - ); - $behaviors['openlayers_behavior_graticule'] = array( - 'title' => t('Graticule'), - 'description' => t('Adds a graticule control to the map to display a grid of latitude and longitude.'), - 'type' => 'layer', - ); - $behaviors['openlayers_behavior_hover'] = array( - 'title' => t('Hover features'), - 'description' => t('Provides on hover behavior on features. A temporary style will be applied on features when hovering them.'), - 'type' => 'layer', - ); - $behaviors['openlayers_behavior_keyboarddefaults'] = 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', - ); - $behaviors['openlayers_behavior_layerswitcher'] = 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', - ); - $behaviors['openlayers_behavior_layerzoom'] = array( - 'title' => t('Zoom restrictions for non-base layers.'), - 'description' => t('Enables restriction of layer display based on zoom level.'), - 'type' => 'layer', - ); - $behaviors['openlayers_behavior_mapformvalues'] = 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, - ); - $behaviors['openlayers_behavior_mouseposition'] = array( - 'title' => t('Mouse Position'), - 'description' => t('Provides a visual indication of the mouse position to the user.'), - 'type' => 'map', - ); - $behaviors['openlayers_behavior_navigation'] = 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', - ); - $behaviors['openlayers_behavior_panzoom'] = 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', - ); - $behaviors['openlayers_behavior_panzoombar'] = 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', - ); - $behaviors['openlayers_behavior_permalink'] = 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', - ); - $behaviors['openlayers_behavior_popup'] = 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', - ); - $behaviors['openlayers_behavior_scaleline'] = array( - 'title' => t('Scale Line'), - 'description' => t('Provides a line of scale in the map interface.'), - 'type' => 'map', - ); - $behaviors['openlayers_behavior_tooltip'] = 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', - ); - $behaviors['openlayers_behavior_touch_navigation'] = array( - 'title' => t('Touch Navigation'), - 'description' => t('Provides specific navigation controls for touch enabled devices only. This is included with the Navigation behavior. Only enable this if you are targeting only touch enabled devices.'), - 'type' => 'map', - ); - $behaviors['openlayers_behavior_zoombox'] = 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', - ); - $behaviors['openlayers_behavior_zoompanel'] = 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', - ); - $behaviors['openlayers_behavior_zoomtolayer'] = 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', - ); - $behaviors['openlayers_behavior_zoomtomaxextent'] = array( - 'title' => t('Zoom to Max Extent'), - 'description' => t('Provides button to zoom to the maximum extent of the map.'), - 'type' => 'map', - ); - - foreach ($behaviors as $key => $data) { - $behaviors[$key]['path'] = drupal_get_path('module', 'openlayers') . '/' . openlayers_ctools_plugin_directory('openlayers', 'behaviors'); - $behaviors[$key]['behavior'] = array( - 'class' => $key, - 'file' => $key . '.inc', - 'parent' => 'openlayers_behavior', - ); - } - - return $behaviors; -} diff --git a/includes/openlayers.control.inc b/includes/openlayers.control.inc new file mode 100644 index 0000000000000000000000000000000000000000..393af7ade9eafad019ed136225d241faecf91826 --- /dev/null +++ b/includes/openlayers.control.inc @@ -0,0 +1,5 @@ +api_version = 1; + $control->machine_name = 'control_attribution'; + $control->name = 'Attribution'; + $control->description = 'Attribution control description'; + $control->class = 'openlayers_control_attribution'; + $control->options = array( + 'collapsible' => 1, + ); + $export['control_attribution'] = $control; + + $control = new stdClass; + $control->api_version = 1; + $control->machine_name = 'control_fullscreen'; + $control->name = 'Fullscreen'; + $control->description = 'Fullscreen control description'; + $control->class = 'openlayers_control_fullscreen'; + $control->options = array(); + $export['control_fullscreen'] = $control; + + $control = new stdClass; + $control->api_version = 1; + $control->machine_name = 'control_mouseposition'; + $control->name = 'Mouse position'; + $control->description = 'Mouse position control description'; + $control->class = 'openlayers_control_mouseposition'; + $control->options = array(); + $export['control_mouseposition'] = $control; + + $control = new stdClass; + $control->api_version = 1; + $control->machine_name = 'control_rotate'; + $control->name = 'Rotate'; + $control->description = 'Rotate control description'; + $control->class = 'openlayers_control_rotate'; + $control->options = array(); + $export['control_rotate'] = $control; + + $control = new stdClass; + $control->api_version = 1; + $control->machine_name = 'control_scaleline'; + $control->name = 'Scaleline'; + $control->description = 'Scaleline control description'; + $control->class = 'openlayers_control_scaleline'; + $control->options = array(); + $export['control_scaleline'] = $control; + + $control = new stdClass; + $control->api_version = 1; + $control->machine_name = 'control_zoom'; + $control->name = 'Zoom'; + $control->description = 'Zoom control description'; + $control->class = 'openlayers_control_zoom'; + $control->options = array(); + $export['control_zoom'] = $control; + + $control = new stdClass; + $control->api_version = 1; + $control->machine_name = 'control_zoomslider'; + $control->name = 'Zoom slider'; + $control->description = 'Zoom slider control description'; + $control->class = 'openlayers_control_zoomslider'; + $control->options = array(); + $export['control_zoomslider'] = $control; + + $control = new stdClass; + $control->api_version = 1; + $control->machine_name = 'control_zoomtoextent'; + $control->name = 'Zoom to extent'; + $control->description = 'Zoom to extent control description'; + $control->class = 'openlayers_control_zoomtoextent'; + $control->options = array(); + $export['control_zoomtoextent'] = $control; + + return $export; +} diff --git a/includes/openlayers.default_interactions.inc b/includes/openlayers.default_interactions.inc new file mode 100644 index 0000000000000000000000000000000000000000..e50f641b9a55922216b95d8e6641778b853da63d --- /dev/null +++ b/includes/openlayers.default_interactions.inc @@ -0,0 +1,166 @@ +api_version = 1; + $interaction->machine_name = 'interaction_doubleclickzoom'; + $interaction->name = 'DoubleClickZoom'; + $interaction->description = 'DoubleClickZoom interaction description'; + $interaction->class = 'openlayers_interaction_doubleclickzoom'; + $interaction->options = array(); + $export['interaction_doubleclickzoom'] = $interaction; + + $interaction = new stdClass; + $interaction->api_version = 1; + $interaction->machine_name = 'interaction_draganddrop'; + $interaction->name = 'DragAndDrop'; + $interaction->description = 'DragAndDrop interaction description'; + $interaction->class = 'openlayers_interaction_draganddrop'; + $interaction->options = array(); + $export['interaction_draganddrop'] = $interaction; + + $interaction = new stdClass; + $interaction->api_version = 1; + $interaction->machine_name = 'interaction_dragbox'; + $interaction->name = 'DragBox'; + $interaction->description = 'DragBox interaction description'; + $interaction->class = 'openlayers_interaction_dragbox'; + $interaction->options = array(); + $export['interaction_dragbox'] = $interaction; + + $interaction = new stdClass; + $interaction->api_version = 1; + $interaction->machine_name = 'interaction_dragpan'; + $interaction->name = 'DragPan'; + $interaction->description = 'DragPan interaction description'; + $interaction->class = 'openlayers_interaction_dragpan'; + $interaction->options = array(); + $export['interaction_dragpan'] = $interaction; + + $interaction = new stdClass; + $interaction->api_version = 1; + $interaction->machine_name = 'interaction_dragrotate'; + $interaction->name = 'DragRotate'; + $interaction->description = 'DragRotate interaction description'; + $interaction->class = 'openlayers_interaction_dragrotate'; + $interaction->options = array(); + $export['interaction_dragrotate'] = $interaction; + + $interaction = new stdClass; + $interaction->api_version = 1; + $interaction->machine_name = 'interaction_dragrotateandzoom'; + $interaction->name = 'DragRotateAndZoom'; + $interaction->description = 'DragRotateAndZoom interaction description'; + $interaction->class = 'openlayers_interaction_dragrotateandzoom'; + $interaction->options = array(); + $export['interaction_dragrotateandzoom'] = $interaction; + + $interaction = new stdClass; + $interaction->api_version = 1; + $interaction->machine_name = 'interaction_dragzoom'; + $interaction->name = 'DragZoom'; + $interaction->description = 'DragZoom interaction description'; + $interaction->class = 'openlayers_interaction_dragzoom'; + $interaction->options = array(); + $export['interaction_dragzoom'] = $interaction; + + $interaction = new stdClass; + $interaction->api_version = 1; + $interaction->machine_name = 'interaction_draw'; + $interaction->name = 'Draw'; + $interaction->description = 'Draw interaction description'; + $interaction->class = 'openlayers_interaction_draw'; + $interaction->options = array(); + $export['interaction_draw'] = $interaction; + + $interaction = new stdClass; + $interaction->api_version = 1; + $interaction->machine_name = 'interaction_keyboardpan'; + $interaction->name = 'KeyboardPan'; + $interaction->description = 'KeyboardPan interaction description'; + $interaction->class = 'openlayers_interaction_keyboardpan'; + $interaction->options = array(); + $export['interaction_keyboardpan'] = $interaction; + + $interaction = new stdClass; + $interaction->api_version = 1; + $interaction->machine_name = 'interaction_keyboardzoom'; + $interaction->name = 'KeyboardZoom'; + $interaction->description = 'KeyboardZoom interaction description'; + $interaction->class = 'openlayers_interaction_keyboardzoom'; + $interaction->options = array(); + $export['interaction_keyboardzoom'] = $interaction; + + $interaction = new stdClass; + $interaction->api_version = 1; + $interaction->machine_name = 'interaction_modify'; + $interaction->name = 'Modify'; + $interaction->description = 'Modify interaction description'; + $interaction->class = 'openlayers_interaction_modify'; + $interaction->options = array(); + $export['interaction_modify'] = $interaction; + + $interaction = new stdClass; + $interaction->api_version = 1; + $interaction->machine_name = 'interaction_mousewheelzoom'; + $interaction->name = 'MouseWheelZoom'; + $interaction->description = 'MouseWheelZoom interaction description'; + $interaction->class = 'openlayers_interaction_mousewheelzoom'; + $interaction->options = array(); + $export['interaction_mousewheelzoom'] = $interaction; + + $interaction = new stdClass; + $interaction->api_version = 1; + $interaction->machine_name = 'interaction_pinchrotate'; + $interaction->name = 'PinchRotate'; + $interaction->description = 'PinchRotate interaction description'; + $interaction->class = 'openlayers_interaction_pinchrotate'; + $interaction->options = array(); + $export['interaction_pinchrotate'] = $interaction; + + $interaction = new stdClass; + $interaction->api_version = 1; + $interaction->machine_name = 'interaction_pinchzoom'; + $interaction->name = 'PinchZoom'; + $interaction->description = 'PinchZoom interaction description'; + $interaction->class = 'openlayers_interaction_pinchzoom'; + $interaction->options = array(); + $export['interaction_pinchzoom'] = $interaction; + + $interaction = new stdClass; + $interaction->api_version = 1; + $interaction->machine_name = 'interaction_pointer'; + $interaction->name = 'Pointer'; + $interaction->description = 'Pointer interaction description'; + $interaction->class = 'openlayers_interaction_pointer'; + $interaction->options = array(); + $export['interaction_pointer'] = $interaction; + + $interaction = new stdClass; + $interaction->api_version = 1; + $interaction->machine_name = 'interaction_select'; + $interaction->name = 'Select'; + $interaction->description = 'Select interaction description'; + $interaction->class = 'openlayers_interaction_select'; + $interaction->options = array(); + $export['interaction_select'] = $interaction; + + $interaction = new stdClass(); + $interaction->disabled = TRUE; /* Edit this to true to make a default interaction disabled initially */ + $interaction->api_version = 1; + $interaction->machine_name = 'map_edit_form_values'; + $interaction->name = 'Map edit form values'; + $interaction->description = 'Provides values for the center, rotation and zoom in the map edit form.'; + $interaction->class = 'openlayers_interaction_setvalues'; + $interaction->options = array( + 'latitude' => 'edit-options-view-center-lat', + 'longitude' => 'edit-options-view-center-lon', + 'rotation' => 'edit-options-view-rotation', + 'zoom' => 'edit-options-view-zoom', + ); + $export['map_edit_form_values'] = $interaction; + + return $export; +} diff --git a/includes/openlayers.default_layers.inc b/includes/openlayers.default_layers.inc new file mode 100644 index 0000000000000000000000000000000000000000..e1666caac8ddb46cf716c5253810ffba02953190 --- /dev/null +++ b/includes/openlayers.default_layers.inc @@ -0,0 +1,85 @@ +api_version = 1; + $layer->machine_name = 'layer_tile_mapquest_osm'; + $layer->name = 'MapQuest OpenStreetMap'; + $layer->description = 'Layer MapQuest OpenStreetMap description'; + $layer->class = 'openlayers_layer_tile'; + $layer->options = array( + 'source' => 'source_mapquest_osm', + ); + $export['layer_tile_mapquest_osm'] = $layer; + + $layer = new stdClass; + $layer->api_version = 1; + $layer->machine_name = 'layer_tile_mapquest_sat'; + $layer->name = 'MapQuest Satellite'; + $layer->description = 'Layer MapQuest Satellite description'; + $layer->class = 'openlayers_layer_tile'; + $layer->options = array( + 'source' => 'source_mapquest_sat', + ); + $export['layer_tile_mapquest_sat'] = $layer; + + $layer = new stdClass; + $layer->api_version = 1; + $layer->machine_name = 'layer_tile_mapquest_hyb'; + $layer->name = 'MapQuest Hybrid'; + $layer->description = 'Layer MapQuest Hybrid description'; + $layer->class = 'openlayers_layer_tile'; + $layer->options = array( + 'source' => 'source_mapquest_hyb', + ); + $export['layer_tile_mapquest_hyb'] = $layer; + + $layer = new stdClass; + $layer->api_version = 1; + $layer->machine_name = 'layer_tile_mapbox_geography_class'; + $layer->name = 'MapBox Geography Class'; + $layer->description = 'Layer MapBox Geography Class description'; + $layer->class = 'openlayers_layer_tile'; + $layer->options = array( + 'source' => 'source_mapbox_geography_class', + ); + $export['layer_tile_mapbox_geography_class'] = $layer; + + $layer = new stdClass; + $layer->api_version = 1; + $layer->machine_name = 'layer_tile_mapbox_natural_earth_hypso_bathy'; + $layer->name = 'MapBox Natural Earth Hypso Bathy'; + $layer->description = 'Layer MapBox Natural Earth Hypso Bathy description'; + $layer->class = 'openlayers_layer_tile'; + $layer->options = array( + 'source' => 'source_mapbox_natural_earth_hypso_bathy', + ); + $export['layer_tile_mapbox_natural_earth_hypso_bathy'] = $layer; + + $layer = new stdClass; + $layer->api_version = 1; + $layer->machine_name = 'layer_image'; + $layer->name = 'Drupal logo layer image'; + $layer->description = 'Layer image description'; + $layer->class = 'openlayers_layer_image'; + $layer->options = array( + 'source' => 'source_imagestatic' + ); + $export['layer_image'] = $layer; + + $layer = new stdClass(); + $layer->disabled = FALSE; /* Edit this to true to make a default layer disabled initially */ + $layer->api_version = 1; + $layer->machine_name = 'layer_tile_openstreetmap'; + $layer->name = 'OpenStreetMap'; + $layer->description = ''; + $layer->class = 'openlayers_layer_tile'; + $layer->options = array( + 'source' => 'source_osm' + ); + $export['layer_tile_openstreetmap'] = $layer; + + return $export; +} diff --git a/includes/openlayers.default_maps.inc b/includes/openlayers.default_maps.inc new file mode 100644 index 0000000000000000000000000000000000000000..e14303206b67866f76ecc157ac96f30288a12e9b --- /dev/null +++ b/includes/openlayers.default_maps.inc @@ -0,0 +1,263 @@ +api_version = 1; + $map->machine_name = 'map_mapbox_natural_earth_hypso_bathy'; + $map->name = 'MapBox Natural Earth Hypso Bathy'; + $map->description = ''; + $map->class = 'openlayers_map_map'; + $map->options = array( + 'width' => 'auto', + 'height' => '300px', + 'contextualLinks' => 1, + 'provideBlock' => 1, + 'view' => array( + 'center' => array( + 'lat' => '0', + 'lon' => '0', + ), + 'rotation' => '0', + 'zoom' => '2', + ), + 'layers' => array( + 0 => 'layer_tile_mapbox_natural_earth_hypso_bathy', + ), + 'controls' => array( + 0 => 'control_rotate', + 1 => 'control_scaleline', + 2 => 'control_zoom', + 3 => 'control_zoomslider', + 4 => 'control_zoomtoextent', + ), + 'interactions' => array( + 0 => 'interaction_doubleclickzoom', + 1 => 'interaction_dragpan', + 2 => 'interaction_dragrotate', + 3 => 'interaction_mousewheelzoom', + ), + ); + $export['map_mapbox_natural_earth_hypso_bathy'] = $map; + + $map = new stdClass(); + $map->api_version = 1; + $map->machine_name = 'map_mapbox_geography_class'; + $map->name = 'MapBox Geography Class'; + $map->description = ''; + $map->class = 'openlayers_map_map'; + $map->options = array( + 'width' => 'auto', + 'height' => '300px', + 'contextualLinks' => 1, + 'provideBlock' => 1, + 'view' => array( + 'center' => array( + 'lat' => '0', + 'lon' => '0', + ), + 'rotation' => '0', + 'zoom' => '2', + ), + 'layers' => array( + 0 => 'layer_tile_mapbox_geography_class', + ), + 'controls' => array( + 0 => 'control_rotate', + 1 => 'control_scaleline', + 2 => 'control_zoom', + 3 => 'control_zoomslider', + 4 => 'control_zoomtoextent', + ), + 'interactions' => array( + 0 => 'interaction_doubleclickzoom', + 1 => 'interaction_dragpan', + 2 => 'interaction_dragrotate', + 3 => 'interaction_mousewheelzoom', + ), + ); + $export['map_mapbox_geography_class'] = $map; + + $map = new stdClass(); + $map->api_version = 1; + $map->machine_name = 'map_mapquest_openstreetmap'; + $map->name = 'MapQuest OpenStreetMap'; + $map->description = ''; + $map->class = 'openlayers_map_map'; + $map->options = array( + 'width' => 'auto', + 'height' => '300px', + 'contextualLinks' => 1, + 'provideBlock' => 1, + 'view' => array( + 'center' => array( + 'lat' => '0', + 'lon' => '0', + ), + 'rotation' => '0', + 'zoom' => '2', + ), + 'layers' => array( + 0 => 'layer_tile_mapquest_osm', + ), + 'controls' => array( + 0 => 'control_rotate', + 1 => 'control_scaleline', + 2 => 'control_zoom', + 3 => 'control_zoomslider', + 4 => 'control_zoomtoextent', + ), + 'interactions' => array( + 0 => 'interaction_doubleclickzoom', + 1 => 'interaction_dragpan', + 2 => 'interaction_dragrotate', + 3 => 'interaction_keyboardpan', + 4 => 'interaction_mousewheelzoom', + ), + ); + $export['map_mapquest_openstreetmap'] = $map; + + $map = new stdClass(); + $map->disabled = FALSE; /* Edit this to true to make a default map disabled initially */ + $map->api_version = 1; + $map->machine_name = 'map_mapquest_hybrid'; + $map->name = 'MapQuest Hybrid'; + $map->description = ''; + $map->class = 'openlayers_map_map'; + $map->options = array( + 'width' => 'auto', + 'height' => '300px', + 'contextualLinks' => 1, + 'provideBlock' => 1, + 'view' => array( + 'center' => array( + 'lat' => '0', + 'lon' => '0', + ), + 'rotation' => '0', + 'zoom' => '2', + ), + 'layers' => array( + 0 => 'layer_tile_mapquest_hyb', + ), + 'controls' => array( + 0 => 'control_attribution', + 1 => 'control_mouseposition', + 2 => 'control_rotate', + 3 => 'control_zoom', + ), + 'interactions' => array( + 0 => 'interaction_doubleclickzoom', + 1 => 'interaction_dragpan', + 2 => 'interaction_dragrotateandzoom', + 3 => 'interaction_mousewheelzoom', + ), + ); + $export['map_mapquest_hybrid'] = $map; + + $map = new stdClass(); + $map->api_version = 1; + $map->machine_name = 'map_mapquest_satellite'; + $map->name = 'MapQuest Satellite'; + $map->description = ''; + $map->class = 'openlayers_map_map'; + $map->options = array( + 'width' => 'auto', + 'height' => '300px', + 'contextualLinks' => 1, + 'provideBlock' => 1, + 'view' => array( + 'center' => array( + 'lat' => '0', + 'lon' => '0', + ), + 'rotation' => '0', + 'zoom' => '2', + ), + 'layers' => array( + 0 => 'layer_tile_mapquest_sat', + ), + 'controls' => array( + 0 => 'control_mouseposition', + 1 => 'control_scaleline', + ), + 'interactions' => array( + 0 => 'interaction_doubleclickzoom', + 1 => 'interaction_dragpan', + 2 => 'interaction_dragrotateandzoom', + 3 => 'interaction_mousewheelzoom', + ), + ); + $export['map_mapquest_satellite'] = $map; + + $map = new stdClass(); + $map->disabled = FALSE; /* Edit this to true to make a default map disabled initially */ + $map->api_version = 1; + $map->machine_name = 'map_openstreetmap'; + $map->name = 'OpenStreetMap'; + $map->description = ''; + $map->class = 'openlayers_map_map'; + $map->options = array( + 'width' => 'auto', + 'height' => '300px', + 'contextualLinks' => 1, + 'provideBlock' => 1, + 'view' => array( + 'center' => array( + 'lat' => '0', + 'lon' => '0', + ), + 'rotation' => '0', + 'zoom' => '2', + ), + 'layers' => array( + 0 => 'layer_tile_openstreetmap', + ), + 'controls' => array(), + 'interactions' => array(), + ); + $export['map_openstreetmap'] = $map; + + $map = new stdClass; + $map->disabled = TRUE; + $map->api_version = 1; + $map->machine_name = 'map_view_edit_form'; + $map->name = 'Map view edit form'; + $map->description = 'Map used in the the map edit form to get center, zoom'; + $map->class = 'openlayers_map_map'; + $map->options = array( + 'width' => 'auto', + 'height' => '400px', + 'view' => array( + 'center' => array( + 'lat' => '0', + 'lon' => '0', + ), + 'rotation' => '0', + 'zoom' => '0', + ), + 'contextualLinks' => 0, + 'provideBlock' => 0, + 'layers' => array( + 0 => 'layer_tile_mapquest_osm', + ), + 'controls' => array( + 0 => 'control_mouseposition', + 1 => 'control_rotate', + 2 => 'control_scaleline', + 3 => 'control_zoom', + 4 => 'control_zoomslider', + 5 => 'control_zoomtoextent', + ), + 'interactions' => array( + 0 => 'map_edit_form_values', + 1 => 'interaction_dragpan', + 2 => 'interaction_dragrotateandzoom', + 3 => 'interaction_mousewheelzoom', + ), + ); + $export['map_view_edit_form'] = $map; + + return $export; +} diff --git a/includes/openlayers.default_sources.inc b/includes/openlayers.default_sources.inc new file mode 100644 index 0000000000000000000000000000000000000000..5e3c7d798a32774ae49dbdbd8f5934fd727025f8 --- /dev/null +++ b/includes/openlayers.default_sources.inc @@ -0,0 +1,97 @@ +api_version = 1; + $source->machine_name = 'source_osm'; + $source->name = 'OpenStreetMap'; + $source->description = 'Source OpenStreetMap description'; + $source->class = 'openlayers_source_osm'; + $source->options = array(); + $export['source_osm'] = $source; + + $source = new stdClass; + $source->api_version = 1; + $source->machine_name = 'source_bingmaps'; + $source->name = 'Bing Maps'; + $source->description = 'Source Bingmaps description'; + $source->class = 'openlayers_source_bingmaps'; + $source->options = array(); + $export['source_bingmaps'] = $source; + + $source = new stdClass(); + $source->disabled = FALSE; /* Edit this to true to make a default source disabled initially */ + $source->api_version = 1; + $source->machine_name = 'source_mapquest_sat'; + $source->name = 'MapQuest Satellite'; + $source->description = 'Source MapQuest Satellite description'; + $source->class = 'openlayers_source_mapquest'; + $source->options = array( + 'layer' => 'sat', + ); + $export['source_mapquest_sat'] = $source; + + $source = new stdClass(); + $source->disabled = FALSE; /* Edit this to true to make a default source disabled initially */ + $source->api_version = 1; + $source->machine_name = 'source_mapquest_osm'; + $source->name = 'MapQuest OpenStreetMap'; + $source->description = 'Source MapQuest OpenStreetMap description'; + $source->class = 'openlayers_source_mapquest'; + $source->options = array( + 'layer' => 'osm', + ); + $export['source_mapquest_osm'] = $source; + + $source = new stdClass(); + $source->disabled = FALSE; /* Edit this to true to make a default source disabled initially */ + $source->api_version = 1; + $source->machine_name = 'source_mapquest_hyb'; + $source->name = 'MapQuest Hybrid'; + $source->description = 'Source MapQuest Hybrid'; + $source->class = 'openlayers_source_mapquest'; + $source->options = array( + 'layer' => 'hyb', + ); + $export['source_mapquest_hyb'] = $source; + + $source = new stdClass(); + $source->disabled = FALSE; /* Edit this to true to make a default source disabled initially */ + $source->api_version = 1; + $source->machine_name = 'source_mapbox_geography_class'; + $source->name = 'MapBox Geography Class'; + $source->description = 'Source MapBox Geography Class description'; + $source->class = 'openlayers_source_tilejson'; + $source->options = array( + 'url' => 'http://api.tiles.mapbox.com/v3/mapbox.geography-class.jsonp', + ); + $export['source_mapbox_geography_class'] = $source; + + $source = new stdClass(); + $source->disabled = FALSE; /* Edit this to true to make a default source disabled initially */ + $source->api_version = 1; + $source->machine_name = 'source_mapbox_natural_earth_hypso_bathy'; + $source->name = 'MapBox Natural Earth Hypso Bathy'; + $source->description = 'Source MapBox Natural Hearth Hypso Bathy description'; + $source->class = 'openlayers_source_tilejson'; + $source->options = array( + 'url' => 'http://api.tiles.mapbox.com/v3/mapbox.natural-earth-hypso-bathy.jsonp', + ); + $export['source_mapbox_natural_earth_hypso_bathy'] = $source; + + $source = new stdClass(); + $source->disabled = FALSE; /* Edit this to true to make a default source disabled initially */ + $source->api_version = 1; + $source->machine_name = 'source_imagestatic'; + $source->name = 'Image Static'; + $source->description = 'Source Image Static description'; + $source->class = 'openlayers_source_imagestatic'; + $source->options = array( + 'url' => url(drupal_get_path('module', 'openlayers') . '/images/druplicon.png', array('absolute' => TRUE)), + ); + $export['source_imagestatic'] = $source; + + return $export; +} diff --git a/includes/openlayers.interaction.inc b/includes/openlayers.interaction.inc new file mode 100644 index 0000000000000000000000000000000000000000..a2210f9ed28c337a633168a806b75b2df507a12f --- /dev/null +++ b/includes/openlayers.interaction.inc @@ -0,0 +1,5 @@ +getOption('source'); + } + + public function attached() { + if ($source = $this->getSource()) { + $source = openlayers_object_load('source', $source); + $this->attached = drupal_array_merge_deep($this->attached, $source->attached()); + } + $this->attached = drupal_array_merge_deep($this->attached, parent::attached()); + return $this->attached; + } +} diff --git a/includes/openlayers.layer_types.inc b/includes/openlayers.layer_types.inc deleted file mode 100644 index 78a36e6fa20f9d999862f92bc507bdfed06c6bce..0000000000000000000000000000000000000000 --- a/includes/openlayers.layer_types.inc +++ /dev/null @@ -1,92 +0,0 @@ - t('Bing'), - 'description' => t('Microsoft Bing.') - ); - $layer_types['openlayers_layer_type_cloudmade'] = array( - 'title' => t('CloudMade'), - 'description' => t('CloudMade Custom Map', array('!url' => 'http://cloudmade.com/')), - ); - $layer_types['openlayers_layer_type_dummy'] = array( - 'title' => t('Blank layer'), - 'description' => t('Blank layer. Dummy blank layer to be used as a placeholder for other module (with hook_openlayers_map_preprocess for example).') - ); - $layer_types['openlayers_layer_type_geojson'] = array( - 'title' => t('GeoJSON'), - 'description' => t('Provides a vector layer based on GeoJSON.', array('!url' => 'http://geojson.org/')), - ); - $layer_types['openlayers_layer_type_google'] = array( - 'title' => t('Google'), - 'description' => t('Google Maps API Map'), - ); - $layer_types['openlayers_layer_type_gpx'] = array( - 'title' => t('GPX'), - 'description' => t('GPX Overlay'), - ); - $layer_types['openlayers_layer_type_image'] = array( - 'title' => t('Image'), - 'description' => t('Use an image as a layer.'), - ); - $layer_types['openlayers_layer_type_kml'] = array( - 'title' => t('KML'), - 'description' => t('KML overlay.', array('!url' => 'http://en.wikipedia.org/wiki/Keyhole_Markup_Language')), - ); - $layer_types['openlayers_layer_type_maptiler'] = array( - 'title' => t('MapTiler'), - 'description' => t('MapTiler or GDAL2Tiles', array('!url' => 'http://www.maptiler.org/')), - ); - $layer_types['openlayers_layer_type_osm'] = array( - 'title' => t('OSM'), - 'description' => t('OpenStreetMap Standard'), - ); - $layer_types['openlayers_layer_type_pointgrid'] = array( - 'title' => t('PointGrid Layer'), - 'description' => t('A point grid layer dynamically generates a regularly spaced grid of point features.'), - ); - $layer_types['openlayers_layer_type_raw'] = array( - 'title' => t('Raw'), - 'description' => t('Layer type for raw data input - not meant to be added with the UI.'), - ); - $layer_types['openlayers_layer_type_tms'] = array( - 'title' => t('TMS'), - 'description' => t('Tile Map Service', array('!url' => 'http://en.wikipedia.org/wiki/Tile_Map_Service')), - ); - $layer_types['openlayers_layer_type_wms'] = array( - 'title' => t('WMS'), - 'description' => t('Web Map Service', array('!url' => 'http://en.wikipedia.org/wiki/Web_Map_Service')), - ); - $layer_types['openlayers_layer_type_wmts'] = array( - 'title' => t('WMTS'), - 'description' => t('Web Map Tile Service', array('!url' => 'http://en.wikipedia.org/wiki/Tile_Map_Service')), - ); - $layer_types['openlayers_layer_type_xyz'] = array( - 'title' => t('XYZ'), - 'description' => t('XYZ layer type. These are tiles sets usually in the form of {z}/{x}/{y}.png.'), - ); - - foreach ($layer_types as $key => $data) { - $layer_types[$key]['path'] = drupal_get_path('module', 'openlayers') . '/' . openlayers_ctools_plugin_directory('openlayers', 'layer_types'); - $layer_types[$key]['layer_type'] = array( - 'class' => $key, - 'file' => $key . '.inc', - 'parent' => 'openlayers_layer_type', - ); - } - - return $layer_types; -} diff --git a/includes/openlayers.layers.inc b/includes/openlayers.layers.inc deleted file mode 100644 index 5ad57b67f1b3272e4f8ebe44e917bffdfd593a07..0000000000000000000000000000000000000000 --- a/includes/openlayers.layers.inc +++ /dev/null @@ -1,439 +0,0 @@ -api_version = 1; - $layer->name = 'google_satellite'; - $layer->title = 'Google Maps Satellite'; - $layer->description = 'Google Maps Satellite Imagery.'; - $layer->data = array( - 'isBaseLayer' => TRUE, - 'type' => 'satellite', - 'projection' => array('EPSG:3857', 'EPSG:900913'), - 'layer_type' => 'openlayers_layer_type_google', - ); - $layers[$layer->name] = $layer; - - $layer = new stdClass(); - $layer->api_version = 1; - $layer->name = 'google_hybrid'; - $layer->title = 'Google Maps Hybrid'; - $layer->description = 'Google Maps with roads and terrain.'; - $layer->data = array( - 'isBaseLayer' => TRUE, - 'type' => 'hybrid', - 'projection' => array('EPSG:3857', 'EPSG:900913'), - 'layer_type' => 'openlayers_layer_type_google', - ); - $layers[$layer->name] = $layer; - - $layer = new stdClass(); - $layer->api_version = 1; - $layer->name = 'google_normal'; - $layer->title = 'Google Maps Normal'; - $layer->description = 'Standard Google Maps Roads'; - $layer->data = array( - 'isBaseLayer' => TRUE, - 'type' => 'normal', - 'projection' => array('EPSG:3857', 'EPSG:900913'), - 'layer_type' => 'openlayers_layer_type_google', - ); - $layers[$layer->name] = $layer; - - $layer = new stdClass(); - $layer->api_version = 1; - $layer->name = 'google_physical'; - $layer->title = 'Google Maps Physical'; - $layer->description = 'Google Maps Hillshades'; - $layer->data = array( - 'isBaseLayer' => TRUE, - 'type' => 'physical', - 'projection' => array('EPSG:3857', 'EPSG:900913'), - 'layer_type' => 'openlayers_layer_type_google', - ); - $layers[$layer->name] = $layer; - - $layer = new stdClass(); - $layer->api_version = 1; - $layer->name = 'mapquest_osm'; - $layer->title = 'MapQuest OSM'; - $layer->description = 'MapQuest’s rendering of OpenStreetMap.'; - $layer->data = array( - 'isBaseLayer' => TRUE, - 'attribution' => t('©CCBYSA ' . - '© OpenStreetMap contributors', - array( - '@openstreetmap' => 'http://www.openstreetmap.org/copyright', - '@ccbysa' => 'http://creativecommons.org/licenses/by-sa/2.0/', - ) - ) . '. ' . t('Tiles Courtesy of MapQuest.'), - 'projection' => array('EPSG:3857', 'EPSG:900913'), - 'layer_type' => 'openlayers_layer_type_xyz', - 'url' => array( - '//otile1' . $mapquest_host . '/tiles/1.0.0/osm/${z}/${x}/${y}.png', - '//otile2' . $mapquest_host . '/tiles/1.0.0/osm/${z}/${x}/${y}.png', - '//otile3' . $mapquest_host . '/tiles/1.0.0/osm/${z}/${x}/${y}.png', - '//otile4' . $mapquest_host . '/tiles/1.0.0/osm/${z}/${x}/${y}.png', - ), - 'wrapDateLine' => TRUE, - 'resolutions' => openlayers_get_resolutions('EPSG:900913', 0, 19) - ); - $layers[$layer->name] = $layer; - - $layer = new stdClass(); - $layer->api_version = 1; - $layer->name = 'mapquest_openaerial'; - $layer->title = 'MapQuest Open Aerial'; - $layer->description = 'MapQuest’s aerial photo map.'; - $layer->data = array( - 'isBaseLayer' => TRUE, - 'attribution' => t('Portions Courtesy NASA/JPL-Caltech and U.S. Depart. of Agriculture, Farm Service Agency.') - . ' ' . t('Tiles Courtesy of MapQuest.'), - 'projection' => array('EPSG:3857', 'EPSG:900913'), - 'layer_type' => 'openlayers_layer_type_xyz', - 'url' => array( - '//oatile1' . $mapquest_host . '/tiles/1.0.0/sat/${z}/${x}/${y}.png', - '//oatile2' . $mapquest_host . '/tiles/1.0.0/sat/${z}/${x}/${y}.png', - '//oatile3' . $mapquest_host . '/tiles/1.0.0/sat/${z}/${x}/${y}.png', - '//oatile4' . $mapquest_host . '/tiles/1.0.0/sat/${z}/${x}/${y}.png' - ), - 'wrapDateLine' => TRUE, - ); - $layers[$layer->name] = $layer; - - // Bing Road - $layer = new stdClass(); - $layer->api_version = 1; - $layer->name = 'bing_road'; - $layer->title = 'Bing Road'; - $layer->description = 'Bing Road tiles.'; - $layer->data = array( - 'name' => 'Bing Road', - 'isBaseLayer' => TRUE, - 'type' => 'Road', - 'projection' => array('EPSG:3857'), - 'layer_type' => 'openlayers_layer_type_bing', - ); - $layers[$layer->name] = $layer; - - // Bing Aerial - $layer = new stdClass(); - $layer->api_version = 1; - $layer->name = 'bing_aerial'; - $layer->title = 'Bing Aerial'; - $layer->description = 'Bing Aerial tiles.'; - $layer->data = array( - 'name' => 'Bing Aerial', - 'isBaseLayer' => TRUE, - 'type' => 'Aerial', - 'projection' => array('EPSG:3857'), - 'layer_type' => 'openlayers_layer_type_bing', - ); - $layers[$layer->name] = $layer; - - // Bing Hybrid - $layer = new stdClass(); - $layer->api_version = 1; - $layer->name = 'bing_hybrid'; - $layer->title = 'Bing Hybrid'; - $layer->description = 'Bing Hybrid tiles.'; - $layer->data = array( - 'name' => 'Bing Hybrid', - 'isBaseLayer' => TRUE, - 'type' => 'AerialWithLabels', - 'projection' => array('EPSG:3857'), - 'layer_type' => 'openlayers_layer_type_bing', - ); - $layers[$layer->name] = $layer; - - // OpenStreetMap Mapnik - $layer = new stdClass(); - $layer->api_version = 1; - $layer->name = 'osm_mapnik'; - $layer->title = 'OSM Mapnik'; - $layer->description = 'The main OpenStreetMap map'; - $layer->data = array( - 'isBaseLayer' => TRUE, - 'attribution' => t('©CCBYSA ' . - '© OpenStreetMap contributors', - array( - '@openstreetmap' => 'http://www.openstreetmap.org/copyright', - '@ccbysa' => 'http://creativecommons.org/licenses/by-sa/2.0/', - ) - ), - 'projection' => array('EPSG:3857'), - 'layer_type' => 'openlayers_layer_type_xyz', - 'url' => 'http://tile.openstreetmap.org/${z}/${x}/${y}.png', - 'wrapDateLine' => TRUE, - ); - $layers[$layer->name] = $layer; - - // OpenStreetMap Cycling Map - $layer = new stdClass(); - $layer->api_version = 1; - $layer->name = 'osm_cycle'; - $layer->title = 'OSM Cycling Map'; - $layer->description = 'OpenStreetMap with highlighted bike lanes'; - $layer->data = array( - 'isBaseLayer' => TRUE, - 'attribution' => t('©CCBYSA ' . - '© OpenStreetMap contributors', - array( - '@openstreetmap' => 'http://www.openstreetmap.org/copyright', - '@ccbysa' => 'http://creativecommons.org/licenses/by-sa/2.0/', - ) - ), - 'projection' => array('EPSG:3857'), - 'layer_type' => 'openlayers_layer_type_xyz', - 'url' => '//a.tile.opencyclemap.org/cycle/${z}/${x}/${y}.png', - 'wrapDateLine' => TRUE, - ); - $layers[$layer->name] = $layer; - - // OpenStreetMap 426 hybrid overlay - $layer = new stdClass(); - $layer->api_version = 1; - $layer->name = 'osm_4326_hybrid'; - $layer->title = 'OSM Overlay'; - $layer->description = 'Semi-transparent hybrid overlay. Projected into - WSG84 for use on non spherical-mercator maps.'; - $layer->data = array( - 'isBaseLayer' => FALSE, - 'attribution' => t('©CCBYSA ' . - '© OpenStreetMap contributors', - array( - '@openstreetmap' => 'http://www.openstreetmap.org/copyright', - '@ccbysa' => 'http://creativecommons.org/licenses/by-sa/2.0/', - ) - ), - 'projection' => array('EPSG:4326'), - 'layer_type' => 'openlayers_layer_type_wms', - 'url' => 'http://oam.hypercube.telascience.org/tiles', - 'params' => array( - 'isBaseLayer' => FALSE, - 'layers' => array( - 'osm-4326-hybrid' - ), - ), - 'options' => array( - 'buffer' => 1, - ), - ); - $layers[$layer->name] = $layer; - - /* Example with KML layer */ - $layer = new stdClass(); - $layer->disabled = FALSE; /* Edit this to true to make a default openlayers_layers disabled initially */ - $layer->api_version = 1; - $layer->name = 'openlayers_kml_example'; - $layer->title = 'KML Example Layer'; - $layer->description = 'A simple example of KML Layer Type.'; - $layer->data = array( - 'method' => 'raw', - 'raw' => 'Simple placemarkAttached to the ground. Intelligently places itself at the height of the underlying terrain.-122.0822035425683,37.42228990140251,0', - 'formatOptions' => array( - 'extractStyles' => TRUE, - 'extractTracks' => FALSE, - 'extractAttributes' => TRUE, - ), - 'projection' => array( - 'EPSG:4326', - ), - 'isBaseLayer' => 0, - 'layer_type' => 'openlayers_layer_type_kml', - 'layer_handler' => 'kml', - 'vector' => TRUE, - ); - $layers[$layer->name] = $layer; - - // MetaCarts base map - $layer = new stdClass(); - $layer->api_version = 1; - $layer->name = 'wms_default'; - $layer->title = 'Default OpenLayers WMS'; - $layer->description = 'MetaCarta basemap of province and water boundaries'; - $layer->data = array( - 'projection' => array('EPSG:4326'), - 'isBaseLayer' => TRUE, - 'layer_type' => 'openlayers_layer_type_wms', - 'base_url' => '//labs.metacarta.com/wms-c/Basic.py', - 'params' => array( - 'isBaseLayer' => TRUE, - ), - 'options' => array( - 'layers' => array('basic'), - ), - ); - $layers[$layer->name] = $layer; - - // GeoJSON example with direct data - $layer = new stdClass(); - $layer->api_version = 1; - $layer->name = 'openlayers_geojson_picture_this'; - $layer->title = t('Example GeoJSON, "Picture This"'); - $layer->description = t('Example that puts GeoJSON directly in layer without Views.'); - $layer->data = array( - 'resolutions' => openlayers_get_resolutions('EPSG:900913'), - 'serverResolutions' => openlayers_get_resolutions('EPSG:4326'), - 'layer_type' => 'openlayers_layer_type_geojson', - 'layer_handler' => 'geojson', - 'projection' => array('EPSG:4326'), - 'isBaseLayer' => FALSE, - 'vector' => TRUE, - 'geojson_data' => ' - { - "type": "Feature", - "properties": { - "name": "' . t('Picture This') . '", - "description": "' . t('Outside of the North Carolina Museum of Art.') . '" - }, - "geometry": { - "type": "Point", - "coordinates": [ - -78.702798, - 35.809411 - ] - }, - "crs": { - "type": "name", - "properties": { - "name": "urn:ogc:def:crs:OGC:1.3:CRS84" - } - } - } - ', - ); - $layers[$layer->name] = $layer; - - $info = _mapbox_layers_info(); - $resolutions = openlayers_get_resolutions('EPSG:900913'); - $resolutions = array_combine(range(0, count($resolutions)-1), $resolutions); - - - foreach ($info as $key => $item) { - $openlayers_layers = new stdClass; - $openlayers_layers->disabled = FALSE; /* Edit this to true to make a default openlayers_layers disabled initially */ - $openlayers_layers->api_version = 1; - $openlayers_layers->name = $key; - $openlayers_layers->title = $item['name']; - $openlayers_layers->description = $item['description']; - $openlayers_layers->data = array( - 'url' => array( - 0 => 'http://a.tiles.mapbox.com/', - 1 => 'http://b.tiles.mapbox.com/', - 2 => 'http://c.tiles.mapbox.com/', - 3 => 'http://d.tiles.mapbox.com/', - ), - 'layername' => $item['layername'], - 'layer_type' => 'openlayers_layer_type_tms', - 'osm' => FALSE, - 'isBaseLayer' => TRUE, - 'type' => 'png', - 'resolutions' => array_intersect_key($resolutions, array_flip(range($item['minzoom'], $item['maxzoom']))), - 'projection' => array('EPSG:3857'), - ); - $layers[$key] = $openlayers_layers; - } - - return $layers; -} - -/** - * This function is for the po editor to be able to find these strings, - * since in the codebase they are not in t()'s, because they are later - * run through t() in the layer loader function - */ -function _openlayers_openlayers_layers_i18n() { - $translatable_strings = array( - // titles - t('Google Maps Satellite'), - t('Google Maps Hybrid'), - t('Google Maps Normal'), - t('Google Maps Physical'), - t('Bing Road'), - t('Bing Aerial'), - t('Bing Hybrid'), - t('Yahoo Maps Street'), - t('Yahoo Maps Hybrid'), - t('Yahoo Maps Satellite'), - t('OSM Mapnik'), - t('OSM Cycling Map'), - t('OSM Overlay'), - t('Default OpenLayers WMS'), - // descriptions - t('Alternative, community-rendered OpenStreetMap'), - t('Google Maps Hillshades'), - t('Google Maps Satellite Imagery.'), - t('Google Maps with roads and terrain.'), - t('MetaCarta basemap of province and water boundaries'), - t('OpenStreetMap with highlighted bike lanes'), - t('Semi-transparent hybrid overlay. Projected into - WSG84 for use on non spherical-mercator maps.'), - t('Standard Google Maps Roads'), - t('The main OpenStreetMap map'), - t('Bing Road tiles.'), - t('Bing Aerial tiles.'), - t('Bing Hybrid tiles.'), - t('MapQuest’s rendering of OpenStreetMap.'), - t('MapQuest’s aerial photo map.'), - ); -} - -function _mapbox_layers_info() { - $info = array(); - $info['mapbox_world_bright'] = array( - 'name' => t('MapBox World Bright'), - 'description' => t('MapBox World Bright'), - 'layername' => 'world-bright', - 'minzoom' => 0, - 'maxzoom' => 11, - ); - $info['mapbox_world_dark'] = array( - 'name' => t('MapBox World Dark'), - 'description' => t('MapBox World Dark'), - 'layername' => 'world-dark', - 'minzoom' => 0, - 'maxzoom' => 11, - ); - $info['mapbox_world_light'] = array( - 'name' => t('MapBox World Light'), - 'description' => t('MapBox World Light'), - 'layername' => 'world-light', - 'minzoom' => 0, - 'maxzoom' => 11, - ); - $info['mapbox_world_print'] = array( - 'name' => t('MapBox World Print'), - 'description' => t('MapBox World Print'), - 'layername' => 'world-print', - 'minzoom' => 0, - 'maxzoom' => 9, - ); - $info['mapbox_world_black'] = array( - 'name' => t('MapBox World Black'), - 'description' => t('MapBox World Black'), - 'layername' => 'world-black', - 'minzoom' => 0, - 'maxzoom' => 11, - ); - - return $info; -} diff --git a/includes/openlayers.map.inc b/includes/openlayers.map.inc new file mode 100644 index 0000000000000000000000000000000000000000..3277b4e0015f86752b2eead639e3e57b377d1616 --- /dev/null +++ b/includes/openlayers.map.inc @@ -0,0 +1,84 @@ +id)) { + return $this->id; + } + + $css_map_name = drupal_clean_css_identifier($this->machine_name); + $this->id = drupal_html_id('openlayers-map-' . $css_map_name); + return $this->id; + } + + public function getLayers() { + if ($this->getOption('layers')) { + if (is_array($this->getOption('layers'))) { + return $this->getOption('layers'); + } + } + return FALSE; + } + + public function getSources() { + if ($this->getOption('layers')) { + if (is_array($this->getOption('layers'))) { + $sources = array(); + foreach($this->getOption('layers') as $index => $machine_name) { + $layer = openlayers_object_load('layer', $machine_name); + if ($source = $layer->getOption('source')) { + $sources[] = $source; + } + } + return $sources; + } + } + return FALSE; + } + + public function getControls() { + if ($this->getOption('controls')) { + if (is_array($this->getOption('controls'))) { + return $this->getOption('controls'); + } + } + return FALSE; + } + + public function getInteractions() { + if ($this->getOption('interactions')) { + if (is_array($this->getOption('interactions'))) { + return $this->getOption('interactions'); + } + } + return FALSE; + } + + public function attached() { + $this->attached = parent::attached(); + + if ($layers = $this->getLayers()) { + foreach($layers as $index => $machine_name) { + $layer = openlayers_object_load('layer', $machine_name); + $this->attached = drupal_array_merge_deep($this->attached, $layer->attached()); + } + } + if ($interactions = $this->getControls()) { + foreach($interactions as $index => $machine_name) { + $control = openlayers_object_load('control',$machine_name); + $this->attached = drupal_array_merge_deep($this->attached, $control->attached()); + } + } + if ($interactions = $this->getInteractions()) { + foreach($interactions as $index => $machine_name) { + $interaction = openlayers_object_load('interaction',$machine_name); + $this->attached = drupal_array_merge_deep($this->attached, $interaction->attached()); + } + } + return $this->attached; + } +} diff --git a/includes/openlayers.maps.inc b/includes/openlayers.maps.inc deleted file mode 100644 index c4166e487ee281a7f64ec2a936d4f1d4d5609297..0000000000000000000000000000000000000000 --- a/includes/openlayers.maps.inc +++ /dev/null @@ -1,421 +0,0 @@ -api_version = 1; - $default->name = 'default'; - $default->title = t('Default Map'); - $default->description = t('This is the default map that will be the basis for all maps, unless you have changed the !settings. This is also a good example of a basic map.', array('!settings' => l(t('OpenLayers main settings'), 'admin/structure/openlayers'))); - $default->data = array( - 'projection' => 'EPSG:3857', - 'width' => 'auto', - 'height' => '400px', - 'default_layer' => 'mapquest_osm', - 'center' => array( - 'initial' => array( - 'centerpoint' => '0,0', - 'zoom' => '0' - ) - ), - 'image_path' => drupal_get_path('module', 'openlayers') . '/themes/default_dark/img/', - 'css_path' => drupal_get_path('module', 'openlayers') . '/themes/default_dark/style.css', - 'displayProjection' => 'EPSG:4326', - 'behaviors' => array( - 'openlayers_behavior_panzoombar' => array(), - 'openlayers_behavior_layerswitcher' => array(), - 'openlayers_behavior_attribution' => array(), - 'openlayers_behavior_keyboarddefaults' => array(), - 'openlayers_behavior_navigation' => array(), - ), - 'layers' => array( - 'mapquest_osm' => 'mapquest_osm', - 'mapquest_openaerial' => 'mapquest_openaerial', - ), - 'styles' => array( - 'default' => 'default', - 'select' => 'default_select', - 'temporary' => 'default', - ), - ); - $items['default'] = $default; - - // An example Google map - $openlayers_maps = new stdClass; - $openlayers_maps->disabled = FALSE; - $openlayers_maps->api_version = 1; - $openlayers_maps->name = 'example_google'; - $openlayers_maps->title = t('Example Google Map'); - $openlayers_maps->description = t('An example map using Google Maps API layers.'); - $openlayers_maps->data = array( - 'width' => 'auto', - 'height' => '400px', - 'image_path' => drupal_get_path('module', 'openlayers') . '/themes/default_dark/img/', - 'css_path' => drupal_get_path('module', 'openlayers') . '/themes/default_dark/style.css', - 'center' => array( - 'initial' => array( - 'centerpoint' => '0, 0', - 'zoom' => '2', - ), - 'restrict' => array( - 'restrictextent' => 0, - 'restrictedExtent' => '', - ), - ), - 'behaviors' => array( - 'openlayers_behavior_attribution' => array( - 'separator' => '', - ), - 'openlayers_behavior_keyboarddefaults' => array(), - 'openlayers_behavior_layerswitcher' => array( - 'ascending' => 1, - 'roundedCorner' => 1, - 'roundedCornerColor' => '#222222', - ), - 'openlayers_behavior_navigation' => array( - 'zoomWheelEnabled' => 1, - 'zoomBoxEnabled' => 1, - 'documentDrag' => 0, - ), - 'openlayers_behavior_permalink' => array( - 'anchor' => 1, - ), - 'openlayers_behavior_zoompanel' => array(), - ), - 'default_layer' => 'google_physical', - 'layers' => array( - 'google_satellite' => 'google_satellite', - 'google_hybrid' => 'google_hybrid', - 'google_normal' => 'google_normal', - 'google_physical' => 'google_physical', - ), - 'projection' => 'EPSG:3857', - 'displayProjection' => 'EPSG:4326', - 'styles' => array( - 'default' => 'default', - 'select' => 'default_select', - 'temporary' => 'default', - ), - ); - $items['default_google'] = $openlayers_maps; - - // Example map with MapQuest and GeoJSON - $openlayers_maps = new stdClass(); - $openlayers_maps->disabled = FALSE; /* Edit this to true to make a default openlayers_maps disabled initially */ - $openlayers_maps->api_version = 1; - $openlayers_maps->name = 'example_geojson'; - $openlayers_maps->title = 'Example GeoJSON Map'; - $openlayers_maps->description = 'A simple map with a custom GeoJSON layer with direct data. Also an example of zooming into a layer.'; - $openlayers_maps->data = array( - 'width' => 'auto', - 'height' => '400px', - 'image_path' => drupal_get_path('module', 'openlayers') . '/themes/default_dark/img/', - 'css_path' => drupal_get_path('module', 'openlayers') . '/themes/default_dark/style.css', - 'proxy_host' => '', - 'hide_empty_map' => 0, - 'center' => array( - 'initial' => array( - 'centerpoint' => '0,0', - 'zoom' => '2', - ), - 'restrict' => array( - 'restrictextent' => 0, - 'restrictedExtent' => '', - ), - ), - 'behaviors' => array( - 'openlayers_behavior_keyboarddefaults' => array(), - 'openlayers_behavior_layerswitcher' => array( - 'ascending' => 1, - 'sortBaseLayer' => '0', - 'roundedCorner' => 1, - 'roundedCornerColor' => '#222222', - 'maximizeDefault' => 0, - ), - 'openlayers_behavior_navigation' => array( - 'zoomWheelEnabled' => 1, - 'zoomBoxEnabled' => 1, - 'documentDrag' => 0, - ), - 'openlayers_behavior_panzoombar' => array( - 'zoomWorldIcon' => 0, - 'panIcons' => 1, - ), - 'openlayers_behavior_popup' => array( - 'layers' => array( - 'openlayers_geojson_picture_this' => 'openlayers_geojson_picture_this', - ), - 'panMapIfOutOfView' => 0, - 'keepInMap' => 1, - ), - 'openlayers_behavior_zoomtolayer' => array( - 'zoomtolayer' => array( - 'openlayers_geojson_picture_this' => 'openlayers_geojson_picture_this', - ), - 'point_zoom_level' => '5', - 'zoomtolayer_scale' => '1', - ), - ), - 'default_layer' => 'mapquest_openaerial', - 'layers' => array( - 'mapquest_osm' => 'mapquest_osm', - 'mapquest_openaerial' => 'mapquest_openaerial', - 'openlayers_geojson_picture_this' => 'openlayers_geojson_picture_this', - ), - 'layer_activated' => array( - 'openlayers_geojson_picture_this' => 'openlayers_geojson_picture_this', - ), - 'projection' => 'EPSG:3857', - 'displayProjection' => 'EPSG:4326', - 'styles' => array( - 'default' => 'default', - 'select' => 'default_select', - 'temporary' => 'default', - ), - ); - $items['example_geojson'] = $openlayers_maps; - - // Example map with MapQuest and GeoJSON - $openlayers_maps = new stdClass(); - $openlayers_maps->disabled = FALSE; /* Edit this to true to make a default openlayers_maps disabled initially */ - $openlayers_maps->api_version = 1; - $openlayers_maps->name = 'example_kml'; - $openlayers_maps->title = 'Example KML Map'; - $openlayers_maps->description = 'A simple map with a KML layer.'; - $openlayers_maps->data = array( - 'width' => 'auto', - 'height' => '400px', - 'image_path' => drupal_get_path('module', 'openlayers') . '/themes/default_dark/img/', - 'css_path' => drupal_get_path('module', 'openlayers') . '/themes/default_dark/style.css', - 'proxy_host' => '', - 'hide_empty_map' => 0, - 'center' => array( - 'initial' => array( - 'centerpoint' => '0, 0', - 'zoom' => '6', - ), - 'restrict' => array( - 'restrictextent' => 0, - 'restrictedExtent' => '', - ), - ), - 'behaviors' => array( - 'openlayers_behavior_mouseposition' => array(), - 'openlayers_behavior_keyboarddefaults' => array(), - 'openlayers_behavior_layerswitcher' => array( - 'ascending' => 1, - 'sortBaseLayer' => '0', - 'roundedCorner' => 1, - 'roundedCornerColor' => '#222222', - 'maximizeDefault' => 0, - ), - 'openlayers_behavior_navigation' => array( - 'zoomWheelEnabled' => 1, - 'zoomBoxEnabled' => 1, - 'documentDrag' => 0, - ), - 'openlayers_behavior_panzoombar' => array( - 'zoomWorldIcon' => 0, - 'panIcons' => 1, - ), - 'openlayers_behavior_popup' => array( - 'layers' => array( - 'openlayers_kml_example' => 'openlayers_kml_example', - ), - 'panMapIfOutOfView' => 0, - 'keepInMap' => 1, - ), - 'openlayers_behavior_zoomtolayer' => array( - 'zoomtolayer' => array( - 'openlayers_kml_example' => 'openlayers_kml_example', - ), - 'point_zoom_level' => '5', - 'zoomtolayer_scale' => '1', - ), - ), - 'default_layer' => 'mapquest_osm', - 'layers' => array( - 'mapquest_osm' => 'mapquest_osm', - 'openlayers_kml_example' => 'openlayers_kml_example', - ), - 'layer_activated' => array( - 'openlayers_kml_example' => 'openlayers_kml_example', - ), - 'projection' => 'EPSG:3857', - 'displayProjection' => 'EPSG:4326', - 'styles' => array( - 'default' => 'default', - 'select' => 'default_select', - 'temporary' => 'default', - ), - ); - $items['example_kml'] = $openlayers_maps; - - // Example Virtual Earth map - $openlayers_maps = new stdClass; - $openlayers_maps->disabled = FALSE; - $openlayers_maps->api_version = 1; - $openlayers_maps->name = 'example_bing'; - $openlayers_maps->title = t('Example Microsoft Bing Map'); - $openlayers_maps->description = t('This map uses the Microsoft Bing map API.'); - $openlayers_maps->data = array( - 'width' => 'auto', - 'height' => '400px', - 'image_path' => drupal_get_path('module', 'openlayers') . '/themes/default_dark/img/', - 'css_path' => drupal_get_path('module', 'openlayers') . '/themes/default_dark/style.css', - 'proxy_host' => '', - 'hide_empty_map' => 0, - 'center' => array( - 'initial' => array( - 'centerpoint' => '0, 0', - 'zoom' => '3', - ), - 'restrict' => array( - 'restrictextent' => 0, - 'restrictedExtent' => '', - ), - ), - 'behaviors' => array( - 'openlayers_behavior_attribution' => array( - 'separator' => '', - ), - 'openlayers_behavior_fullscreen' => array( - 'activated' => 0, - ), - 'openlayers_behavior_keyboarddefaults' => array(), - 'openlayers_behavior_layerswitcher' => array( - 'ascending' => 1, - 'roundedCorner' => 1, - 'roundedCornerColor' => '#222222', - ), - 'openlayers_behavior_navigation' => array( - 'zoomWheelEnabled' => 1, - 'zoomBoxEnabled' => 1, - 'documentDrag' => 0, - ), - 'openlayers_behavior_panzoom' => array(), - ), - 'default_layer' => 'bing_road', - 'layers' => array( - 'bing_road' => 'bing_road', - 'bing_hybrid' => 'bing_hybrid', - 'bing_aerial' => 'bing_aerial', - ), - 'projection' => 'EPSG:3857', - 'displayProjection' => 'EPSG:4326', - 'styles' => array( - 'default' => 'default', - 'select' => 'default_select', - 'temporary' => 'default', - ), - ); - $items['example_bing'] = $openlayers_maps; - - // Example OpenStreetMap - $openlayers_maps = new stdClass; - $openlayers_maps->disabled = FALSE; - $openlayers_maps->api_version = 1; - $openlayers_maps->name = 'example_osm'; - $openlayers_maps->title = 'Example OpenStreetMap Map'; - $openlayers_maps->description = 'Map to show off the OpenStreetMap layers.'; - $openlayers_maps->data = array( - 'width' => 'auto', - 'height' => '400px', - 'image_path' => drupal_get_path('module', 'openlayers') . '/themes/default_dark/img/', - 'css_path' => drupal_get_path('module', 'openlayers') . '/themes/default_dark/style.css', - 'proxy_host' => '', - 'hide_empty_map' => 0, - 'center' => array( - 'initial' => array( - 'centerpoint' => '0, 0', - 'zoom' => '3', - ), - 'restrict' => array( - 'restrictextent' => 0, - 'restrictedExtent' => '', - ), - ), - 'behaviors' => array( - 'openlayers_behavior_attribution' => array( - 'separator' => '', - ), - 'openlayers_behavior_keyboarddefaults' => array(), - 'openlayers_behavior_layerswitcher' => array( - 'ascending' => 1, - 'roundedCorner' => 1, - 'roundedCornerColor' => '#222222', - ), - 'openlayers_behavior_navigation' => array( - 'zoomWheelEnabled' => 1, - 'zoomBoxEnabled' => 1, - 'documentDrag' => 0, - ), - 'openlayers_behavior_zoompanel' => array(), - - 'openlayers_behavior_scaleline' => array(), - ), - 'default_layer' => 'osm_mapnik', - 'layers' => array( - 'osm_mapnik' => 'osm_mapnik', - 'osm_cycle' => 'osm_cycle', - ), - 'projection' => 'EPSG:3857', - 'displayProjection' => 'EPSG:4326', - 'styles' => array( - 'default' => 'default', - 'select' => 'default_select', - 'temporary' => 'default', - ), - ); - $items["example_osm"] = $openlayers_maps; - - // Backwards compatibilty for features presets. Since features - // no longers cares about the preset hooks, we need to manually include - // the preset file that stores the old hooks. - $found_features = FALSE; - if (module_exists('features')) { - $features = features_get_features(); - - foreach ($features as $feature) { - // Only utilize enabled features and look for presets - if ($feature->status > 0 && !empty($feature->info['features']['openlayers_map_presets'])) { - $found_features = TRUE; - // Include the file we need. - $presets = $feature->info['features']['openlayers_map_presets']; - $module = $feature->name; - $inc = module_load_include('inc', $module, $module . '.openlayers_presets'); - } - } - } - - // If features found, we have to explicilty reset the implement - // cache. This could be a significant performance hit on a site - // that has a high number of modules installed. - if ($found_features) { - module_implements('openlayers_presets', FALSE, TRUE); - } - - // Backwards compatibilty for normal presets - $data = module_invoke_all('openlayers_presets'); - if (count($data) > 0) { - $items = $items + $data; - } - - - return $items; -} diff --git a/includes/openlayers.object.inc b/includes/openlayers.object.inc new file mode 100644 index 0000000000000000000000000000000000000000..a0631de4e9b27113602a8e657ae75ca1d3362974 --- /dev/null +++ b/includes/openlayers.object.inc @@ -0,0 +1,72 @@ + '', + 'name' => '', + 'description' => '', + 'class' => '', + 'options' => array() + ); + } + + function options_form() { + return array(); + } + + function init(stdClass $data) { + foreach ($this->defauts_properties() as $property => $value) { + if (isset($data->{$property})) { + $this->{$property} = $data->$property; + } + } + + $this->options = array_replace_recursive((array) $this->options, (array) $data->options); + } + + public function setOption($key, $value = NULL) { + if (is_string($key) && !empty($value)) { + $this->options = array_replace_recursive($this->options, array($key => $value)); + } + if (is_array($key)) { + $this->options = array_replace_recursive($this->options, $key); + } + return $this; + } + + public function getOption($key, $default_value = NULL) { + if (isset($this->options[$key])) { + return $this->options[$key]; + } + if (is_null($default_value)) { + return FALSE; + } + return $default_value; + } + + public function toArray() { + return json_decode(json_encode($this), TRUE); + } + + public function attached() { + if (isset($this->plugin)) { + $file = $this->plugin['path'] . '/' . $this->class . '.js'; + if (file_exists($file)) { + $this->attached['js'][$file] = $file; + unset($this->plugin); + } + } + + return $this->attached; + } + +} diff --git a/includes/openlayers.projections.inc b/includes/openlayers.projections.inc deleted file mode 100644 index e505102ca035ad40715df006ba0a998f23bbe0bb..0000000000000000000000000000000000000000 --- a/includes/openlayers.projections.inc +++ /dev/null @@ -1,245 +0,0 @@ -disabled = FALSE; /* Edit this to true to make a default openlayers_projections disabled initially */ - $openlayers_projections->api_version = 1; - $openlayers_projections->identifier = 'EPSG:2056'; - $openlayers_projections->authority = 'EPSG'; - $openlayers_projections->code = '2056'; - $openlayers_projections->definition = '+proj=somerc +lat_0=46.95240555555556 +lon_0=7.439583333333333 +k_0=1 +x_0=2600000 +y_0=1200000 +ellps=bessel +towgs84=674.374,15.056,405.346,0,0,0,0 +units=m +no_defs'; - $openlayers_projections->projectedextentleft = '2485869.5728'; - $openlayers_projections->projectedextentbottom = '1076443.1884'; - $openlayers_projections->projectedextentright = '2837076.5648'; - $openlayers_projections->projectedextenttop = '1299941.7864'; - $openlayers_projections->data = ''; - $projections[$openlayers_projections->identifier] = $openlayers_projections; - - // Pulkovo 1942(83) / 3-degree Gauß-Krüger zone 4 - $openlayers_projections = new stdClass(); - $openlayers_projections->disabled = FALSE; /* Edit this to true to make a default openlayers_projections disabled initially */ - $openlayers_projections->api_version = 1; - $openlayers_projections->identifier = 'EPSG:2398'; - $openlayers_projections->authority = 'EPSG'; - $openlayers_projections->code = '2398'; - $openlayers_projections->definition = '+proj=tmerc +lat_0=0 +lon_0=12 +k=1 +x_0=4500000 +y_0=0 +ellps=krass +towgs84=24,-123,-94,0.02,-0.25,-0.13,1.1 +units=m +no_defs'; - $openlayers_projections->projectedextentleft = '4390150.9946'; - $openlayers_projections->projectedextentbottom = '5419736.8531'; - $openlayers_projections->projectedextentright = '4610103.4021'; - $openlayers_projections->projectedextenttop = '6067242.1812'; - $openlayers_projections->data = ''; - $projections[$openlayers_projections->identifier] = $openlayers_projections; - - // Pulkovo 1942(83) / 3-degree Gauß-Krüger zone 5 - $openlayers_projections = new stdClass(); - $openlayers_projections->disabled = FALSE; /* Edit this to true to make a default openlayers_projections disabled initially */ - $openlayers_projections->api_version = 1; - $openlayers_projections->identifier = 'EPSG:2399'; - $openlayers_projections->authority = 'EPSG'; - $openlayers_projections->code = '2399'; - $openlayers_projections->definition = '+proj=tmerc +lat_0=0 +lon_0=15 +k=1 +x_0=5500000 +y_0=0 +ellps=krass +towgs84=24,-123,-94,0.02,-0.25,-0.13,1.1 +units=m +no_defs'; - $openlayers_projections->projectedextentleft = '5384982.9245'; - $openlayers_projections->projectedextentbottom = '5152896.3049'; - $openlayers_projections->projectedextentright = '5615270.6353'; - $openlayers_projections->projectedextenttop = '6053880.2778'; - $openlayers_projections->data = ''; - $projections[$openlayers_projections->identifier] = $openlayers_projections; - - // Former EPSG:900913 - $openlayers_projections = new stdClass(); - $openlayers_projections->disabled = FALSE; /* Edit this to true to make a default openlayers_projections disabled initially */ - $openlayers_projections->api_version = 1; - $openlayers_projections->identifier = 'EPSG:3857'; - $openlayers_projections->authority = 'EPSG'; - $openlayers_projections->code = '3857'; - $openlayers_projections->definition = '+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs'; - $openlayers_projections->projectedextentleft = '-20037508.34'; - $openlayers_projections->projectedextentbottom = '-20037508.34'; - $openlayers_projections->projectedextentright = '20037508.34'; - $openlayers_projections->projectedextenttop = '20037508.34'; - $openlayers_projections->data = ''; - $projections[$openlayers_projections->identifier] = $openlayers_projections; - - // ETRS89 - $openlayers_projections = new stdClass(); - $openlayers_projections->disabled = FALSE; /* Edit this to true to make a default openlayers_projections disabled initially */ - $openlayers_projections->api_version = 1; - $openlayers_projections->identifier = 'EPSG:4258'; - $openlayers_projections->authority = 'EPSG'; - $openlayers_projections->code = '4258'; - $openlayers_projections->definition = '+proj=longlat +ellps=GRS80 +no_defs'; - $openlayers_projections->projectedextentleft = '-10.6700'; - $openlayers_projections->projectedextentbottom = '34.5000'; - $openlayers_projections->projectedextentright = '31.5500'; - $openlayers_projections->projectedextenttop = '71.0500'; - $openlayers_projections->data = ''; - $projections[$openlayers_projections->identifier] = $openlayers_projections; - - $openlayers_projections = new stdClass(); - $openlayers_projections->disabled = FALSE; /* Edit this to true to make a default openlayers_projections disabled initially */ - $openlayers_projections->api_version = 1; - $openlayers_projections->identifier = 'EPSG:4326'; - $openlayers_projections->authority = 'EPSG'; - $openlayers_projections->code = '4326'; - $openlayers_projections->definition = '+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs'; - $openlayers_projections->projectedextentleft = '-180'; - $openlayers_projections->projectedextentbottom = '-90'; - $openlayers_projections->projectedextentright = '180'; - $openlayers_projections->projectedextenttop = '90'; - $openlayers_projections->data = ''; - $projections[$openlayers_projections->identifier] = $openlayers_projections; - - // CH1903 / LV03 - $openlayers_projections = new stdClass(); - $openlayers_projections->disabled = FALSE; /* Edit this to true to make a default openlayers_projections disabled initially */ - $openlayers_projections->api_version = 1; - $openlayers_projections->identifier = 'EPSG:21781'; - $openlayers_projections->authority = 'EPSG'; - $openlayers_projections->code = '21781'; - // Warning: Conversions without grid shift file yield errors of up to 2.5m - $openlayers_projections->definition = '+proj=somerc +lat_0=46.95240555555556 +lon_0=7.439583333333333 +k_0=1 +x_0=600000 +y_0=200000 +ellps=bessel +towgs84=674.374,15.056,405.346,0,0,0,0 +units=m +no_defs'; - $openlayers_projections->projectedextentleft = '485869.5728'; - $openlayers_projections->projectedextentbottom = '76443.1884'; - $openlayers_projections->projectedextentright = '837076.5648'; - $openlayers_projections->projectedextenttop = '299941.7864'; - $openlayers_projections->data = ''; - $projections[$openlayers_projections->identifier] = $openlayers_projections; - - // ETRS89 / UTM zone 32N - $openlayers_projections = new stdClass(); - $openlayers_projections->disabled = FALSE; /* Edit this to true to make a default openlayers_projections disabled initially */ - $openlayers_projections->api_version = 1; - $openlayers_projections->identifier = 'EPSG:25832'; - $openlayers_projections->authority = 'EPSG'; - $openlayers_projections->code = '25832'; - $openlayers_projections->definition = '+proj=utm +zone=32 +ellps=GRS80 +units=m +no_defs'; - $openlayers_projections->projectedextentleft = '265948.8191'; - $openlayers_projections->projectedextentbottom = '6421521.2254'; - $openlayers_projections->projectedextentright = '677786.3629'; - $openlayers_projections->projectedextenttop = '7288831.7014'; - $openlayers_projections->data = ''; - $projections[$openlayers_projections->identifier] = $openlayers_projections; - - // ETRS89 / UTM zone 33N - $openlayers_projections = new stdClass(); - $openlayers_projections->disabled = FALSE; /* Edit this to true to make a default openlayers_projections disabled initially */ - $openlayers_projections->api_version = 1; - $openlayers_projections->identifier = 'EPSG:25833'; - $openlayers_projections->authority = 'EPSG'; - $openlayers_projections->code = '25833'; - $openlayers_projections->definition = '+proj=utm +zone=33 +ellps=GRS80 +units=m +no_defs'; - $openlayers_projections->projectedextentleft = '227879.8880'; - $openlayers_projections->projectedextentbottom = '3932632.6543'; - $openlayers_projections->projectedextentright = '1044484.3835'; - $openlayers_projections->projectedextenttop = '8893131.0281'; - $openlayers_projections->data = ''; - $projections[$openlayers_projections->identifier] = $openlayers_projections; - - // OSGB 1936 / British National Grid - $openlayers_projections = new stdClass(); - $openlayers_projections->disabled = FALSE; /* Edit this to true to make a default openlayers_projections disabled initially */ - $openlayers_projections->api_version = 1; - $openlayers_projections->identifier = 'EPSG:27700'; - $openlayers_projections->authority = 'EPSG'; - $openlayers_projections->code = '27700'; - $openlayers_projections->definition = '+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy +datum=OSGB36 +units=m +no_defs'; - $openlayers_projections->projectedextentleft = '1393.0196'; - $openlayers_projections->projectedextentbottom = '13494.9764'; - $openlayers_projections->projectedextentright = '671196.3657'; - $openlayers_projections->projectedextenttop = '1230275.0454'; - $openlayers_projections->data = ''; - $projections[$openlayers_projections->identifier] = $openlayers_projections; - - // DHDN / 3-degree Gauß-Krüger zone 2 - $openlayers_projections = new stdClass(); - $openlayers_projections->disabled = FALSE; /* Edit this to true to make a default openlayers_projections disabled initially */ - $openlayers_projections->api_version = 1; - $openlayers_projections->identifier = 'EPSG:31466'; - $openlayers_projections->authority = 'EPSG'; - $openlayers_projections->code = '31466'; - $openlayers_projections->definition = '+proj=tmerc +lat_0=0 +lon_0=6 +k=1 +x_0=2500000 +y_0=0 +ellps=bessel +datum=potsdam +units=m +no_defs'; - $openlayers_projections->projectedextentleft = '2490547.1867'; - $openlayers_projections->projectedextentbottom = '5440321.7879'; - $openlayers_projections->projectedextentright = '2609576.6008'; - $openlayers_projections->projectedextenttop = '5958700.0208'; - $openlayers_projections->data = ''; - $projections[$openlayers_projections->identifier] = $openlayers_projections; - - // DHDN / 3-degree Gauß-Krüger zone 3 - $openlayers_projections = new stdClass(); - $openlayers_projections->disabled = FALSE; /* Edit this to true to make a default openlayers_projections disabled initially */ - $openlayers_projections->api_version = 1; - $openlayers_projections->identifier = 'EPSG:31467'; - $openlayers_projections->authority = 'EPSG'; - $openlayers_projections->code = '31467'; - $openlayers_projections->definition = '+proj=tmerc +lat_0=0 +lon_0=9 +k=1 +x_0=3500000 +y_0=0 +ellps=bessel +datum=potsdam +units=m +no_defs'; - $openlayers_projections->projectedextentleft = '3386564.9400'; - $openlayers_projections->projectedextentbottom = '5237917.9109'; - $openlayers_projections->projectedextentright = '3613579.2251'; - $openlayers_projections->projectedextenttop = '6104500.7393'; - $openlayers_projections->data = ''; - $projections[$openlayers_projections->identifier] = $openlayers_projections; - - // DHDN / 3-degree Gauß-Krüger zone 4 - $openlayers_projections = new stdClass(); - $openlayers_projections->disabled = FALSE; /* Edit this to true to make a default openlayers_projections disabled initially */ - $openlayers_projections->api_version = 1; - $openlayers_projections->identifier = 'EPSG:31468'; - $openlayers_projections->authority = 'EPSG'; - $openlayers_projections->code = '31468'; - $openlayers_projections->definition = '+proj=tmerc +lat_0=0 +lon_0=12 +k=1 +x_0=4500000 +y_0=0 +ellps=bessel +datum=potsdam +units=m +no_defs'; - $openlayers_projections->projectedextentleft = '4386596.4101'; - $openlayers_projections->projectedextentbottom = '5237914.5325'; - $openlayers_projections->projectedextentright = '4613610.5843'; - $openlayers_projections->projectedextenttop = '6104496.9694'; - $openlayers_projections->data = ''; - $projections[$openlayers_projections->identifier] = $openlayers_projections; - - // DHDN / 3-degree Gauß-Krüger zone 5 - $openlayers_projections = new stdClass(); - $openlayers_projections->disabled = FALSE; /* Edit this to true to make a default openlayers_projections disabled initially */ - $openlayers_projections->api_version = 1; - $openlayers_projections->identifier = 'EPSG:31469'; - $openlayers_projections->authority = 'EPSG'; - $openlayers_projections->code = '31469'; - $openlayers_projections->definition = '+proj=tmerc +lat_0=0 +lon_0=15 +k=1 +x_0=5500000 +y_0=0 +ellps=bessel +datum=potsdam +units=m +no_defs'; - $openlayers_projections->projectedextentleft = '5386627.6162'; - $openlayers_projections->projectedextentbottom = '5237909.9506'; - $openlayers_projections->projectedextentright = '5613641.6401'; - $openlayers_projections->projectedextenttop = '6104491.8566'; - $openlayers_projections->data = ''; - $projections[$openlayers_projections->identifier] = $openlayers_projections; - - // TODO Remove before publishing as replaced by EPSG:3857 - $openlayers_projections = new stdClass(); - $openlayers_projections->disabled = FALSE; /* Edit this to true to make a default openlayers_projections disabled initially */ - $openlayers_projections->api_version = 1; - $openlayers_projections->identifier = 'EPSG:900913'; - $openlayers_projections->authority = 'EPSG'; - $openlayers_projections->code = '900913'; - $openlayers_projections->definition = '+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs'; - $openlayers_projections->projectedextentleft = '-20037508.34'; - $openlayers_projections->projectedextentbottom = '-20037508.34'; - $openlayers_projections->projectedextentright = '20037508.34'; - $openlayers_projections->projectedextenttop = '20037508.34'; - $openlayers_projections->data = ''; - $projections[$openlayers_projections->identifier] = $openlayers_projections; - - return $projections; -} diff --git a/includes/openlayers.render.inc b/includes/openlayers.render.inc deleted file mode 100644 index a867ef367e7f4126f8ee1dd3089629d01300ce6f..0000000000000000000000000000000000000000 --- a/includes/openlayers.render.inc +++ /dev/null @@ -1,181 +0,0 @@ - $layer) { - if ($layer_object = openlayers_layer_load($layer)) { - $layers[$key] = $layer_object; - if (!empty($map['layer_weight'][$key])) { - $layers[$key]->weight = $map['layer_weight'][$key]; - } - else $layers[$key]->weight = 0; - } - else unset($layers[$key]); - } - - // Sort layers - usort($layers, '_openlayers_layers_process_sort'); - - // Process into array-based layer data for the map - foreach ($layers as $type => $layer_object) { - if (is_object($layer_object)) { - $layer_object->data['title'] = $layer_object->title; - $layer_object->data['weight'] = $layer_object->weight; - $layer_data[$layer_object->name] = $layer_object; - } - } - - return $layer_data; -} - -/** - * Callback function for sorting - * - * @param $a - * Layer $a - * @param $b - * Layer $b - * @return $a_greater_b - * Return the weight different - allowing usort to sort - */ -function _openlayers_layers_process_sort($a, $b) { - return intval($a->weight - $b->weight); -} - -/** - * Execute render() method for all enabled behaviors. - * - * @param $behaviors - * Array of behaviors to process - * @param $map - * Map array - * @return $rendered - * Indexed array of rendered behaviors - */ -function _openlayers_behaviors_render($behaviors = array(), &$map = array()) { - $rendered = array(); - - foreach (openlayers_behaviors() as $key => $plugin) { - if (isset($behaviors[$key]) && $class = ctools_plugin_get_class($plugin, 'behavior')) { - $rendered[$key] = new $class($behaviors[$key], $map); - } - } - - return $rendered; -} - -/** - * Process Styles - * - * Get full data for any styles. The idea is that we load - * all the needed styles into the ['styles'] key of the - * map object, and keep a reference in ['layer_styles'] - * and ['layer_styles_select'] for layer specific styling. - * - * TODO: Overall, this is not a great approach to managing - * styles. - * - * @param $styles - * Array of map styles ( : | ) - * @param $layer_styles - * Array of layer styles ( : ) - * @param $layer_styles_select - * Array of layer styles ( : ) - * @param $map - * Map array - * @return $processed - * Array of processed styles ( => ) - */ -function _openlayers_styles_process($styles = array(), - $layer_styles = array(), $layer_styles_select = array(), $layer_styles_temporary = array(), &$map = array()) { - - // Get styles info array - $styles_info = openlayers_styles(); - - // Go through styles - $processed = array(); - foreach ($styles as $k => $style) { - // Check if array, if array, just pass on - if (is_array($style)) { - $processed[$k] = $style; - } - elseif (!empty($styles_info[$style]) && $info = $styles_info[$style]->data) { - $processed[$k] = $info; - } - } - - // Add layer styles - foreach ($layer_styles as $key => $style) { - if (!isset($processed[$style]) && - !empty($styles_info[$style]) && - $info = $styles_info[$style]->data) { - $processed[$style] = $info; - } - if (empty($style)) { - // If a particular layer's style is 0, set it to the appropriate default. - $map['layer_styles'][$key] = 'default'; - } - } - - // Add layer styles select - foreach ($layer_styles_select as $key => $style) { - if (!isset($processed[$style]) && - !empty($styles_info[$style]) && - $info = $styles_info[$style]->data) { - $processed[$style] = $info; - } - if (empty($style)) { - // If a particular layer's style is 0, set it to the appropriate default. - $map['layer_styles_select'][$key] = 'select'; - } - } - - // Add layer styles temporary - foreach ($layer_styles_temporary as $key => $style) { - if (!isset($processed[$style]) && - !empty($styles_info[$style]) && - $info = $styles_info[$style]->data) { - $processed[$style] = $info; - } - if (empty($style)) { - // If a particular layer's style is 0, set it to the appropriate default. - $map['layer_styles_temporary'][$key] = 'temporary'; - } - } - - // Return processed - return $processed; -} - -/** - * Create Map ID - * - * Create a unique ID for any maps that are not assigned an ID - * - * @note - * Technically someone can assign a map ID identical - * to the one that is created - * @return - * New map id - */ -function _openlayers_create_map_id($default = 'openlayers-map') { - return drupal_html_id($default); -} diff --git a/includes/openlayers.source.inc b/includes/openlayers.source.inc new file mode 100644 index 0000000000000000000000000000000000000000..9257d836c72a4d3034cdbe4555f1a3ec380709a7 --- /dev/null +++ b/includes/openlayers.source.inc @@ -0,0 +1,5 @@ +api_version = 1; - $style->name = 'invisible'; - $style->title = t('Invisible style'); - $style->description = t('Invisible default style.'); - $style->data = array( - 'pointRadius' => '0', - 'strokeWidth' => '0', - 'fillOpacity' => '0' - ); - $styles[$style->name] = $style; - - // Default style - $style = new stdClass(); - $style->api_version = 1; - $style->name = 'default'; - $style->title = t('Default style'); - $style->description = t('Basic default style.'); - $style->data = array( - 'pointRadius' => '6', - 'fillColor' => '#888888', - 'strokeColor' => '#222222', - 'strokeWidth' => '4', - 'fillOpacity' => '0.5', - 'strokeOpacity' => '0.7', - ); - $styles[$style->name] = $style; - - // Default select style - $style = new stdClass(); - $style->api_version = 1; - $style->name = 'default_select'; - $style->title = t('Default select style'); - $style->description = t('Default style for selected geometries'); - $style->data = array( - 'pointRadius' => '6', - 'fillColor' => '#222222', - 'strokeColor' => '#888888', - 'strokeWidth' => '4', - 'fillOpacity' => '0.7', - 'strokeOpacity' => '0.8', - ); - $styles[$style->name] = $style; - - // Default temporary style - $style = new stdClass(); - $style->api_version = 1; - $style->name = 'default_temporary_select'; - $style->title = t('Default temporary select style'); - $style->description = t('Default temporary style when using tooltips or hovering behavior'); - $style->data = array( - 'pointRadius' => '6', - 'fillColor' => '#222222', - 'strokeColor' => '#888888', - 'strokeWidth' => '4', - 'fillOpacity' => '0.9', - 'strokeOpacity' => '0.8', - ); - $styles[$style->name] = $style; - - // Custom black markers - $style = new stdClass(); - $style->api_version = 1; - $style->name = 'default_marker_black'; - $style->title = t('Marker Black'); - $style->description = t('Black marker provided by the OpenLayers module.'); - $style->data = array( - 'externalGraphic' => base_path() . drupal_get_path('module', 'openlayers') . - '/themes/default_dark/markers/marker-black.png', - 'graphicWidth' => 25, - 'graphicHeight' => 41, - 'graphicXOffset' => -12, - 'graphicYOffset' => -41, - ); - $styles[$style->name] = $style; - - $style = new stdClass(); - $style->api_version = 1; - $style->name = 'default_marker_black_small'; - $style->title = t('Marker Black Small'); - $style->description = t('Small black marker provided by the OpenLayers module.'); - $style->data = array( - 'externalGraphic' => base_path() . drupal_get_path('module', 'openlayers') . - '/themes/default_dark/markers/marker-black-small.png', - 'graphicWidth' => 16, - 'graphicHeight' => 26, - 'graphicXOffset' => -8, - 'graphicYOffset' => -26, - ); - $styles[$style->name] = $style; - - // Marker styles - $markers = array( - 'red' => t('Red'), - 'green' => t('Green'), - 'gold' => t('Gold'), - 'blue' => t('Blue'), - ); - - foreach ($markers as $marker => $color) { - $style = new stdClass(); - $style->api_version = 1; - $style->name = 'default_marker_' . $marker; - $style->title = t('Marker !color', array('!color' => $color)); - $style->description = t('!color marker provided by the OpenLayers module.', - array('!color' => $color)); - $style->data = array( - 'externalGraphic' => base_path() . drupal_get_path('module', 'openlayers') . - '/themes/default_dark/img/marker-' . $marker . '.png', - 'graphicWidth' => 21, - 'graphicHeight' => 25, - 'graphicXOffset' => -10, - 'graphicYOffset' => -25, - ); - $styles[$style->name] = $style; - } - - return $styles; -} diff --git a/js/openlayers.js b/js/openlayers.js index 7632a3ddd31d60f250c9b77dc3753e5837d2ca6f..6a7c75c216a42237d207ded297e49b3dec91c536 100644 --- a/js/openlayers.js +++ b/js/openlayers.js @@ -2,454 +2,156 @@ /*jslint forin: true */ /*global OpenLayers Drupal $ document jQuery window */ -/** - * @file - * This file holds the main javascript API for OpenLayers. It is - * responsable for loading and displaying the map. - * - * @ingroup openlayers - */ - -/** - * This is a workaround for a bug involving IE and VML support. - * See the Drupal Book page describing this problem: - * http://drupal.org/node/613002 - */ - document.namespaces; (function($) { + Drupal.behaviors.openlayers = { + 'attach': function(context, settings) { + + if (typeof(Drupal.settings.openlayers) === 'object' && Drupal.settings.openlayers.maps) { + $('.openlayers-map').once('openlayers-map', function() { + var map_id = $(this).attr('id'); + if (Drupal.settings.openlayers.maps[map_id]) { + try { + var object = Drupal.settings.openlayers.maps[map_id]; + var layers = object.layer || []; + var controls = object.control || []; + var interactions = object.interaction || []; + var sources = object.source || []; + // Todo: see why this is not working with ajax. + var objects = {}; + objects.sources = {}; + objects.controls = {}; + objects.interactions = {}; + objects.layers = {}; + + object.map.options.layers = []; + object.map.options.controls = []; + object.map.options.interactions = []; + + Drupal.openlayers.console.info("Creating map object..."); + var map = Drupal.openlayers[object.map.class](object.map.options); + Drupal.openlayers.console.info("Creating map object... done !"); + + Drupal.openlayers.console.info("Building sources..."); + sources.map(function(data){ + objects.sources[data.machine_name] = Drupal.openlayers.getObject(context, 'sources', data, map); + }); + Drupal.openlayers.console.info("Building sources... done !"); + + Drupal.openlayers.console.info("Building controls..."); + controls.map(function(data){ + objects.controls[data.machine_name] = Drupal.openlayers.getObject(context, 'controls', data, map); + map.addControl(objects.controls[data.machine_name]); + }); + Drupal.openlayers.console.info("Building controls... done !"); + + Drupal.openlayers.console.info("Building interactions..."); + interactions.map(function(data){ + objects.interactions[data.machine_name] = Drupal.openlayers.getObject(context, 'interactions', data, map); + map.addInteraction(objects.interactions[data.machine_name]); + }); + Drupal.openlayers.console.info("Building interactions... done !"); + + Drupal.openlayers.console.info("Building layers..."); + layers.map(function(data){ + Drupal.openlayers.console.info(" Adding source to layer..."); + data.options.source = objects.sources[data.options.source]; + objects.layers[data.machine_name] = Drupal.openlayers.getObject(context, 'layers', data, map); + Drupal.openlayers.console.info(" Adding layer to map..."); + map.addLayer(objects.layers[data.machine_name]); + }); + Drupal.openlayers.console.info("Building layers... done !"); + + // Attach data to map DOM object + Drupal.openlayers.console.info("Caching objects..."); + jQuery(context).data('openlayers', {'map': map, 'objects': objects}); + Drupal.openlayers.console.info("Caching objects... done !"); -Drupal.settings.openlayers = {}; -Drupal.settings.openlayers.maps = {}; - -/** - * Minimal OpenLayers map bootstrap. - * All additional operations occur in additional Drupal behaviors. - */ -Drupal.behaviors.openlayers = { - 'attach': function(context, settings) { - Drupal.openlayers.loadProjections(context, settings); - - if (typeof(Drupal.settings.openlayers) === 'object' && - Drupal.settings.openlayers.maps && - !$(context).data('openlayers')) { - $('.openlayers-map').once('openlayers-map', function() { - // By setting the stop_render variable to TRUE, this will - // halt the render process. If set, one could remove this setting - // then call Drupal.attachBehaviors again to get it started - var map_id = $(this).attr('id'); - if (Drupal.settings.openlayers.maps[map_id] && Drupal.settings.openlayers.maps[map_id].stop_render != true) { - var map = Drupal.settings.openlayers.maps[map_id]; - - if(map.default_layer===null){ - Drupal.openlayers.console.error("Map configuration is invalid as it lacks a base layer."); - } - - // Use try..catch for error handling. - try { - // Set OpenLayers language based on document language, - // rather than browser language - OpenLayers.Lang.setCode($('html').attr('lang')); - - var options = {}; - // This is necessary because the input JSON cannot contain objects - options.projection = new OpenLayers.Projection(map.projection); - options.displayProjection = new OpenLayers.Projection(map.displayProjection); - - // Restrict map to its extent (usually projection extent). - options.maxExtent = OpenLayers.Bounds.fromArray(map.maxExtent); - - options.maxResolution = 'auto'; - options.controls = []; - - // Change image, CSS, and proxy paths if specified - if (map.image_path) { - OpenLayers.ImgPath = Drupal.openlayers.relatePath(map.image_path, - Drupal.settings.basePath); - } - if (map.css_path) { - options.theme = Drupal.openlayers.relatePath(map.css_path, - Drupal.settings.basePath); } - if (map.proxy_host) { - OpenLayers.ProxyHost = Drupal.openlayers.relatePath(map.proxy_host, - Drupal.settings.basePath); - } - - // Initialize openlayers map - var openlayers = new OpenLayers.Map(map_id, options); - - // Run the layer addition first - Drupal.openlayers.addLayers(map, openlayers); - - // Ensure redraw as maps stays blank until first zoom otherwise (observed with EPSG:2056) - openlayers.moveTo(openlayers.getCenter(), openlayers.getZoom(), { - forceZoomChange: true - }); - - // Attach data to map DOM object - $(this).data('openlayers', {'map': map, 'openlayers': openlayers}); - - // Finally, attach behaviors - Drupal.attachBehaviors(this); - - // Always load the map when the page has finished loading. - // See #2227993 and #2254625 - $(window).load(function() { - openlayers.render(map.id); - }); - } - catch (e) { - var errorMessage = e.name + ': ' + e.message; - if (typeof console != 'undefined') { - Drupal.openlayers.console.log(errorMessage); - } - else { - $(this).text('Error during map rendering: ' + errorMessage); + catch (e) { + var errorMessage = e.name + ': ' + e.message; + if (typeof console != 'undefined') { + Drupal.openlayers.console.log(errorMessage); + } + else { + $(this).text('Error during map rendering: ' + errorMessage); + } } } - } - }); - } - } -}; - -/** - * Collection of helper methods. - */ -Drupal.openlayers = { - // Determine path based on format. - 'relatePath': function(path, basePath) { - // Check for a full URL or an absolute path. - if (path.indexOf('://') >= 0 || path.indexOf('/') == 0) { - return path; - } - else { - return basePath + path; - } - }, - /* - * Redraw Vectors. - * This is necessary because various version of IE cannot draw vectors on - * $(document).ready() - */ - 'redrawVectors': function() { - $(window).load( - function() { - var map; - for (map in Drupal.settings.openlayers.maps) { - $.each($('#' + map).data('openlayers') - .openlayers.getLayersByClass('OpenLayers.Layer.Vector'), - function(i, layer) { - layer.redraw(); - } - ); - } - } - ); - }, - /** - * Add layers to the map - * - * @param map Drupal settings object for the map. - * @param openlayers OpenLayers Map Object. - */ - 'addLayers': function(map, openlayers) { - - var sorted = []; - for (var name in map.layers) { - sorted.push({'name': name, 'weight': map.layers[name].weight, 'isBaseLayer': map.layers[name].isBaseLayer }); - } - - sorted.sort(function(a, b) { - var x = parseInt(a.weight, 10), y = parseInt(b.weight, 10); - return ((a.isBaseLayer && x < y) ? -1 : ((b.isBaseLayer || x > y) ? 1 : 0)); - }); - - for (var i = 0; i < sorted.length; ++i) { - var layer, - name = sorted[i].name, - options = map.layers[name]; - - // Add reference to our layer ID - options.drupalID = name; - // Ensure that the layer handler is available - if (options.layer_handler !== undefined && - Drupal.openlayers.layer[options.layer_handler] !== undefined) { - - layer = Drupal.openlayers.layer[options.layer_handler](map.layers[name].title, map, options); - - layer.visibility = !!(!map.layer_activated || map.layer_activated[name]); - - if (layer.isBaseLayer === false) { - layer.displayInLayerSwitcher = (!map.layer_switcher || map.layer_switcher[name]); - } - - openlayers.addLayer(layer); - } - } - - openlayers.setBaseLayer(openlayers.getLayersBy('drupalID', map.default_layer)[0]); - - // Set the restricted extent if wanted. - // Prevents the map from being panned outside of a specfic bounding box. - if (typeof map.center.restrict !== 'undefined' && map.center.restrict.restrictextent) { - var desiredRestriction = OpenLayers.Bounds.fromString( - map.center.restrict.restrictedExtent - ).transform(new OpenLayers.Projection('EPSG:3857'), openlayers.projection); - - if(desiredRestriction.left>=openlayers.maxExtent.left && desiredRestriction.right<=openlayers.maxExtent.right - && desiredRestriction.top<=openlayers.maxExtent.top && desiredRestriction.bottom>=openlayers.maxExtent.bottom){ - - openlayers.restrictedExtent = desiredRestriction; - } else { - // Given the map to set the restricted extent is not dependent on the map projection - // it does allow to set an extent outwith the valid bound of the map projection. As a - // result no valid data could be requested and thus the wrong extent needs to be ignored. - Drupal.openlayers.console.error("Restricted bounds ignored as not within projection bounds."); + }); } } + }; - // Zoom & center - if (map.center.initial) { - var center = OpenLayers.LonLat.fromString(map.center.initial.centerpoint).transform( - new OpenLayers.Projection('EPSG:4326'), - new OpenLayers.Projection(map.projection)); - var zoom = parseInt(map.center.initial.zoom, 10); - openlayers.setCenter(center, zoom, false, false); - } - }, /** - * Abstraction of OpenLayer's feature adding syntax to work with Drupal output. - * Ideally this should be rolled into the PHP code, because we don't want to manually - * parse WKT + * Collection of helper methods. */ - 'addFeatures': function(map, layer, features) { - var newFeatures = []; - - // Go through features - for (var key in features) { - var feature = features[key]; - var newFeatureObject = this.objectFromFeature(feature); - - // If we have successfully extracted geometry add additional - // properties and queue it for addition to the layer - if (newFeatureObject) { - var newFeatureSet = []; - - // Check to see if it is a new feature, or an array of new features. - if (typeof(newFeatureObject[0]) === 'undefined') { - newFeatureSet[0] = newFeatureObject; - } - else { - newFeatureSet = newFeatureObject; - } + Drupal.openlayers = { - // Go through new features - for (var i = 0; i < newFeatureSet.length; i++) { - var newFeature = newFeatureSet[i]; + 'getObject': (function (context, type, data, map) { + var cache = $(context).data('openlayers') || {}; - // Transform the geometry if the 'projection' property is different from the map projection - if (feature.projection) { - if (feature.projection !== map.projection) { - var featureProjection = new OpenLayers.Projection(feature.projection); - var mapProjection = new OpenLayers.Projection(map.projection); - newFeature.geometry.transform(featureProjection, mapProjection); - } - } - - // Add attribute data - if (feature.attributes) { - // Attributes belong to features, not single component geometries - // of them. But we're creating a geometry for each component for - // better performance and clustering support. Let's call these - // "pseudofeatures". - // - // In order to identify the real feature each geometry belongs to - // we then add a 'fid' parameter to the "pseudofeature". - // NOTE: 'drupalFID' is only unique within a single layer. - newFeature.attributes = feature.attributes; - newFeature.data = feature.attributes; - newFeature.drupalFID = key; - } - - // Add style information - if (feature.style) { - newFeature.style = jQuery.extend({}, - OpenLayers.Feature.Vector.style['default'], - feature.style); - } - - // Push new features - newFeatures.push(newFeature); - } + if (typeof cache.objects != 'undefined') { + cache = cache.objects; + } else { + cache.sources = []; + cache.controls = []; + cache.layers = []; + cache.interactions = []; + cache.map = []; } - } - - // Add new features if there are any - if (newFeatures.length !== 0) { - layer.addFeatures(newFeatures); - } - }, - 'getStyleMap': function(map, layername) { - if (map.styles) { - var stylesAdded = {}; + cache = $.extend({}, cache.objects, cache); - // Grab and map base styles. - for (var style in map.styles) { - stylesAdded[style] = new OpenLayers.Style(map.styles[style]); - } - - // Implement layer-specific styles. First default, then select. - if (map.layer_styles !== undefined && map.layer_styles[layername]) { - var style = map.layer_styles[layername]; - stylesAdded['default'] = new OpenLayers.Style(map.styles[style]); - } - if (map.layer_styles_select !== undefined && map.layer_styles_select[layername]) { - var style = map.layer_styles_select[layername]; - stylesAdded['select'] = new OpenLayers.Style(map.styles[style]); - } - if (map.layer_styles_temporary !== undefined && map.layer_styles_temporary[layername]) { - var style = map.layer_styles_temporary[layername]; - stylesAdded['temporary'] = new OpenLayers.Style(map.styles[style]); + var object; + if (typeof cache[type][data.machine_name] == 'undefined') { + Drupal.openlayers.console.info(" Computing " + type + " " + data.machine_name + "..."); + cache[type][data.machine_name] = Drupal.openlayers[data.class](data.options, map); + object = cache[type][data.machine_name] + } else { + Drupal.openlayers.console.info("Loading " + type + " " + data.machine_name +" from cache"); + object = cache[type][data.machine_name] } - return new OpenLayers.StyleMap(stylesAdded); - } - else { - return new OpenLayers.StyleMap({ - 'default': new OpenLayers.Style({ - pointRadius: 5, - fillColor: '#ffcc66', - strokeColor: '#ff9933', - strokeWidth: 4, - fillOpacity: 0.5 - }), - 'select': new OpenLayers.Style({ - fillColor: '#66ccff', - strokeColor: '#3399ff' - }) - }); - } - }, - - 'objectFromFeature': function(feature) { - var wktFormat = new OpenLayers.Format.WKT(); - // Extract geometry either from wkt property or lon/lat properties - if (feature.wkt) { - return wktFormat.read(feature.wkt); - } - else if (feature.lon) { - return wktFormat.read('POINT(' + feature.lon + ' ' + feature.lat + ')'); - } - }, - - /** - * Add Behavior. - * - * This is a wrapper around adding behaviors for OpenLayers. - * a module does not have to use this, but it helps cut - * down on code. - * - * @param id - * The identifier of the behavior that is attached to - * the map. - * @param attach - * The callback function for the attach part of the - * Drupal behavior. - * @param detach - * The callback function for the detach part of the - * Drupal behavior. - */ - 'addBehavior': function(id, attach, detach) { - // Add as a Drupal behavior. Add a prefix, just to be safe. - Drupal.behaviors['openlayers_auto_' + id] = { - attach: function (context, settings) { - var data = $(context).data('openlayers'); - - // Ensure that there is a map and that the appropriate - // behavior exists. Need "data &&" to avoid js crash - // when data is empty - var localBehavior = data && data.map.behaviors[id]; - - // Ensure scope in the attach callback - var that = this; - if (localBehavior) { - $(context).once('openlayers-' + id, function () { - attach.apply(that, [data, data.map.behaviors[id], context, settings]); - }); + return object; + }), + + /** + * Logging implementation that logs using the browser's logging API. + * Falls back to doing nothing in case no such API is available. Simulates + * the presece of Firebug's console API in Drupal.openlayers.console. + */ + 'console': (function(){ + var api = {}; + var logger; + if(typeof(console)==="object" && typeof(console.log)==="function"){ + logger = function(){ + // Use console.log as fallback for missing parts of API if present. + console.log.apply(console, arguments); } - }, - // Maybe we need a little more handling here. - detach: detach - }; - }, - - /** - * Add Control. - * - * This is a wrapper around adding controls to maps. It - * is not needed but saves some code. - */ - 'addControl': function(openlayers, controlName, options) { - var control = new OpenLayers.Control[controlName](options); - openlayers.addControl(control); - control.activate(); - return control; - }, - - /** - * Instructs the Proj4js module to make projection definitions available - * to Proj4js and thus OpenLayers, too. - * - * Triggering the initialization of Proj4js this way guarantees projection - * definitions are available. - */ - 'loadProjections': function(context, settings){ - // Proj4js is not necessarily present as we only load it when OpenLayers - // can't handle the projections is use without its help. - if(Drupal.behaviors.proj4js){ - Drupal.behaviors.proj4js.attach(context, settings); - } - }, - - /** - * Logging implementation that logs using the browser's logging API. - * Falls back to doing nothing in case no such API is available. Simulates - * the presece of Firebug's console API in Drupal.openlayers.console. - */ - 'console': (function(){ - var api = {}; - var logger; - if(typeof(console)==="object" && typeof(console.log)==="function"){ - logger = function(){ - // Use console.log as fallback for missing parts of API if present. - console.log.apply(console, arguments); - } - } else { - logger = function (){ - // Ignore call as no logging facility is available. - }; - } - jQuery(["log", "debug", "info", "warn", "exception", "assert", "dir", - "dirxml", "trace", "group", "groupEnd", "groupCollapsed", "profile", - "profileEnd", "count", "clear", "time", "timeEnd", "timeStamp", "table", - "error"]).each(function(index, functionName){ - if(typeof(console)!=="object" || typeof(console[functionName])!=="function"){ - // Use fallback as browser does not provide implementation. - api[functionName] = logger; } else { - api[functionName] = function(){ - // Use browsers implementation. - console[functionName].apply(console, arguments); + logger = function (){ + // Ignore call as no logging facility is available. }; } - }); - return api; - })() -}; + jQuery(["log", "debug", "info", "warn", "exception", "assert", "dir", + "dirxml", "trace", "group", "groupEnd", "groupCollapsed", "profile", + "profileEnd", "count", "clear", "time", "timeEnd", "timeStamp", "table", + "error"]).each(function(index, functionName){ + if(typeof(console)!=="object" || typeof(console[functionName])!=="function"){ + // Use fallback as browser does not provide implementation. + api[functionName] = logger; + } else { + api[functionName] = function(){ + // Use browsers implementation. + console[functionName].apply(console, arguments); + }; + } + }); + return api; + })() + }; -Drupal.openlayers.layer = {}; + Drupal.openlayers.layer = {}; })(jQuery); diff --git a/modules/openlayers_ui/includes/openlayers_ui.admin.inc b/modules/openlayers_ui/includes/openlayers_ui.admin.inc index 1fca365bedf56e4c0368ec69c38eb8c87840dc0f..46267e603dd992143ef58a4f5fc53856754bf0f1 100644 --- a/modules/openlayers_ui/includes/openlayers_ui.admin.inc +++ b/modules/openlayers_ui/includes/openlayers_ui.admin.inc @@ -12,87 +12,25 @@ * * @see system_settings_form() */ -function openlayers_ui_admin_settings() { - $client_check = variable_get('openlayers_ui_version_check', 'no-check'); - $source_description = - t('

By default the your site will point to a hosted version of the - OpenLayers library at %ol_api_url.

-

For better performance and reliability, you should use an internal version of the library. - Download the OpenLayers library, and add it to your Drupal installation. - Use the new drush command \'dl-openlayers\' to download it and place it at the right place automatically. - If you download the library manually, then place it in the libraries/openlayers folder and new options will appear under OpenLayers source type on this page. - You can also use a double backslash before the domain name - (eg. //www.example.com/OpenLayers.js) which then respects the use of both HTTPS and HTTP protocols.

-
    -
  • The default suggested, compatible version: %suggested_api
  • -
  • The default suggested, compatible hosted URL: %ol_api_url
  • -
  • Your version found from client-side, Javascript check: %client
  • -
', - array( - '%ol_api_url' => OPENLAYERS_DEFAULT_LIBRARY, - '%suggested_api' => OPENLAYERS_SUGGESTED_LIBRARY, - '!ol_url' => 'http://openlayers.org/', - '%client' => ($client_check == 'no-check') ? t('(not checked)') : $client_check, - ) - ); - - $options = array('external' => 'External'); - if (module_exists('libraries') && - ($library = libraries_detect('openlayers')) && !empty($library['installed'])) { - $options += array('internal' => 'Internal'); +function openlayers_ui_admin_settings($form, &$form_state) { + + ctools_include('plugins'); + ctools_include('export'); + $maps = ctools_export_crud_load_all('openlayers_maps'); + $options = array(); + foreach($maps as $machine_name => $data) { + $map = openlayers_object_load('map', $machine_name); + // Todo: Rewrite properly and create a generic function to load all objects. + if (property_exists($map, 'disabled') && ($map->disabled == 1 || $map->disabled == TRUE)) continue; + $options[$machine_name] = $data->name; } - $form['openlayers_source_type'] = array( - '#type' => 'radios', - '#options' => $options, - '#title' => t('OpenLayers source type'), - '#description' => t(' -
    -
  • Select internal to load the OpenLayers library from your drupal installation. -
    You can use the drush command dl-openlayers to download the library and place it at the right place automatically.
  • -
  • Select external to load it from Internet.
  • -
-

You should use the libraries module to enable the internal loading of the library.

- ', array('!libraries' => 'http://drupal.org/project/libraries')), - '#default_value' => variable_get('openlayers_source_type', 'external') - ); - - $form['openlayers_source_external'] = array( - '#type' => 'textfield', - '#title' => t('OpenLayers external source'), - '#description' => $source_description, - '#default_value' => variable_get('openlayers_source_external', OPENLAYERS_DEFAULT_LIBRARY), - '#states' => array( - 'visible' => array( - ':input[name="openlayers_source_type"]' => array('value' => 'external'), - ), - ), - ); - - $library = libraries_info('openlayers'); - $variants = array('original' => 'original') + $library['variants']; - - $form['openlayers_source_internal_variant'] = array( - '#type' => 'radios', - '#options' => array_combine(array_keys($variants), array_map('ucfirst', array_keys($variants))), - '#title' => t('OpenLayers internal source variant'), - '#description' => t('The OpenLayers library (version >= 2.12) has different variants. Select the one you prefer for your installation. Warning: OpenLayers is design to only work for original variants. Hopefully more variants will be supported soon.'), - '#default_value' => variable_get('openlayers_source_internal_variant', 'original'), - '#states' => array( - 'visible' => array( - ':input[name="openlayers_source_type"]' => array('value' => 'internal'), - ), - ), - ); - $form['openlayers_default_map'] = array( '#type' => 'select', - '#title' => t('OpenLayers Default Map'), - '#description' => t('This is the default map that will be used - in cases where one is not defined. It will also be used as - the default when creating new maps.'), - '#options' => openlayers_map_options(), - '#default_value' => variable_get('openlayers_default_map', 'default'), + '#title' => t('OpenLayers maps'), + '#description' => t('This form is just a test, it just shows the AJAX possibility of the module.'), + '#options' => $options, + '#default_value' => 'map_mapquest_openstreetmap', '#ajax' => array( 'callback' => '_ajax_reload_default_map', 'method' => 'replace', @@ -106,98 +44,24 @@ function openlayers_ui_admin_settings() { '#suffix' => '', '#type' => 'openlayers', '#description' => t('This is the map set as default.'), - '#map' => variable_get('openlayers_default_map', 'default') - ); - - $form['openlayers_ui_preview_map'] = array( - '#type' => 'checkbox', - '#title' => t('Preview Map'), - '#description' => t('Turning this on will show you a map preview when editing it through the !link.', - array('!link' => l(t('Map Interface'), 'admin/structure/openlayers/maps'))), - '#default_value' => variable_get('openlayers_ui_preview_map', FALSE), - '#ajax' => array( - 'callback' => '_ajax_reload_default_map', - 'method' => 'replace', - 'wrapper' => 'default_map_ajax', - 'effect' => 'fade' - ), + '#map' => 'map_mapquest_openstreetmap' ); - // A hidden value to reset client check - $form['openlayers_ui_version_check'] = array( - '#type' => 'hidden', - '#value' => '', - ); + // This is for preventing 'system/ajax' as destination when using AJAX maps. + // See: http://drupal.stackexchange.com/questions/86958/get-current-url-arguments-inside-ajax-callback + $form['current_path'] = array('#type' => 'hidden', '#value' => current_path()); // Make a system setting form and return return system_settings_form($form); } -/** - * Ajax callback for the default map element in the form. - * - * @param $form - * @param $form_state - * @return mixed - */ function _ajax_reload_default_map($form, &$form_state) { - $output = $form['default_map']; - $output['#map'] = $form_state['values']['openlayers_default_map']; - return $output; -} - -/** - * Settings form validation - * - * @param $form - * @param $form_state - */ -function openlayers_ui_admin_settings_validate($form, &$form_state) { - if ($form_state['values']['openlayers_source_type'] == 'external') { - $url = $form_state['values']['openlayers_source_external']; - // If protocol neutral, fake a URL that will pass valid_url() and - // url_is_external(). - if (strpos($url, '//') === 0) { - $url = 'http:' . $url; - } - if (!valid_url($url, TRUE) && !url_is_external($url)) { - form_set_error('openlayers_source_external', 'The source must be a valid external URL, beginning with http(s).'); - } - } -} - -/** - * Callback endpoint for sending in OL version from client JS. - */ -function openlayers_ui_version_check($version = 0) { - $version = check_plain($version); - - // Set variable with version for hook_requirements - // and so we dont do this on every page load. - variable_set('openlayers_ui_version_check', $version); - - // Do a basic check - if (strpos($version, (string) OPENLAYERS_SUGGESTED_LIBRARY) !== FALSE) { - $status = 'valid'; - $message = t('Valid library found with a Javascript client check; version: %version', array('%version' => $version)); - } - else { - $status = 'invalid'; - $message = t('Could not find a valid library with a Javascript client-side check; Value found: %version. Please visit the !settings for more details.', - array( - '%version' => $version, - '!settings' => l(t('OpenLayers settings page'), 'admin/structure/openlayers'), - ) - ); - } - - // Kind of a hack, but since we are using messages for this, let's clear the - // messages queue out. - $messages = drupal_get_messages(); - - // We just want to send some markup back. - drupal_json_output(array( - 'status' => $status, - 'response' => $message, - )); + // This is for preventing 'system/ajax' as destination when using AJAX maps. + // See: http://drupal.stackexchange.com/questions/86958/get-current-url-arguments-inside-ajax-callback + $_SESSION['current_path'] = $form_state['input']['current_path']; + $map = openlayers_object_load('map', $form_state['values']['openlayers_default_map']); + $form['default_map']['map'] = array( + '#markup' => openlayers_render_map($map) + ); + return $form['default_map']; } diff --git a/modules/openlayers_ui/includes/openlayers_ui.layers.inc b/modules/openlayers_ui/includes/openlayers_ui.layers.inc deleted file mode 100644 index 5051b16937493c3c5407384ecd00d4c0496ee691..0000000000000000000000000000000000000000 --- a/modules/openlayers_ui/includes/openlayers_ui.layers.inc +++ /dev/null @@ -1,49 +0,0 @@ - $type_def) { - $type = openlayers_layer_type_load($name); - if ($type->settings_form()) { - $form[$name] = array( - '#type' => 'fieldset', - '#tree' => TRUE, - '#title' => $type_def['title'] - ); - $form[$name]['settings'] = $type->settings_form(); - } - } - - $form['submit'] = array( - '#type' => 'submit', - '#value' => t('Save'), - ); - - return $form; -} - -/** - * Submit handler for openlayers_ui_layers_settings -*/ -function openlayers_ui_layers_settings_submit(&$form, &$form_state) { - $layer_types = openlayers_layer_types(); - foreach ($form_state['values'] as $key => $value) { - if (in_array($key, array_keys($layer_types))) { - foreach ($value['settings'] as $k => $v) { - variable_set($k, $v); - } - } - } -} diff --git a/modules/openlayers_ui/includes/openlayers_ui.maps.inc b/modules/openlayers_ui/includes/openlayers_ui.maps.inc deleted file mode 100644 index 0f2f400898cdfbefdf70b4608eff3faf37a3b85d..0000000000000000000000000000000000000000 --- a/modules/openlayers_ui/includes/openlayers_ui.maps.inc +++ /dev/null @@ -1,287 +0,0 @@ - NULL, 'submitted' => FALSE); - $form_build_id = $_POST['form_build_id']; - $form = form_get_cache($form_build_id, $form_state); - - // Get variables - $args = $form['#parameters']; - $form_id = array_shift($args); - $form_state['post'] = $form['#post'] = $_POST; - $form['#programmed'] = $form['#redirect'] = FALSE; - - // Reprocess form with new form state - drupal_process_form($form_id, $form, $form_state); - - // Rebuild form and remove any submit handlers - $form = drupal_rebuild_form($form_id, $form_state, $args, $form_build_id); - - // Unset wrapper and create output - $output = theme('status_messages') . drupal_render($form['layerstyles']); - - // Final rendering callback. - drupal_json(array('status' => TRUE, 'data' => $output)); -} - -/** - * Process form submission into a map array. - * - * @param $values - * Array of values to process. - * @return - * Map data array. - */ -function openlayers_ui_maps_form_process($values = array()) { - // Valid keys that we will cherry-pick from the form values. - $keys = array( - 'width', - 'height', - 'image_path', - 'css_path', - 'proxy_host', - 'hide_empty_map', - 'center', - 'behaviors', - 'layers', - 'layer_weight', - 'layer_styles', - 'layer_styles_select', - 'layer_styles_temporary', - 'layer_activated', - 'layer_switcher', - 'projections', - 'styles' - ); - - // TODO: eliminate this process, too much disconnect between - // forms and data - $processed = array(); - foreach ($keys as $key) { - switch ($key) { - case 'behaviors': - $processed['behaviors'] = array(); - foreach ($values['behaviors'] as $behavior => $settings) { - if ($settings['enabled']) { - $processed['behaviors'][$behavior] = - isset($settings['options_set']['options']) ? - $settings['options_set']['options'] : array(); - } - } - break; - - case 'projections': - $processed['projection'] = $values['layerstyles']['projections']['easy_projection']; - $processed['displayProjection'] = $values['layerstyles']['projections']['displayProjection']; - break; - - case 'layers': - // Put the default layer in the right place. - // TODO: finish port here - $processed['default_layer'] = $values['layerstyles']['layers']['default_layer']; - $baselayers = array_filter($values['layerstyles']['layers']['baselayers']); - $overlays = (isset($values['layerstyles']['layers']['overlays'])) ? - array_filter($values['layerstyles']['layers']['overlays']) : array(); - // Sort overlay layers by weight, in case browser didn't - // send them already sorted - if (isset($values['layerstyles']['layer_weight'])) { - $overlays = array(); - asort($values['layerstyles']['layer_weight']); - foreach (array_keys($values['layerstyles']['layer_weight']) as $layer_key) { - if ($values['layerstyles']['layers']['overlays'][$layer_key]) { - $overlays[$layer_key] = $layer_key; - } - } - // TODO: Above code is terrrrrrrrible. rewrite when I have the time - } - - // Merge our different layer sections together - $processed['layers'] = array_merge($baselayers, $overlays); - break; - - case 'layer_weight': - case 'layer_styles': - case 'layer_styles_select': - case 'layer_styles_temporary': - case 'layer_activated': - case 'layer_switcher': - case 'projections': - case 'styles': - $processed[$key] = isset($values['layerstyles'][$key]) ? $values['layerstyles'][$key] : array(); - break; - - default: - // $processed[$key] = is_array($values[$key]) ? - // array_filter($values[$key]) : $values[$key]; - $processed[$key] = isset($values[$key]) ? $values[$key] : array(); - break; - } - } - - // Ensure these values are arrays - $ensure_array = array('behaviors', 'layers', 'layer_weight', 'layer_styles', 'layer_styles_select', 'layer_styles_temporary', 'styles'); - foreach ($ensure_array as $key) { - if (empty($processed[$key])) { - $processed[$key] = array(); - } - } - - return $processed; -} - -/** - * Get behavior options. - */ -function openlayers_ui_get_behavior_options($type, $defaults) { - $form = array(); - $behaviors = openlayers_behaviors(); - $enabled_behaviors = array(); - - foreach ($defaults['behaviors'] as $key => $options) { - $enabled_behaviors[$key] = $behaviors[$key]; - unset($behaviors[$key]); - } - - // Ordering behaviors - // First display the enabled, then the disabled. - uasort($enabled_behaviors, '_openlayers_ui_sort_behaviors'); - uasort($behaviors, '_openlayers_ui_sort_behaviors'); - - $behaviors = array_merge($enabled_behaviors, $behaviors); - - foreach ($behaviors as $key => $plugin) { - - // Get behavior class - $class = ctools_plugin_load_class( - 'openlayers', - 'behaviors', - $key, - 'behavior'); - if (!empty($class)) { - $options = isset($defaults['behaviors'][$key]) ? - $defaults['behaviors'][$key] : array(); - - $behavior = new $class($options, $defaults); - - if (!isset($plugin['ui_visibility']) || $plugin['ui_visibility']) { - // Create basic form structure for behavior - $form[$key] = array( - '#type' => 'fieldset', - '#title' => $plugin['title'], - '#collapsible' => TRUE, - '#collapsed' => isset($defaults['behaviors'][$key]) ? FALSE : TRUE, - 'enabled' => array( - '#type' => 'checkbox', - '#title' => $plugin['title'], - '#description' => $plugin['description'], - '#default_value' => isset($defaults['behaviors'][$key]), - ) - ); - - // Create options items - $options = $behavior->options_form($options); - if (!empty($options)) { - $form[$key]['options_set'] = array( - '#type' => 'fieldset', - '#title' => t('Options'), - '#collapsible' => FALSE, - '#collapsed' => FALSE, - '#states' => array( - 'visible' => array( - ':input[name="behaviors['.$key.'][enabled]"]' => array('checked' => TRUE), - ), - ), - 'options' => $options - ); - } - } - } - } - return $form; -} - -/** - * Callback sorting behaviors alphabetically - */ -function _openlayers_ui_sort_behaviors($a, $b) { - return strnatcmp($a['title'], $b['title']); -} - -/** - * Create Centering Map - * - * Create map for interactive default centering - * - * @param $defaults - * Array of defults to use for the map of centering and zooming - * @return - * Themed map array - */ -function openlayers_ui_maps_form_center_map($defaults = array()) { - // Pass variables etc. to javascript - $pass_values = array( - 'openlayersForm' => array( - 'projectionLayers' => openlayers_ui_get_projection_options(), - ), - ); - drupal_add_js($pass_values, 'setting'); - - $projection = openlayers_get_projection('EPSG', '3857'); - openlayers_add_js_projection_definition($projection); - - // centerpoint & zoom of this map are overridden - // by the mapformvalues behavior on page load. - // - // Note that navigation screws up the boxselect - // behavior for getting extent. - $centermap_def = array( - 'id' => 'openlayers-center-helpmap', - 'projection' => $projection->identifier, - 'displayProjection' => $projection->identifier, - 'default_layer' => 'mapquest_osm', - 'width' => '600px', - 'height' => '400px', - 'center' => array( - 'initial' => array( - 'centerpoint' => "0, 0", - 'zoom' => 2, - ), - ), - 'image_path' => drupal_get_path('module', 'openlayers') . '/themes/default_dark/img/', - 'layers' => array( - 'mapquest_osm', - ), - 'behaviors' => array( - 'openlayers_behavior_navigation' => array(), - 'openlayers_behavior_panzoombar' => array(), - 'openlayers_behavior_dragpan' => array(), - 'openlayers_behavior_mapformvalues' => array(), - 'openlayers_behavior_boxselect' => array(), - 'openlayers_behavior_attribution' => array(), - ), - ); - return openlayers_render_map_data($centermap_def); -} diff --git a/modules/openlayers_ui/includes/openlayers_ui.theme.inc b/modules/openlayers_ui/includes/openlayers_ui.theme.inc deleted file mode 100644 index 2d2a542442109430d02043039ed130ded8d88fa7..0000000000000000000000000000000000000000 --- a/modules/openlayers_ui/includes/openlayers_ui.theme.inc +++ /dev/null @@ -1,96 +0,0 @@ - drupal_get_destination())); - } - return $args['layer_title'] . ($args['layer_description'] ? - ' ' . - $args['layer_description'] . '' : - ''); -} - -/** - * Theme function for form description of projection - */ -function theme_openlayers_ui_form_projection_description($args) { - $output = $args['projection']->getLocalizedMessage(); - if (count($args['available_layers'])) { - $names = implode(', ', $args['available_layers']); - $output .= " - $names"; - } - return $output; -} - -function theme_openlayers_ui_maps_form_layers($args) { - $form = $args['elements']; - - $output = drupal_render($form['projections']) - . drupal_render($form['help_data_overlays']); - - // Base layers - $rows = array(); - foreach (element_children($form['layers']['baselabels']) as $key) { - unset($form['layers']['default_layer'][$key]['#title']); - unset($form['layers']['baselayers'][$key]['#title']); - - $rows[] = array( - drupal_render($form['layers']['baselabels'][$key]), - drupal_render($form['layers']['baselayers'][$key]), - drupal_render($form['layers']['default_layer'][$key])); - } - $output_layer_list = theme('table', array( - 'header' => array(t('Base layers'), t('Enabled'), t('Default')), - 'rows' => $rows) - ); - - // Overlay layers - $rows = array(); - foreach (element_children($form['layers']['overlaylabels']) as $key) { - unset($form['overlays'][$key]['#title']); - unset($form['layers']['overlays'][$key]['#title']); - unset($form['layer_activated'][$key]['#title']); - unset($form['layer_switcher'][$key]['#title']); - - $rows[] = array( - 'data' => array( - drupal_render($form['layers']['overlaylabels'][$key]), - drupal_render($form['layer_weight'][$key]), - drupal_render($form['layers']['overlays'][$key]), - drupal_render($form['layer_activated'][$key]), - drupal_render($form['layer_switcher'][$key]), - drupal_render($form['layer_styles'][$key]), - drupal_render($form['layer_styles_select'][$key]), - drupal_render($form['layer_styles_temporary'][$key]), - ), - 'class' => array('draggable') - ); - } - $output_layer_list .= theme('table', - array( - 'header' => array( - t('Overlay layers'), t('Weight'), t('Enabled'), - t('Activated'), t('In Switcher'), t('Style'), t('Select Style'), - ('Temporary Style') - ), - 'rows' => $rows, - array('id' => 'overlay-layer-table') - ) - ); - $form['layers']['layerlist']['#markup'] = $output_layer_list; - $output .= drupal_render($form['layers']); - - drupal_add_tabledrag('overlay-layer-table', 'order', 'sibling', - 'layer-weight'); - return $form['#prefix'] . $output . drupal_render_children($form) . $form['#suffix']; -} diff --git a/modules/openlayers_ui/js/openlayers_ui.admin.js b/modules/openlayers_ui/js/openlayers_ui.admin.js deleted file mode 100644 index 4f4f8272b489d2afd13d27cebab897a33a252b4c..0000000000000000000000000000000000000000 --- a/modules/openlayers_ui/js/openlayers_ui.admin.js +++ /dev/null @@ -1,53 +0,0 @@ -/** - * @file - * Javascript for OL UI Admin - * - * @ingroup openlayers - */ - -// Namespace jQuery -(function ($) { - -/** - * Drupal behaviors for OpenLayers UI form. - */ -Drupal.behaviors.openlayers_ui_admin = { - 'attach': function(context, settings) { - $('.openlayers-ui-version-check-message').once('openlayers-ui-version-check-message', function() { - // Determine version - var version = '0'; - var $thisContainer = $(this); - - if (typeof OpenLayers != 'undefined' && OpenLayers.hasOwnProperty('VERSION_NUMBER')) { - version = OpenLayers.VERSION_NUMBER; - } - - // Mark as loading, then do AJAX request - $thisContainer.addClass('throbbing'); - var url = settings.basePath + '?q=admin/structure/openlayers/callbacks/version_check/' + version; - $.ajax({ - url: url, - success: function(data) { - $thisContainer.removeClass('throbbing'); - $thisContainer.html(data.response); - if (data.status == 'valid') { - $thisContainer.parent() - .removeClass('warning') - .addClass('status'); - } - else { - $thisContainer.parent() - .removeClass('status') - .addClass('warning'); - } - }, - error: function(data) { - $thisContainer.removeClass('throbbing'); - $thisContainer.html(Drupal.t('Error making request to server.')); - } - }); - }); - } -}; - -})(jQuery); diff --git a/modules/openlayers_ui/js/openlayers_ui.maps.js b/modules/openlayers_ui/js/openlayers_ui.maps.js deleted file mode 100644 index 893f57edf0993166319c4d5ce8f7b349d871fbf1..0000000000000000000000000000000000000000 --- a/modules/openlayers_ui/js/openlayers_ui.maps.js +++ /dev/null @@ -1,75 +0,0 @@ - -/** - * @file - * This file holds the javascript functions for the map UI - * - * @ingroup openlayers - */ - -/** - * Test whether function exists, - * even if it is the child of another object - * @param head the function name as a string, - * optionally with dots for invoking children - * @return bool true or false for existence - */ -function function_exists(head) { - return _function_exists(head.split('.'), window); -} - -function _function_exists(head, f) { - if (head.length == 0) { - return true; - } - h = head.shift(); - if (typeof f[h] !== 'undefined') { - return _function_exists(head, f[h]); - } - else { - return false; - } -} - -(function ($) { -/** - * Drupal behaviors for OpenLayers UI form. - */ -Drupal.behaviors.openlayers_ui = { - 'attach': function(context, settings) { - - // mark openlayers dependencies as valid or invalid - $('.openlayers-dependency-flag').each(function() { - if (!function_exists($(this).find('.openlayers-dependency-value').text())) { - $(this).find('.openlayers-dependency-broken').show(); - } - }); - - // Since CTools dependency is not working - $('#edit-behaviors:not(.openlayers-behaviors-checks-processed)').each(function () { - $('#edit-behaviors').addClass('openlayers-behaviors-checks-processed'); - $('#edit-behaviors table tbody tr td > div.form-type-checkbox').each(function () { - var $thisBehavior = $(this); - var $thisCheck = $('input[type=checkbox]', $thisBehavior); - - if ($thisCheck.attr('checked')) { - $thisBehavior.siblings().show(); - } - else { - $thisBehavior.siblings().hide(); - } - - $thisCheck.click(function() { - if ($thisCheck.attr('checked')) { - $thisBehavior.siblings().show(); - } - else { - $thisBehavior.siblings().hide(); - } - }); - - }); - }); - } -}; - -})(jQuery); diff --git a/modules/openlayers_ui/js/openlayers_ui.styles.js b/modules/openlayers_ui/js/openlayers_ui.styles.js deleted file mode 100644 index 3fce3d079a715194401d576de91c654ba12cc93f..0000000000000000000000000000000000000000 --- a/modules/openlayers_ui/js/openlayers_ui.styles.js +++ /dev/null @@ -1,58 +0,0 @@ -/** - * @file - * Javascript for OL Styles UI. - * - * @ingroup openlayers - */ - -// Namespace jQuery -(function ($) { - -/** - * Drupal behaviors for OpenLayers UI form. - */ -Drupal.behaviors.openlayers_ui_styles = { - 'attach': function(context, settings) { - var maps = {}; - - // Go through each preview - $('.openlayers-ui-style-preview:not(.openlayers-ui-style-preview-processed)').each(function() { - $thisPreview = $(this); - $thisPreview.addClass('openlayers-ui-style-preview-processed'); - var id = $thisPreview.attr('id'); - var style = Drupal.settings.openlayers_ui.style_preview[id].data; - - // We want to create a very simple map with a style on - // top. There's no need to use the Drupal API for this as we - // want to keep it lean. - maps[id] = new OpenLayers.Map(id, { controls: [] }); - var mapquest = new OpenLayers.Layer.OSM(Drupal.t('MapQuest-OSM Tiles'), - [(location.protocol === 'https:' ? '//otile1-s' : '//otile1') + '.mqcdn.com/tiles/1.0.0/osm/${z}/${x}/${y}.png']); - maps[id].addLayer(mapquest); - var point = new OpenLayers.LonLat(Math.random() * 175, Math.random() * 80).transform( - new OpenLayers.Projection("EPSG:4326"), maps[id].getProjectionObject() - ); - maps[id].setCenter(point, (Math.floor(Math.random() * 4) + 1)); - - // Now add a point with the preview style. - var feature = new OpenLayers.Feature.Vector( - new OpenLayers.Geometry.Point(point.lon, point.lat)); - var vector = new OpenLayers.Layer.Vector(Drupal.t('Preview'), { - styleMap: new OpenLayers.StyleMap(style) - }); - vector.addFeatures([ feature ]); - maps[id].addLayer(vector); - - // And finally, lets add a little crosshair so that - // the user can see how the style is centered. If it is - // enabled; - if (Drupal.settings.openlayers_ui.style_preview[id + '_crosshairs']) { - $thisPreview.find('.olMapViewport') - .append('
') - .append('
'); - } - }); - } -}; - -})(jQuery); diff --git a/modules/openlayers_ui/openlayers_ui.css b/modules/openlayers_ui/openlayers_ui.css deleted file mode 100644 index 6b1439b7224850155547593710d52b6ff9ee64ab..0000000000000000000000000000000000000000 --- a/modules/openlayers_ui/openlayers_ui.css +++ /dev/null @@ -1,120 +0,0 @@ - -/** - * @file - * OpenLayers Admin CSS - * - * This file holds CSS for the openlayers ui module - * - * @ingroup openlayers - */ - -/** - * Map Form - */ -.openlayers-form-projection-description, -.openlayers-form-layer-description { - font-size: smaller; - font-style: italic; -} - -#openlayers-form-proj-msg { - display: none; -} - -span.openlayers-dependency-value { - display: none; -} - -span.openlayers-dependency-broken { - font-size: smaller; - display: none; - color: red; -} - -/** - * Overriding for vertical tabs - */ -div.vertical-tabs fieldset { - border: 1px solid #CCCCCC; - margin: 1em 0; - padding: 2.5em 0 0; - position: relative; -} - -div.vertical-tabs .vertical-tabs-panes legend { - display: block; -} - -div.vertical-tabs .vertical-tabs-panes > fieldset { - border: 0 none; - margin: 0; - padding: 0; -} - -div.vertical-tabs .vertical-tabs-panes > fieldset > legend { - display: none; -} - -/** - * Behaviors table - */ -div.vertical-tabs table tbody tr fieldset { - font-size: .85em; - margin-left: 20px; - margin-right: 20px; - padding: 10px; - background-color: #EEEEEE; - position: inherit; -} - -div.vertical-tabs table tbody tr.odd .form-item, -div.vertical-tabs table tbody tr.even .form-item { - white-space: normal; -} - -/** - * Style previews - */ -.openlayers-ui-style-preview { - width: 60px; - height: 60px; - background-color: #DDDDDD; - border: 1px solid #222222; -} - -#openlayers-ui-styles-form .openlayers-ui-style-preview { - width: 200px; - height: 200px; -} - -#openlayers-ui-styles-form #edit-preview-style-container { - float: right; - width: 210px; - margin: 0 0 10px 10px; -} - -.openlayers-ui-style-preview .openlayers-ui-style-preview-top, -.openlayers-ui-style-preview .openlayers-ui-style-preview-left { - position: absolute; - z-index: 999999; -} - -.openlayers-ui-style-preview .openlayers-ui-style-preview-top { - top: 0; - right: 0; - left: 0; - width: 100%; - height: 50%; - border-bottom: 1px solid rgb(33, 33, 33); - border-bottom: 1px solid rgba(33, 33, 33, .2); - -} -.openlayers-ui-style-preview .openlayers-ui-style-preview-left { - top: 0; - right: 0; - left: 0; - width: 50%; - height: 100%; - border-right: 1px solid rgb(33, 33, 33); - border-right: 1px solid rgba(33, 33, 33, .2); -} \ No newline at end of file diff --git a/modules/openlayers_ui/openlayers_ui.install b/modules/openlayers_ui/openlayers_ui.install index 719c62037970657f65fae1affb90c181f0e9e210..b3d9bbc7f3711e882119cd6b3af051245d859d04 100644 --- a/modules/openlayers_ui/openlayers_ui.install +++ b/modules/openlayers_ui/openlayers_ui.install @@ -1,34 +1 @@ condition('link_path', 'admin/structure/openlayers%', 'LIKE') - ->execute(); -} diff --git a/modules/openlayers_ui/openlayers_ui.module b/modules/openlayers_ui/openlayers_ui.module index 2a80755e0c9159ad03786095b9c660589f9d5d85..f5259766ae86dc2a84e581213ea2f9a74bef2c0f 100644 --- a/modules/openlayers_ui/openlayers_ui.module +++ b/modules/openlayers_ui/openlayers_ui.module @@ -1,111 +1,4 @@ !title !message', array( - '!title' => $r['value'], - '!message' => isset($r['description']) ? $r['description'] : '', - )), $severity); - } - } - - // We also want to do some nice AJAX magic to get the library - // version to the system. - $check = variable_get('openlayers_ui_version_check', ''); - if (empty($check)) { - // Load AJAX libraries - drupal_add_library('system', 'drupal.ajax'); - drupal_add_library('system', 'jquery.form'); - // Ensure that the library is included - openlayers_include(); - // Add custom client JS - drupal_add_js(drupal_get_path('module', 'openlayers_ui') . '/js/openlayers_ui.admin.js'); - // We shouldn't, but we are just gonna put a message up there - // to get replaced. - drupal_set_message('
' . - t('Checking client library via Javascript...') . '
', 'none'); - } - } -} - -/** - * Implements hook_help - */ -function openlayers_ui_help($path, $arg) { - switch ($path) { - case 'admin/help#openlayers_ui': - return '

' . t('Provides a user interface to manage OpenLayers maps.') . '

'; - case 'admin/structure/openlayers': - return '

' . t('Configure where Drupal finds - the OpenLayers javascript library. Using a local or compacted - version of OpenLayers can reduce filesize, but remember to set the Image Path and - CSS Path options in every map, because OpenLayers is not able to find these resources - automatically. See the included documentation in /doc for - more details.', - array('@olb' => 'http://trac.openlayers.org/wiki/Profiles')) . '

'; - case 'admin/structure/openlayers/styles': - return '

' . t('OpenLayer styles are stored versions of - javascript StyleMap objects, but are much easier to - configure through an interface. Styles will typically define the icon, - fill color, border, and radius of points or polygons, so they are used - on overlays more often than base layers, which are not affected by vector - styles.', array("@ols" => 'http://trac.openlayers.org/wiki/Styles')) . '

'; - case 'admin/structure/openlayers/styles/add': - return '

' . t('The name, title, and description you give a style is for Drupal\'s - interal storage. The rest of the properties are documented on openlayers.org') - . '

'; - case 'admin/structure/openlayers/maps': - return '

' . t('Maps are combinations of the layers, styles, and behaviors - which constitute maps. They also contain basic configuration like the - width and centerpoint of the map - everything except for a mechanism - to put a map on a page. For that, use the Views OpenLayers Map style.') . '

'; - case 'admin/structure/openlayers/layers': - return '

' . t('Layers are stored versions of javascript OpenLayers layer - objects. They point at a data source, like OpenStreetMap, Google Maps, - or Drupal itself, and sometimes define the zoom levels for which they apply.') . '

'; - case 'admin/structure/openlayers/projections': - return t('

Projections describe how the earth is flattened to a map image. They define coordinate systems for data retrieval.

'); - case 'admin/structure/openlayers/layers/settings': - return '

' . t('Commercial layer providers like Google will require API keys - to ensure that users are\'t abusing the service and to enforce limits. Not all - of these keys are required, of course, only those that are used on a site.') . '

'; - - } -} - -/** - * Implements hook_permission(). - */ -function openlayers_ui_permission() { - return array( - 'administer openlayers' => array( - 'title' => t('Administer OpenLayers'), - 'description' => t('Configure OpenLayers settings, styles, maps, and layers.'), - ), - ); -} /** * Implements hook_menu @@ -116,7 +9,7 @@ function openlayers_ui_menu() { // Core OpenLayers settings pages. $items['admin/structure/openlayers'] = array( 'title' => 'OpenLayers', - 'description' => 'Manage maps, layers, styles, and map behaviors.', + 'description' => 'Manage maps, layers, sources, controls, styles, and interactions.', 'page callback' => 'drupal_get_form', 'page arguments' => array('openlayers_ui_admin_settings'), 'access arguments' => array('administer openlayers'), @@ -129,215 +22,14 @@ function openlayers_ui_menu() { 'weight' => -20, ); - // Layer-type-wide settings form - $items['admin/structure/openlayers/layers/settings'] = array( - 'title' => 'API Keys', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('openlayers_ui_layers_settings'), - 'access arguments' => array('administer openlayers'), - 'file' => 'includes/openlayers_ui.layers.inc', - 'type' => MENU_LOCAL_TASK, - 'weight' => -10, - ); - - $items['admin/structure/openlayers/callbacks/version_check/%'] = array( - 'title' => 'OpenLayers Version Check', - 'page callback' => 'openlayers_ui_version_check', - 'page arguments' => array(5), - 'access arguments' => array('administer openlayers'), - 'file' => 'includes/openlayers_ui.admin.inc', - 'type' => MENU_CALLBACK, - ); - - return $items; -} - -/** - * Implements hook_theme(). - */ -function openlayers_ui_theme($existing, $type, $theme, $path) { - return array( - 'openlayers_ui_form_layer_description' => array( - 'variables' => array( - 'layer_title' => '', - 'layer_description' => '', - ), - 'file' => 'includes/openlayers_ui.theme.inc', - ), - 'openlayers_ui_form_projection_description' => array( - 'variables' => array( - 'projection' => '', - 'available_layers' => array(), - 'layers' => array(), - ), - 'file' => 'includes/openlayers_ui.theme.inc', - ), - 'openlayers_ui_maps_form' => array( - 'render element' => 'elements', - 'file' => 'includes/openlayers_ui.theme.inc', - ), - 'openlayers_ui_maps_form_layers' => array( - 'render element' => 'elements', - 'file' => 'includes/openlayers_ui.theme.inc', - ), - 'openlayers_ui_maps_form_behaviors' => array( - 'render element' => 'elements', - 'file' => 'includes/openlayers_ui.theme.inc', - ), - 'openlayers_ui_styles_preview' => array( - 'arguments' => array( - 'style' => NULL, - ), - 'template' => 'openlayers-ui-styles-preview', - 'path' => drupal_get_path('module', 'openlayers_ui') . '/themes', - ), - ); -} - -/** - * Get projection options. - * - * @return - * Array of projection options suitable for use in a FormAPI element. - */ -function openlayers_ui_get_projection_options() { - $options = array(); - foreach (openlayers_layers_load() as $key => $layer) { - foreach ($layer->getProjections() as $projection) { - $options[$projection->identifier] = $projection; - } - } - return $options; -} - -/** - * Get layer options. - * @param String $type - * @param openlayers_projection $projection - */ -function openlayers_ui_get_layer_options($type = 'baselayer', - $projection = NULL) { - $options = array(); - $layers = array(); - - // Get layers in an array - foreach (openlayers_layers_load() as $l) { - $layers[$l->name] = openlayers_get_layer_object($l); - } - - // Go through layers to theme output. - foreach ($layers as $key => $layer) { - if (!is_object($layer)) { - // Failure was already logged in openlayers_get_layer_object - continue; - } - - // not filtering by projection - // this layer has an appropriate projection - // this layer can be reprojected because it is vector - $variables = array(); - if ( - !isset($projection) || - in_array($projection, $layer->getProjections()) || - !empty($layer->data['vector']) - ) { - if (!array_key_exists('isBaseLayer', $layer->data)) { - throw new Exception("Layer definition $key lacks isBaseLayer attribute"); - } - - if ($layer->data['isBaseLayer'] == TRUE && $type == 'baselayer') { - $variables = array( - 'layer_title' => $layer->title, - 'layer_description' => $layer->description, - 'layer_link' => 'admin/structure/openlayers/layers/list/' . $layer->name . '/edit' - ); - } - - if ($layer->data['isBaseLayer'] == FALSE && $type == 'overlay') { - $variables = array( - 'layer_title' => $layer->title, - 'layer_description' => $layer->description, - 'layer_link' => 'admin/structure/openlayers/layers/list/' . $layer->name . '/edit' - ); - - if ($layer->data['layer_type'] == 'openlayers_views_vector') { - $variables['layer_link'] = 'admin/structure/views/view/' . $layer->data['views']['view'] . '/edit/' . $layer->data['views']['display']; - } - } - } - if (!empty($variables)) { - $options[$key] = theme('openlayers_ui_form_layer_description', $variables); - } - } - return $options; -} - -/** - * Get style options. - * - * @return - * Array of style options suitable for use in a FormAPI element. - */ -function openlayers_ui_get_style_options() { - $options = array(); - foreach (openlayers_styles() as $key => $style) { - $options[$key] = $style->title; - } - return $options; -} - -/** - * dependencies widget helper - * @param $dependencies - * Array of Javascript dependencies as strings of function names - * @return $form - * Form element of dependencies if any - */ -function openlayers_dependency_widget($dependencies) { - if (is_array($dependencies) > 0) { - $dependency_form = array(); - foreach ($dependencies as $dependency) { - $dependency_form[] = array( - '#markup' => "
" - . "$dependency" - . "" - . t('Dependency not found:') . ' ' . $dependency . "" - . "
" - ); - } - return $dependency_form; - } -} - -/** - * Create Style Preview - * - * Create a style preview given style object. - */ -function openlayers_ui_style_preview($style, $crosshairs = FALSE) { - drupal_add_js(drupal_get_path('module', 'openlayers_ui') . '/js/openlayers_ui.styles.js'); - drupal_add_css(drupal_get_path('module', 'openlayers_ui') . '/openlayers_ui.css'); - module_load_include('inc', 'openlayers', 'includes/openlayers.render'); - openlayers_include(); - - // Let's make a tiny map for a preview - drupal_add_js(array('openlayers_ui' => - array( - 'style_preview' => array( - $style->name => $style, - $style->name . '_crosshairs' => $crosshairs, - ), - ), - ), 'setting'); - - return theme('openlayers_ui_styles_preview', array('style' => $style)); + return $items; } /** * Implements hook_ctools_plugin_directory(). */ -function openlayers_ui_ctools_plugin_directory($module, $plugin) { - if ($module == 'ctools' && $plugin == 'export_ui') { - return 'plugins/' . $plugin; +function openlayers_ui_ctools_plugin_directory($module, $type) { + if ($type == 'export_ui') { + return 'plugins/export_ui'; } } diff --git a/modules/openlayers_ui/plugins/export_ui/openlayers_controls.inc b/modules/openlayers_ui/plugins/export_ui/openlayers_controls.inc new file mode 100644 index 0000000000000000000000000000000000000000..c3f1e20e37a7c44ffe28149204f822bca132939d --- /dev/null +++ b/modules/openlayers_ui/plugins/export_ui/openlayers_controls.inc @@ -0,0 +1,115 @@ + 'openlayers_controls', + 'access' => 'administer openlayers', + 'menu' => array( + 'menu prefix' => 'admin/structure/openlayers', + 'menu item' => 'controls', + 'menu title' => 'Controls', + 'menu description' => 'Administer OpenLayers controls.', + ), + + 'handler' => array( + 'class' => 'openlayers_controls_ui', + 'parent' => 'ctools_export_ui' + ), + + 'export' => array( + 'admin_title' => 'name', + 'admin_description' => 'description', + ), + + 'use wizard' => TRUE, + 'form info' => array( + 'order' => array( + 'start' => t('Administrative settings'), + 'second' => t('Control type'), + 'third' => t('Control type options'), + ), + 'forms' => array( + 'start' => array( + 'form id' => 'openlayers_control_form_start' + ), + 'second' => array( + 'form id' => 'openlayers_control_form_second' + ), + 'third' => array( + 'form id' => 'openlayers_control_form_third' + ), + ) + ), + + 'title singular' => t('control'), + 'title plural' => t('controls'), + 'title singular proper' => t('OpenLayers control preset'), + 'title plural proper' => t('OpenLayers control presets'), + + 'strings' => array( + 'confirmation' => array( + 'add' => array( + 'success' => t('Control saved.'), + ), + 'delete' => array( + 'success' => t('Control was deleted.'), + ) + ) + ), + ); +} + +function openlayers_control_form_start($form, &$form_state) { + $class = new ctools_export_ui(); + $class->init($form_state['plugin']); + $class->edit_form($form, $form_state); + return $form; +} + +function openlayers_control_form_start_validate($form, &$form_state) { + $class = new ctools_export_ui(); + $class->init($form_state['plugin']); + $class->edit_form_validate($form, $form_state); +} + +function openlayers_control_form_start_submit($form, &$form_state) { + $class = new ctools_export_ui(); + $class->init($form_state['plugin']); + $class->edit_form_submit($form, $form_state); +} + +function openlayers_control_form_second($form, &$form_state) { + $layers = ctools_get_plugins('openlayers', 'control'); + $options = array('' => t('')); + foreach ($layers as $class => $plugin) { + $options[$class] = $class; + } + + $form['class'] = array( + '#type' => 'select', + '#title' => t('Control Type'), + '#default_value' => isset($form_state['item']->class) ? $form_state['item']->class: '', + '#description' => t('Select the type of control.'), + '#options' => $options, + '#required' => TRUE + ); + + return $form; +} +function openlayers_control_form_second_submit($form, &$form_state) { + $form_state['item']->class = $form_state['values']['class']; +} + +function openlayers_control_form_third($form, &$form_state) { + $control = openlayer_object_factory_create('control', $form_state['item']->class, $form_state['item']); + $form['options'] = $control->options_form(); + $form['options']['#tree'] = TRUE; + + return $form; +} +function openlayers_control_form_third_submit($form, &$form_state) { + $form_state['item']->options = array_replace_recursive($form_state['item']->options, $form_state['values']['options']); +} diff --git a/modules/openlayers_ui/plugins/export_ui/openlayers_controls_ui.class.php b/modules/openlayers_ui/plugins/export_ui/openlayers_controls_ui.class.php new file mode 100644 index 0000000000000000000000000000000000000000..3c8a7e1cc8de4e26db71a894afce764754393528 --- /dev/null +++ b/modules/openlayers_ui/plugins/export_ui/openlayers_controls_ui.class.php @@ -0,0 +1,92 @@ +plugin['export']['admin_title'])) { + $header[] = array('data' => t('Name'), 'class' => array('ctools-export-ui-title')); + } + + $header[] = array('data' => t('Machine name'), 'class' => array('ctools-export-ui-name')); + $header[] = array('data' => t('Class'), 'class' => array('ctools-export-ui-class')); + $header[] = array('data' => t('Storage'), 'class' => array('ctools-export-ui-storage')); + $header[] = array('data' => t('Operations'), 'class' => array('ctools-export-ui-operations')); + + return $header; + } + + /** + * Build a row based on the item. + * + * By default all of the rows are placed into a table by the render + * method, so this is building up a row suitable for theme('table'). + * This doesn't have to be true if you override both. + */ + function list_build_row($item, &$form_state, $operations) { + // Set up sorting + $name = $item->{$this->plugin['export']['key']}; + $schema = ctools_export_get_schema($this->plugin['schema']); + + // Note: $item->{$schema['export']['export type string']} should have already been set up by export.inc so + // we can use it safely. + switch ($form_state['values']['order']) { + case 'disabled': + $this->sorts[$name] = empty($item->disabled) . $name; + break; + case 'title': + $this->sorts[$name] = $item->{$this->plugin['export']['admin_title']}; + break; + case 'name': + $this->sorts[$name] = $name; + break; + case 'class': + $this->sorts[$name] = $name; + break; + case 'storage': + $this->sorts[$name] = $item->{$schema['export']['export type string']} . $name; + break; + } + + $this->rows[$name]['data'] = array(); + $this->rows[$name]['class'] = !empty($item->disabled) ? array('ctools-export-ui-disabled') : array('ctools-export-ui-enabled'); + + // If we have an admin title, make it the first row. + if (!empty($this->plugin['export']['admin_title'])) { + $this->rows[$name]['data'][] = array('data' => check_plain($item->{$this->plugin['export']['admin_title']}), 'class' => array('ctools-export-ui-title')); + } + $this->rows[$name]['data'][] = array('data' => check_plain($name), 'class' => array('ctools-export-ui-name')); + $this->rows[$name]['data'][] = array('data' => check_plain($item->class), 'class' => array('ctools-export-ui-class')); + $this->rows[$name]['data'][] = array('data' => check_plain($item->{$schema['export']['export type string']}), 'class' => array('ctools-export-ui-storage')); + + $ops = theme('links__ctools_dropbutton', array('links' => $operations, 'attributes' => array('class' => array('links', 'inline')))); + + $this->rows[$name]['data'][] = array('data' => $ops, 'class' => array('ctools-export-ui-operations')); + + // Add an automatic mouseover of the description if one exists. + if (!empty($this->plugin['export']['admin_description'])) { + $this->rows[$name]['title'] = $item->{$this->plugin['export']['admin_description']}; + } + } + + + +} diff --git a/modules/openlayers_ui/plugins/export_ui/openlayers_interactions.inc b/modules/openlayers_ui/plugins/export_ui/openlayers_interactions.inc new file mode 100644 index 0000000000000000000000000000000000000000..3981fb6f02ee9fc766412b8800a5a7c85b9abb83 --- /dev/null +++ b/modules/openlayers_ui/plugins/export_ui/openlayers_interactions.inc @@ -0,0 +1,115 @@ + 'openlayers_interactions', + 'access' => 'administer openlayers', + 'menu' => array( + 'menu prefix' => 'admin/structure/openlayers', + 'menu item' => 'interactions', + 'menu title' => 'Interactions', + 'menu description' => 'Administer OpenLayers interactions.', + ), + + 'handler' => array( + 'class' => 'openlayers_interactions_ui', + 'parent' => 'ctools_export_ui' + ), + + 'export' => array( + 'admin_title' => 'name', + 'admin_description' => 'description', + ), + + 'use wizard' => TRUE, + 'form info' => array( + 'order' => array( + 'start' => t('Administrative settings'), + 'second' => t('Interaction type'), + 'third' => t('Interaction type options'), + ), + 'forms' => array( + 'start' => array( + 'form id' => 'openlayers_interaction_form_start' + ), + 'second' => array( + 'form id' => 'openlayers_interaction_form_second' + ), + 'third' => array( + 'form id' => 'openlayers_interaction_form_third' + ), + ) + ), + + 'title singular' => t('interaction'), + 'title plural' => t('interactions'), + 'title singular proper' => t('OpenLayers interaction preset'), + 'title plural proper' => t('OpenLayers interaction presets'), + + 'strings' => array( + 'confirmation' => array( + 'add' => array( + 'success' => t('Interaction saved.'), + ), + 'delete' => array( + 'success' => t('Interaction was deleted.'), + ) + ) + ), + ); +} + +function openlayers_interaction_form_start($form, &$form_state) { + $class = new ctools_export_ui(); + $class->init($form_state['plugin']); + $class->edit_form($form, $form_state); + return $form; +} + +function openlayers_interaction_form_start_validate($form, &$form_state) { + $class = new ctools_export_ui(); + $class->init($form_state['plugin']); + $class->edit_form_validate($form, $form_state); +} + +function openlayers_interaction_form_start_submit($form, &$form_state) { + $class = new ctools_export_ui(); + $class->init($form_state['plugin']); + $class->edit_form_submit($form, $form_state); +} + +function openlayers_interaction_form_second($form, &$form_state) { + $layers = ctools_get_plugins('openlayers', 'interaction'); + $options = array('' => t('')); + foreach ($layers as $class => $plugin) { + $options[$class] = $class; + } + + $form['class'] = array( + '#type' => 'select', + '#title' => t('Interaction Type'), + '#default_value' => isset($form_state['item']->class) ? $form_state['item']->class: '', + '#description' => t('Select the type of interaction.'), + '#options' => $options, + '#required' => TRUE + ); + + return $form; +} +function openlayers_interaction_form_second_submit($form, &$form_state) { + $form_state['item']->class = $form_state['values']['class']; +} + +function openlayers_interaction_form_third($form, &$form_state) { + $interaction = openlayer_object_factory_create('interaction', $form_state['item']->class, $form_state['item']); + $form['options'] = $interaction->options_form(); + $form['options']['#tree'] = TRUE; + + return $form; +} +function openlayers_interaction_form_third_submit($form, &$form_state) { + $form_state['item']->options = array_replace_recursive((array) $form_state['item']->options, $form_state['values']['options']); +} diff --git a/modules/openlayers_ui/plugins/export_ui/openlayers_interactions_ui.class.php b/modules/openlayers_ui/plugins/export_ui/openlayers_interactions_ui.class.php new file mode 100644 index 0000000000000000000000000000000000000000..6259b83a313f082c8b79d48b0cbdfc6604ce4c24 --- /dev/null +++ b/modules/openlayers_ui/plugins/export_ui/openlayers_interactions_ui.class.php @@ -0,0 +1,92 @@ +plugin['export']['admin_title'])) { + $header[] = array('data' => t('Name'), 'class' => array('ctools-export-ui-title')); + } + + $header[] = array('data' => t('Machine name'), 'class' => array('ctools-export-ui-name')); + $header[] = array('data' => t('Class'), 'class' => array('ctools-export-ui-class')); + $header[] = array('data' => t('Storage'), 'class' => array('ctools-export-ui-storage')); + $header[] = array('data' => t('Operations'), 'class' => array('ctools-export-ui-operations')); + + return $header; + } + + /** + * Build a row based on the item. + * + * By default all of the rows are placed into a table by the render + * method, so this is building up a row suitable for theme('table'). + * This doesn't have to be true if you override both. + */ + function list_build_row($item, &$form_state, $operations) { + // Set up sorting + $name = $item->{$this->plugin['export']['key']}; + $schema = ctools_export_get_schema($this->plugin['schema']); + + // Note: $item->{$schema['export']['export type string']} should have already been set up by export.inc so + // we can use it safely. + switch ($form_state['values']['order']) { + case 'disabled': + $this->sorts[$name] = empty($item->disabled) . $name; + break; + case 'title': + $this->sorts[$name] = $item->{$this->plugin['export']['admin_title']}; + break; + case 'name': + $this->sorts[$name] = $name; + break; + case 'class': + $this->sorts[$name] = $name; + break; + case 'storage': + $this->sorts[$name] = $item->{$schema['export']['export type string']} . $name; + break; + } + + $this->rows[$name]['data'] = array(); + $this->rows[$name]['class'] = !empty($item->disabled) ? array('ctools-export-ui-disabled') : array('ctools-export-ui-enabled'); + + // If we have an admin title, make it the first row. + if (!empty($this->plugin['export']['admin_title'])) { + $this->rows[$name]['data'][] = array('data' => check_plain($item->{$this->plugin['export']['admin_title']}), 'class' => array('ctools-export-ui-title')); + } + $this->rows[$name]['data'][] = array('data' => check_plain($name), 'class' => array('ctools-export-ui-name')); + $this->rows[$name]['data'][] = array('data' => check_plain($item->class), 'class' => array('ctools-export-ui-class')); + $this->rows[$name]['data'][] = array('data' => check_plain($item->{$schema['export']['export type string']}), 'class' => array('ctools-export-ui-storage')); + + $ops = theme('links__ctools_dropbutton', array('links' => $operations, 'attributes' => array('class' => array('links', 'inline')))); + + $this->rows[$name]['data'][] = array('data' => $ops, 'class' => array('ctools-export-ui-operations')); + + // Add an automatic mouseover of the description if one exists. + if (!empty($this->plugin['export']['admin_description'])) { + $this->rows[$name]['title'] = $item->{$this->plugin['export']['admin_description']}; + } + } + + + +} diff --git a/modules/openlayers_ui/plugins/export_ui/openlayers_layers.inc b/modules/openlayers_ui/plugins/export_ui/openlayers_layers.inc index 7d7a82defa9644b5e80cfc130b489def29b5cd47..a293a206ebf21daef52c3d03251522c424667b81 100644 --- a/modules/openlayers_ui/plugins/export_ui/openlayers_layers.inc +++ b/modules/openlayers_ui/plugins/export_ui/openlayers_layers.inc @@ -11,11 +11,32 @@ function openlayers_ui_openlayers_layers_ctools_export_ui() { 'menu prefix' => 'admin/structure/openlayers', 'menu item' => 'layers', 'menu title' => 'Layers', - 'menu description' => 'Administer OpenLayers Layers presets.', + 'menu description' => 'Administer OpenLayers layers presets.', ), 'handler' => array( 'class' => 'openlayers_layers_ui', + 'parent' => 'ctools_export_ui' + ), + + 'use wizard' => TRUE, + 'form info' => array( + 'order' => array( + 'start' => t('Administrative settings'), + 'second' => t('type'), + 'third' => t('type options'), + ), + 'forms' => array( + 'start' => array( + 'form id' => 'openlayers_layer_form_start' + ), + 'second' => array( + 'form id' => 'openlayers_layer_form_second' + ), + 'third' => array( + 'form id' => 'openlayers_layer_form_third' + ), + ) ), 'export' => array( @@ -25,18 +46,117 @@ function openlayers_ui_openlayers_layers_ctools_export_ui() { 'title singular' => t('layer'), 'title plural' => t('layers'), - 'title singular proper' => t('OpenLayers Layer preset'), + 'title singular proper' => t('OpenLayers preset'), 'title plural proper' => t('OpenLayers Layers presets'), 'strings' => array( 'confirmation' => array( 'add' => array( - 'success' => t('Layer saved.'), + 'success' => t('saved.'), ), 'delete' => array( - 'success' => t('Layer was deleted.'), + 'success' => t('was deleted.'), ) ) ), ); } + +function openlayers_layer_form_start($form, &$form_state) { + $class = new ctools_export_ui(); + $class->init($form_state['plugin']); + $class->edit_form($form, $form_state); + return $form; +} + +function openlayers_layer_form_start_validate($form, &$form_state) { + $class = new ctools_export_ui(); + $class->init($form_state['plugin']); + $class->edit_form_validate($form, $form_state); +} + +function openlayers_layer_form_start_submit($form, &$form_state) { + $class = new ctools_export_ui(); + $class->init($form_state['plugin']); + $class->edit_form_submit($form, $form_state); +} + +function openlayers_layer_form_second($form, &$form_state) { + $layers = ctools_get_plugins('openlayers', 'layer'); + $options = array('' => t('')); + foreach ($layers as $class => $plugin) { + $options[$class] = $class; + } + + $form['class'] = array( + '#type' => 'select', + '#title' => t('Type'), + '#default_value' => isset($form_state['item']->class) ? $form_state['item']->class: '', + '#description' => t('Select the type of layer.'), + '#options' => $options, + '#required' => TRUE + ); + + $sources = ctools_export_crud_load_all('openlayers_sources'); + $options = array('' => t('')); + foreach($sources as $machine_name => $data) { + $options[$machine_name] = $data->name; + } + + $form['options'] = array( + '#tree' => TRUE + ); + + // Todo: Replace with getOption(). To get this, we'll probably need to use + // 'object factory' in the appropriate schema from ctools export. + // This way, objects create by ctools export UI will have the right class + // and the getOption() method will be available. + $form['options']['source'] = array( + '#type' => 'select', + '#title' => t('Source'), + '#default_value' => isset($form_state['item']->options['source']) ? $form_state['item']->options['source']: '', + '#description' => t('Select the source.'), + '#options' => $options, + '#required' => TRUE + ); + + return $form; +} + +function openlayers_layer_form_second_submit($form, &$form_state) { + $form_state['item']->class = $form_state['values']['class']; + $form_state['item']->options = array_replace_recursive((array) $form_state['item']->options, $form_state['values']['options']); +} + + +function openlayers_layer_form_third($form, &$form_state) { + $layer = openlayer_object_factory_create('layer', $form_state['item']->class, $form_state['item']); + $form['options'] = $layer->options_form(); + $form['options']['#tree'] = TRUE; + + return $form; +} + +function openlayers_layer_form_third_validate($form, &$form_state) { + +/* + $layer = openlayer_object_factory_create('layer', $form_state['item']->class, $form_state['item']); + $layer->init($form_state['item']); + $layer->options_form_validate($form, $form_state); +*/ +} + +function openlayers_layer_form_third_submit($form, &$form_state) { + + if (isset($form_state['item']->options['file']) && $file = file_load($form_state['item']->options['file'])) { + file_delete($file); + } + + if (isset($form_state['values']['file']) && $file = file_load($form_state['values']['file'])) { + $file->status = FILE_STATUS_PERMANENT; + file_save($file); + file_usage_add($file, 'openlayers', 'layer', $form_state['item']->machine_name); + } + + $form_state['item']->options = array_replace_recursive((array) $form_state['item']->options, $form_state['values']['options']); +} diff --git a/modules/openlayers_ui/plugins/export_ui/openlayers_layers_ui.class.php b/modules/openlayers_ui/plugins/export_ui/openlayers_layers_ui.class.php index 89129e2fbbcc2a44d5fe137b95d5f1951ac4cc76..904cf55b9b21e565a711a073cc55a6d06f7259ab 100644 --- a/modules/openlayers_ui/plugins/export_ui/openlayers_layers_ui.class.php +++ b/modules/openlayers_ui/plugins/export_ui/openlayers_layers_ui.class.php @@ -1,198 +1,46 @@ t('Select the layer type')); - - $layer = NULL; - if ($form_state['op'] == 'edit' && $form_state['form type'] == 'edit') { - $layer = openlayers_layer_load($form_state['item']->name); - } - if ($form_state['op'] == 'add' && $form_state['form type'] == 'clone') { - $layer = openlayers_layer_load($form_state['function args'][2]->name); - $layer->title = t('Clone of ') . $layer->title; - } - - $form['info']['title'] = array( - '#id' => 'layertitle', - '#type' => 'textfield', - '#weight' => -1, - '#title' => t('Layer Title'), - '#default_value' => isset($layer->title) ? $layer->title : '', - '#description' => t('The friendly name of your layer, which will appear in the administration interface as well on the map interface if it is exposed.'), - ); - $form['info']['name']['#machine_name']['source'] = array('info', 'title'); - - $layers_options = array(); - - // Go trough all layer types and get each options form. - foreach ($layer_types as $layer_type) { - - if (is_object($layer) && get_class($layer) == $layer_type['layer_type']['class']) { - // Layer is of current layer type. - $layer_type_object = $layer; - } else { - // Otherwise load layer object for current layer type. - $layer_type_object = openlayers_layer_type_load($layer_type['name']); - } - - $layer_options_form = array(); - if (method_exists($layer_type_object, 'options_form')) { - // This is because the class openlayers_layer_type - // is not abstract. - // Maybe there's a better way to do ? - $parent = get_parent_class($layer_type_object); - $parent_object = new $parent; - $layer_options_form = $layer_type_object->options_form() + $parent_object->options_form($layer); - } - // TODO First case can never be true without crashing earlier - if ($layer_type_object == FALSE || empty($layer_options_form)) { - continue; - } - - $layers_option = array( - '#type' => 'fieldset', - '#tree' => TRUE, - '#title' => t('Layer specific options for @layer_title', array('@layer_title' => $layer_type['title'])), - ); - - $layers_option += $layer_options_form; - $layers_option['#states'] = array( - 'visible' => array( - ':input[name="layer_type"]' => array('value' => $layer_type['name']), - ), - ); - - $layers_option['layer_type'] = array( - '#type' => 'hidden', - '#value' => $layer_type['name'], - ); - - $layers_options[$layer_type['name']] = $layers_option; - - $options[$layer_type['name']] = $layer_type['title']; - } - - $form['layer_type'] = array( - '#type' => 'select', - '#title' => t('Layer Type'), - '#default_value' => isset($layer->data['layer_type']) ? $layer->data['layer_type']: '', - '#description' => t('Select the type of layer.'), - '#options' => $options, - ); - - $form += $layers_options; - - $form['buttons']['submit']['#weight'] = 0; - $form['buttons']['delete']['#weight'] = 20; - - $form['buttons']['saveandedit'] = array( - '#type' => 'submit', - '#value' => t('Save and edit'), - '#weight' => 10 - ); - } - function edit_form_validate(&$form, &$form_state) { - ctools_get_plugins('openlayers', 'layer_types'); - - $layer = openlayers_layer_type_load($form_state['values']['layer_type']); - $form_state['values']['data'] = $form_state['values'][$form_state['values']['layer_type']]; - - if (empty($form_state['values']['layer_type'])) { - form_set_error('layer_type', 'Layer type cannot be empty.'); - } - - $parent = get_parent_class($layer); - $parent_object = new $parent; - $form_state['values']['data'] += $layer->options_init(); - $form_state['values']['data'] += $parent_object->options_init(); - - $layer_types = openlayers_layer_types(); - - foreach($layer_types as $layer_type) { - unset($form_state['values'][$layer_type['name']]); - } - - unset($form_state['values']['layer_type']); - - if (method_exists($layer, 'options_form_validate')) { - $layer->options_form_validate($form, $form_state['values']); - } parent::edit_form_validate($form, $form_state); - } - - /** - * Prepare the tag values before they are added to the database. - */ - function edit_form_submit(&$form, &$form_state) { - $layer = openlayers_layer_type_load($form_state['values']['data']['layer_type']); - $layer->options_form_submit($form, $form_state); - parent::edit_form_submit($form, $form_state); + $layer = $form_state['values']['class']; + $form_state['values']['options'] = $form_state['values']['options'][$layer]; + $form_state['values']['options']['source'] = $form_state['values']['source']; + unset($form_state['values']['data']); } /** - * Implements ctools_export_ui::edit_execute_form(). + * hook_menu() entry point. * - * This is hacky, but since CTools Export UI uses drupal_goto() we have to - * effectively change the plugin to modify the redirect path dynamically. + * Child implementations that need to add or modify menu items should + * probably call parent::hook_menu($items) and then modify as needed. */ - function edit_execute_form(&$form_state) { - $output = parent::edit_execute_form($form_state); - if (!empty($form_state['executed'])) { - $clicked = $form_state['clicked_button']['#value']; - if (t('Save and edit') == $clicked) { - // We always want to redirect back to this page when adding an item, - // but we want to preserve the destination so we can be redirected back - // to where we came from after clicking "Save". - $options = array(); - if (!empty($_GET['destination'])) { - $options['query']['destination'] = $_GET['destination']; - unset($_GET['destination']); - } - - // Sets redirect path and options. - $op = $form_state['op']; - $name = $form_state['values']['name']; - $path = ('add' != $op) ? current_path() : 'admin/structure/openlayers/layers/list/' . $name . '/edit'; - $this->plugin['redirect'][$op] = array($path, $options); - } - } - return $output; + function hook_menu(&$items) { + parent::hook_menu($items); + $items['admin/structure/openlayers/layers']['type'] = MENU_LOCAL_TASK; + $items['admin/structure/openlayers/layers']['weight'] = -5; } /** - * Deletes exportable items from the database. + * Provide the table header. + * + * If you've added columns via list_build_row() but are still using a + * table, override this method to set up the table header. */ - function delete_form_submit(&$form_state) { - - $item = $form_state['item']; - - $layer = openlayers_layer_type_load($item->data['layer_type']); - if (method_exists($layer, 'delete')) { - $layer->delete($item); + function list_table_header() { + $header = array(); + if (!empty($this->plugin['export']['admin_title'])) { + $header[] = array('data' => t('Name'), 'class' => array('ctools-export-ui-title')); } - parent::delete_form_submit($form_state); - } + $header[] = array('data' => t('Machine name'), 'class' => array('ctools-export-ui-name')); + $header[] = array('data' => t('Class'), 'class' => array('ctools-export-ui-class')); + $header[] = array('data' => t('Storage'), 'class' => array('ctools-export-ui-storage')); + $header[] = array('data' => t('Operations'), 'class' => array('ctools-export-ui-operations')); - /** - * hook_menu() entry point. - * - * Child implementations that need to add or modify menu items should - * probably call parent::hook_menu($items) and then modify as needed. - */ - function hook_menu(&$items) { - parent::hook_menu($items); - $items['admin/structure/openlayers/layers']['type'] = MENU_LOCAL_TASK; + return $header; } /** @@ -207,11 +55,6 @@ class openlayers_layers_ui extends ctools_export_ui { $name = $item->{$this->plugin['export']['key']}; $schema = ctools_export_get_schema($this->plugin['schema']); - $layers_types = openlayers_layer_types(); - if (!isset($layers_types[$item->data['layer_type']])) { - return; - } - // Note: $item->{$schema['export']['export type string']} should have already been set up by export.inc so // we can use it safely. switch ($form_state['values']['order']) { @@ -224,6 +67,9 @@ class openlayers_layers_ui extends ctools_export_ui { case 'name': $this->sorts[$name] = $name; break; + case 'class': + $this->sorts[$name] = $name; + break; case 'storage': $this->sorts[$name] = $item->{$schema['export']['export type string']} . $name; break; @@ -236,23 +82,10 @@ class openlayers_layers_ui extends ctools_export_ui { if (!empty($this->plugin['export']['admin_title'])) { $this->rows[$name]['data'][] = array('data' => check_plain($item->{$this->plugin['export']['admin_title']}), 'class' => array('ctools-export-ui-title')); } - - $this->rows[$name]['data'][] = array('data' => $item->title, 'class' => array('ctools-export-ui-title')); - $this->rows[$name]['data'][] = array('data' => $layers_types[$item->data['layer_type']]['title'], 'class' => array('ctools-export-ui-layer-type')); - $this->rows[$name]['data'][] = array('data' => $item->description, 'class' => array('ctools-export-ui-description')); + $this->rows[$name]['data'][] = array('data' => check_plain($name), 'class' => array('ctools-export-ui-name')); + $this->rows[$name]['data'][] = array('data' => check_plain($item->class), 'class' => array('ctools-export-ui-class')); $this->rows[$name]['data'][] = array('data' => check_plain($item->{$schema['export']['export type string']}), 'class' => array('ctools-export-ui-storage')); - // This should be in the module openlayers_views, but I'm still looking - // for a solution to do it properly. - // Temporarily removed. - /* - if ($item->data['layer_type'] == 'openlayers_views_vector') { - $operations['edit']['href'] = 'admin/structure/views/view/' . $item->data['views']['view'] . '/edit/' . $item->data['views']['display']; - $operations['disable']['href'] = 'admin/structure/views/view/' . $item->data['views']['view'] . '/disable/' . $item->data['views']['display']; - $operations['clone']['href'] = 'admin/structure/views/view/' . $item->data['views']['view'] . '/clone/' . $item->data['views']['display']; - $operations['export']['href'] = 'admin/structure/views/view/' . $item->data['views']['view'] . '/export/' . $item->data['views']['display']; - } - */ $ops = theme('links__ctools_dropbutton', array('links' => $operations, 'attributes' => array('class' => array('links', 'inline')))); $this->rows[$name]['data'][] = array('data' => $ops, 'class' => array('ctools-export-ui-operations')); @@ -262,51 +95,4 @@ class openlayers_layers_ui extends ctools_export_ui { $this->rows[$name]['title'] = $item->{$this->plugin['export']['admin_description']}; } } - - /** - * Provide the table header. - * - * If you've added columns via list_build_row() but are still using a - * table, override this method to set up the table header. - */ - function list_table_header() { - $header = array(); - if (!empty($this->plugin['export']['admin_title'])) { - $header[] = array('data' => t('Name'), 'class' => array('ctools-export-ui-name')); - } - - $header[] = array('data' => t('Title'), 'class' => array('ctools-export-ui-title')); - $header[] = array('data' => t('Type'), 'class' => array('ctools-export-ui-layer-type')); - $header[] = array('data' => t('Description'), 'class' => array('ctools-export-ui-description')); - $header[] = array('data' => t('Storage'), 'class' => array('ctools-export-ui-storage')); - $header[] = array('data' => t('Operations'), 'class' => array('ctools-export-ui-operations')); - - return $header; - } - - /** - * Provide a list of sort options. - * - * Override this if you wish to provide more or change how these work. - * The actual handling of the sorting will happen in build_row(). - */ - function list_sort_options() { - if (!empty($this->plugin['export']['admin_title'])) { - $options = array( - 'disabled' => t('Enabled, title'), - $this->plugin['export']['admin_title'] => t('Title'), - ); - } - else { - $options = array( - 'disabled' => t('Enabled, title'), - ); - } - - $options += array( - 'storage' => t('Storage'), - ); - - return $options; - } } diff --git a/modules/openlayers_ui/plugins/export_ui/openlayers_maps.inc b/modules/openlayers_ui/plugins/export_ui/openlayers_maps.inc index a4dc3e75784da2d3876f3e4631b4bd5fc234f224..6d4ef7631fe390a7e30e64193d52b4f05c513720 100644 --- a/modules/openlayers_ui/plugins/export_ui/openlayers_maps.inc +++ b/modules/openlayers_ui/plugins/export_ui/openlayers_maps.inc @@ -11,11 +11,48 @@ function openlayers_ui_openlayers_maps_ctools_export_ui() { 'menu prefix' => 'admin/structure/openlayers', 'menu item' => 'maps', 'menu title' => 'Maps', - 'menu description' => 'Administer OpenLayers Maps presets.', + 'menu description' => 'Administer OpenLayers maps presets.', ), 'handler' => array( - 'class' => 'openlayers_maps_ui' + 'class' => 'openlayers_maps_ui', + 'parent' => 'ctools_export_ui' + ), + + 'use wizard' => TRUE, + 'form info' => array( + 'order' => array( + 'start' => t('Administrative settings'), + 'settings' => t('Map settings'), + 'layers' => t('Layers'), + 'controls' => t('Controls'), + 'interactions' => t('Interactions'), + 'styles' => t('Styles'), + 'preview' => t('Preview') + ), + 'forms' => array( + 'start' => array( + 'form id' => 'openlayers_map_form_start' + ), + 'settings' => array( + 'form id' => 'openlayers_map_form_settings' + ), + 'layers' => array( + 'form id' => 'openlayers_map_form_layers' + ), + 'controls' => array( + 'form id' => 'openlayers_map_form_controls' + ), + 'interactions' => array( + 'form id' => 'openlayers_map_form_interactions' + ), + 'styles' => array( + 'form id' => 'openlayers_map_form_styles' + ), + 'preview' => array( + 'form id' => 'openlayers_map_form_preview' + ) + ) ), 'export' => array( @@ -25,8 +62,8 @@ function openlayers_ui_openlayers_maps_ctools_export_ui() { 'title singular' => t('map'), 'title plural' => t('maps'), - 'title singular proper' => t('Openlayers Map preset'), - 'title plural proper' => t('Openlayers Maps presets'), + 'title singular proper' => t('OpenLayers map preset'), + 'title plural proper' => t('OpenLayers maps presets'), 'strings' => array( 'confirmation' => array( @@ -40,3 +77,257 @@ function openlayers_ui_openlayers_maps_ctools_export_ui() { ), ); } + +function openlayers_map_form_start($form, &$form_state) { + $class = new ctools_export_ui(); + $class->init($form_state['plugin']); + $class->edit_form($form, $form_state); + return $form; +} + +function openlayers_map_form_start_validate($form, &$form_state) { + $class = new ctools_export_ui(); + $class->init($form_state['plugin']); + $class->edit_form_validate($form, $form_state); +} + +function openlayers_map_form_start_submit($form, &$form_state) { + $class = new ctools_export_ui(); + $class->init($form_state['plugin']); + $class->edit_form_submit($form, $form_state); +} + +function openlayers_map_form_settings($form, &$form_state) { + // todo fix this class + $map = openlayer_object_factory_create('map', 'openlayers_map_map', $form_state['item']); + $form['options'] = $map->options_form(); + $form['options']['#tree'] = TRUE; + + return $form; +} +function openlayers_map_form_settings_submit($form, &$form_state) { + // todo: fix + $form_state['item']->class = 'openlayers_map_map'; + $form_state['item']->options = array_replace_recursive((array) $form_state['item']->options, $form_state['values']['options']); +} + +function openlayers_map_form_layers($form, &$form_state) { + $all_layers = ctools_export_crud_load_all('openlayers_layers'); + + $map_layers = array(); + if (isset($form_state['item']->options['layers'])) { + $map_layers = $form_state['item']->options['layers']; + } + + $layers = array(); + foreach($map_layers as $i => $machine_name) { + if (isset($all_layers[$machine_name])) { + $layers[$machine_name] = $all_layers[$machine_name]; + $layers[$machine_name]->enable = 1; + unset($all_layers[$machine_name]); + } + } + + $layers = array_merge($layers, $all_layers); + + $data = array(); + + $i = 0; + foreach ($layers as $machine_name => $layer) { + $data[$machine_name] = array( + 'name' => $layer->name, + 'machine_name' => $layer->machine_name, + 'description' => $layer->description, + 'class' => $layer->class, + 'weight' => $i++, + 'enable' => isset($layer->enable) ? $layer->enable : 0, + 'default' => 1 + ); + } + + $rows = array(); + foreach($data as $id => $entry) { + $rows[$id] = array( + 'data' => array( + array('class', array('entry-cross')), + array('data' => array( + '#type' => 'weight', + '#title' => t('Weight'), + '#title_display' => 'invisible', + '#default_value' => $entry['weight'], + '#parents' => array('layers', $id, 'weight'), + '#attributes' => array( + 'class' => array('entry-order-weight'), + ) + )), + array('data' => array( + '#type' => 'checkbox', + '#title' => t('Enable'), + '#title_display' => 'invisible', + '#default_value' => $entry['enable'], + '#parents' => array('layers', $id, 'enable'), + )), + array('data' => array( + '#type' => 'checkbox', + '#title' => t('Default'), + '#title_display' => 'invisible', + '#default_value' => $entry['default'], + '#parents' => array('layers', $id, 'default'), + )), + check_plain($entry['name']), + check_plain($entry['machine_name']), + check_plain($entry['description']), + check_plain($entry['class']), + ), + 'class' => array('draggable'), + ); + // Build rows of the form elements in the table. + $row_elements[$id] = array( + 'weight' => &$rows[$id]['data'][1]['data'], + 'enabled' => &$rows[$id]['data'][2]['data'], + 'default' => &$rows[$id]['data'][3]['data'], + ); + } + + // Add the table to the form. + $form['table'] = array( + '#theme' => 'table', + // The row form elements need to be processed and build, + // therefore pass them as element children. + 'elements' => $row_elements, + '#header' => array( + // We need two empty columns for the weigth field and the cross. + array('data' => NULL, 'colspan' => 2), + t('Enabled'), + t('Default'), + t('Name'), + t('Machine name'), + t('Description'), + t('Class'), + ), + '#rows' => $rows, + '#empty' => t('There are no entries available.'), + '#attributes' => array('id' => 'entry-order'), + ); + drupal_add_tabledrag('entry-order', 'order', 'sibling', 'entry-order-weight'); + return $form; +} +function openlayers_map_form_layers_submit($form, &$form_state) { + $layers = $form_state['values']['layers']; + + $layers_enabled = array(); + foreach($layers as $id => $data) { + if ($data['enable'] == 1) { + $layers_enabled[$data['weight']] = $id; + } + } + + ksort($layers_enabled); + + $form_state['item']->options['layers'] = array_values($layers_enabled); +} + +function openlayers_map_form_controls($form, &$form_state) { + $all_controls = ctools_export_crud_load_all('openlayers_controls'); + + $header = array( + 'name' => t('Name'), + 'machine_name' => t('Machine name'), + 'description' => t('Description'), + ); + + $rows = array(); + foreach ($all_controls as $machine_name => $control) { + $rows[$machine_name] = array( + 'name' => $control->name, + 'machine_name' => $control->machine_name, + 'description' => $control->description, + ); + } + + $form['options']['#tree'] = TRUE; + + if (!isset($form_state['item']->options['controls'])) { + $form_state['item']->options['controls'] = array(); + } + + $form['options']['controls'] = array( + '#type' => 'tableselect', + '#header' => $header, + '#options' => $rows, + '#default_value' => drupal_map_assoc($form_state['item']->options['controls']) + ); + + return $form; +} +function openlayers_map_form_controls_submit($form, &$form_state) { + $form_state['item']->options['controls'] = array_filter(array_values($form_state['values']['options']['controls'])); +} + +function openlayers_map_form_interactions($form, &$form_state) { + $all_interactions = ctools_export_crud_load_all('openlayers_interactions'); + + $header = array( + 'name' => t('Name'), + 'machine_name' => t('Machine name'), + 'description' => t('Description'), + ); + + $rows = array(); + foreach ($all_interactions as $machine_name => $interaction) { + $rows[$machine_name] = array( + 'name' => $interaction->name, + 'machine_name' => $interaction->machine_name, + 'description' => $interaction->description, + ); + } + + $form['options']['#tree'] = TRUE; + + if (!isset($form_state['item']->options['interactions'])) { + $form_state['item']->options['interactions'] = array(); + } + + $form['options']['interactions'] = array( + '#type' => 'tableselect', + '#header' => $header, + '#options' => $rows, + '#default_value' => drupal_map_assoc($form_state['item']->options['interactions']) + ); + + return $form; +} +function openlayers_map_form_interactions_submit($form, &$form_state) { + $form_state['item']->options = array_replace_recursive($form_state['item']->options, $form_state['values']['options']); + $form_state['item']->options['interactions'] = array_filter(array_values($form_state['values']['options']['interactions'])); +} + +function openlayers_map_form_styles($form, &$form_state) { + return $form; +} +function openlayers_map_form_styles_submit($form, &$form_state) { +// $form_state['item']->options = $form_state['item']->options, (array) $form_state['values']['options']); +} + +function openlayers_map_form_preview($form, &$form_state) { + $map = openlayer_object_factory_create('map', $form_state['item']->class); + $map->init($form_state['item']); + $map->setOption('contextualLinks', FALSE); + + $form['preview'] = array( + '#markup' => openlayers_render_map($map) + ); + + return $form; +} +function openlayers_map_form_preview_submit($form, &$form_state) { + $form_state['item']->options = $form_state['item']->options; +} + +function _openlayers_maps_sort_by_weight($a, $b) { + if (isset($a['weight']) && isset($b['weight'])) { + return $a['weight'] < $b['weight'] ? -1 : 1; + } + return 0; +} + diff --git a/modules/openlayers_ui/plugins/export_ui/openlayers_maps_ui.class.php b/modules/openlayers_ui/plugins/export_ui/openlayers_maps_ui.class.php index a0eb77bf6ac53013773c48258fc418fbcc98aab4..9bb756ec2f43bae6327ff311e9636bc796631c98 100644 --- a/modules/openlayers_ui/plugins/export_ui/openlayers_maps_ui.class.php +++ b/modules/openlayers_ui/plugins/export_ui/openlayers_maps_ui.class.php @@ -1,701 +1,7 @@ name)) { - $map = NULL; - } - - module_load_include('inc', 'openlayers_ui', 'includes/openlayers_ui.maps'); - - openlayers_include(); - ctools_include('dependent'); - drupal_add_js(drupal_get_path('module', 'openlayers_ui') . - '/js/openlayers_ui.maps.js'); - drupal_add_css(drupal_get_path('module', 'openlayers_ui') . - '/openlayers_ui.css'); - - // If cloning or editing, attempt to get map. - $defaults = array(); - if (empty($map)) { - $default_map = openlayers_map_load(variable_get('openlayers_default_map', 'default')); - if ($default_map) { - $defaults = $default_map->data; - } - } - else { - $defaults = $map->data; - } - $defaults['projection'] = openlayers_get_projection_by_identifier($defaults['projection']); - $defaults['displayProjection'] = openlayers_get_projection_by_identifier($defaults['displayProjection']); - - // Map preview. It's a little in the way, so we allow the user - // to turn it on or off. Show on preview, otherwise look at setting. - // Might want to look at disableing the mousewheel zoom since - // the map could be very in the way. - if ( (isset($form_state['clicked_button']['#id']) - && ($form_state['clicked_button']['#id'] == 'edit-buttons-preview')) - || (variable_get('openlayers_ui_preview_map', FALSE))) { - - $map_preview = isset($form_state['values']) ? openlayers_ui_maps_form_process($form_state['values']) : $map; - - $form['preview'] = array( - '#tree' => FALSE, - '#type' => 'fieldset', - '#title' => t('Preview'), - '#description' => t('The following is a preview of your map. Click Preview - to refresh the map with the new values. ' . - (!variable_get('openlayers_ui_preview_map', FALSE) ? - t('Turn map previews on by default on the !link.', - array('!link' => l(t('Settings page'), 'admin/structure/openlayers/settings'))) : '' - ) - ), - ); - - $build = openlayers_render_map_data($map_preview->data); - $form['preview']['map'] = array( - '#markup' => render($build), - ); - } else { - $form['preview'] = array(); - $form['preview']['map'] = array( - '#markup' => '

' . t('Turn map previews on by default on the !link.', - array('!link' => l(t('Settings page'), 'admin/structure/openlayers/settings'))) . '

', - ); - } - - // Utilize vertical tabs for a better interface. - $form['ui'] = array( - '#type' => 'vertical_tabs', - '#default_tab' => 'info' - ); - - // General map information. - $form['info']['#type'] = 'fieldset'; - $form['info']['#group'] = 'ui'; - $form['info']['#title'] = 'Infos'; - - $form['info']['title'] = array( - '#id' => 'maptitle', - '#type' => 'textfield', - '#title' => t('Map Title'), - '#description' => t('This is the descriptive title of the map and will show up most often in the interface.'), - '#maxlength' => 255, - '#default_value' => !empty($map->title) ? $map->title : '', - '#required' => TRUE, - '#weight' => -1 - ); - $form['info']['name']['#machine_name']['source'] = array('info', 'title'); - - $form['info']['width'] = array( - '#type' => 'textfield', - '#title' => t('Width'), - '#description' => t('The map\'s width. "auto" will make the map fill - the space it is given; otherwise, enter a value in pixels, like 400px.'), - '#default_value' => !empty($defaults['width']) ? $defaults['width'] : '', - '#maxlength' => 128, - '#required' => TRUE, - ); - $form['info']['height'] = array( - '#type' => 'textfield', - '#title' => t('Height'), - '#description' => t('The map\'s height. Enter a value in pixels, - like 400px.'), - '#default_value' => !empty($defaults['height']) ? $defaults['height'] : '', - '#maxlength' => 128, - '#required' => TRUE, - ); - - // Only show this if Openlayers Views is enabled - if (module_exists('openlayers_views')) { - $form['info']['hide_empty_map'] = array( - '#type' => 'checkbox', - '#title' => t('Hide empty map for Views'), - '#description' => t("Show views empty text or hide the map if there are - no map overlays with features. Otherwise an empty map is displayed."), - '#default_value' => isset($defaults['hide_empty_map']) ? - $defaults['hide_empty_map'] : FALSE, - ); - } - - $default_image_path = drupal_get_path('module', 'openlayers') . '/themes/default_dark/img/'; - $form['info']['image_path'] = array( - '#type' => 'textfield', - '#title' => t('Image Path'), - '#description' => t('

The path to a directory of UI graphics. Use any of the - following:

-
    -
  • Leave blank for default graphics as provided - by the OpenLayers library.
  • -
  • Relative Drupal path a path without leading slash and - the base path will be prepended, ex. "sites/all/themes/path/to/images/"
  • -
  • Absolute path a path with leading slash and path will - start from sites root directory, ex. "/path/to/images/"
  • -
  • Full URL such as "http://example.com/image/"
  • -
-

Always include trailing slash. The default path provided with this module - is: %default

-

This is actually a setting for the OpenLayers - object and will affect all maps on the same page.

', - array('%default' => $default_image_path) - ), - '#default_value' => !empty($defaults['image_path']) ? - $defaults['image_path'] : '', - ); - - $default_css_path = drupal_get_path('module', 'openlayers') . '/themes/default_dark/style.css'; - $form['info']['css_path'] = array( - '#type' => 'textfield', - '#title' => t('CSS Path'), - '#description' => t('

The path to a CSS file for overriding CSS. You - don\'t really need to override this as CSS is almost always overridable. - Use any of the following:

-
    -
  • Leave blank for default hosted OpenLayers which - is !link
  • -
  • Relative Drupal path a path without leading slash and - the base path will be prepended, ex. "sites/all/themes/path/to/style.css"
  • -
  • Absolute path a path with leading slash and path will - start from sites root directory, ex. "/path/to/style.css"
  • -
  • Full URL such as "http://example.com/style.css"
  • -
-

The default path provided with this module - is: %default

-

This is actually a setting for the OpenLayers - object and will affect all maps on the same page.

', - array( - '!link' => l('http://openlayers.org/api/theme/default/style.css', - 'http://openlayers.org/api/theme/default/style.css'), - '%default' => $default_css_path, - ) - ), - '#default_value' => !empty($defaults['css_path']) ? - $defaults['css_path'] : '', - ); - - $form['info']['proxy_host'] = array( - '#type' => 'textfield', - '#title' => t('Proxy Host'), - '#description' => t('

A proxy (typically on the same domain as this site) - which enables requests to cross-domain AJAX resources (including remote - KML). Use any of the following:

-
    -
  • Leave blank no proxy path.
  • -
  • Relative Drupal path a path without leading slash and - the base path will be prepended, ex. "proxy?request="
  • -
  • Absolute path a path with leading slash and path will - start from sites root directory, ex. "/cgi_proxy?request="
  • -
  • Full URL such as "http://example.com/proxy?request="
  • -
-

This is actually a setting for the OpenLayers - object and will affect all maps on the same page.

' - ), - '#default_value' => !empty($defaults['proxy_host']) ? - $defaults['proxy_host'] : '', - ); - - // Center - $form['center'] = array( - '#title' => t('Center & Bounds'), - '#description' => t('Where the map will center itself initially. - Shift-drag a box on the map to set the Restricted Extent.'), - '#tree' => TRUE, - '#type' => 'fieldset', - '#group' => 'ui' - ); - $build = openlayers_ui_maps_form_center_map($defaults); - $form['center']['helpmap'] = array( - '#markup' => '
' . render($build) . '
' - ); - $form['center']['initial'] = array( - '#type' => 'fieldset', - '#title' => t('Initial Map View') - ); - $form['center']['initial']['centerpoint'] = array( - '#type' => 'textfield', - '#title' => t('Centerpoint'), - '#description' => t('Coordinates that are the intial focus of the map. This - is formated like longitude,latitude.'), - '#default_value' => $defaults['center']['initial']['centerpoint'], - '#attributes' => array('class' => array('openlayers-form-centerpoint')), - '#size' => 25, - ); - $form['center']['initial']['zoom'] = array( - '#type' => 'textfield', - '#title' => t('Zoom Level'), - '#description' => t('Initial Zoom Level when the map intially displays. - Higher is more zoomed in.'), - '#default_value' => $defaults['center']['initial']['zoom'], - '#attributes' => array('class' => array('openlayers-form-zoom')), - '#size' => 25, - ); - $form['center']['restrict'] = array( - '#type' => 'fieldset', - '#title' => t('Restrict Extent') - ); - $form['center']['restrict']['restrictextent'] = array( - '#type' => 'checkbox', - '#title' => t('Restrict Extent'), - '#description' => t('Setting the restricted extent of a map prevents users - from panning the map outside a specified area. This can be set - interactively by holding the shift key and dragging a box over the map - above. Setting the extent does not restrict how far users can zoom out, - so setting restricted zoom levels (via individual layer settings) is - recommended.'), - '#id' => 'restrictextent', - '#default_value' => isset($defaults['center']['restrict']['restrictextent']) ? - $defaults['center']['restrict']['restrictextent'] : '', - ); - $form['center']['restrict']['restrictedExtent'] = array( - '#type' => 'textfield', - '#title' => t('Restricted Extent'), - '#description' => t('Prevents users from panning outside of a specific bounding box'), - '#default_value' => isset($defaults['center']['restrict']['restrictedExtent']) ? - $defaults['center']['restrict']['restrictedExtent'] : '', - '#attributes' => array('class' => array('openlayers-form-restrictedExtent')), - '#size' => 25, - '#process' => array('ctools_dependent_process'), - '#dependency' => array('restrictextent' => array(1)) - ); - - // Layers & styles - $form['layerstyles'] = array( - '#type' => 'fieldset', - '#title' => t('Layers & Styles'), - '#description' => t('Layer settings. The Layer options will change based on the projection chosen.'), - '#theme' => 'openlayers_ui_maps_form_layers', - '#tree' => TRUE, - '#group' => 'ui', - '#prefix' => '', - '#suffix' => '' - ); - - // Projection options - $projections = array(); - foreach (openlayers_ui_get_projection_options() as $projection) { - $projection_layers = array_merge( - openlayers_ui_get_layer_options('baselayer', $projection), - openlayers_ui_get_layer_options('overlay', $projection)); - - $projections[$projection->identifier] = theme( - 'openlayers_ui_form_projection_description', - array( - 'projection' => $projection, - 'available_layers' => $projection_layers - ) - ); - } - - $form['layerstyles']['projections'] = array( - '#type' => 'fieldset', - '#title' => t('Projections'), - '#description' => t('

WARNING: Projections are not well supported in - this module. If you need to handle non spherical mercator projections - you may be better using the API directly.

-

Select the !link_proj for your map. The list next - to each projection is the layers that support this projection.

', - array('!link_proj' => l(t('geographical projection'), - 'http://en.wikipedia.org/wiki/Map_projection')) - ), - '#tree' => TRUE, - ); - $form['layerstyles']['projections']['easy_projection'] = array( - '#type' => 'radios', - '#title' => t('Map Projection'), - '#description' => t('The !link_proj of this map: all layers will either be requested or reprojected to this format.', array( - '!link_proj' => l( - t('geographical projection'), - 'http://en.wikipedia.org/wiki/Map_projection'), - )), - '#default_value' => $defaults['projection']->identifier, - '#options' => $projections, - '#attributes' => array('class' => array('openlayers-form-easy-projection')), - '#ajax' => array( - 'callback' => 'openlayers_map_layerlist', - 'wrapper' => 'edit-layerstyles', - 'method' => 'replace', - 'event' => 'change' - ) - ); - $displayProjectionOptions = array(); - foreach(openlayers_ui_get_projection_options() as $projectionIdentifier => $projection){ - $displayProjectionOptions[$projectionIdentifier] = $projection->getLocalizedMessage(); - } - $form['layerstyles']['projections']['displayProjection'] = array( - '#type' => 'select', - '#title' => t('Display Projection'), - '#description' => t('All interaction with the map - drawing, panning, - centering, and more - occurs in the display projection. The vast majority - of maps use 4326 (latitude/longitude) for this value.'), - '#default_value' => !empty($defaults['displayProjection']) ? - $defaults['displayProjection']->identifier : openlayers_get_projection('EPSG', '4326')->identifier, - '#options' => $displayProjectionOptions, - ); - - $form['layerstyles']['layers'] = array( - '#title' => t('Layers & Styles'), - '#description' => t('Layer settings. The Layer options will change based on the projection chosen.'), - '#type' => 'fieldset', - ); - - // Construct data for theme_openlayers_ui_maps_form_layers - $form['layerstyles']['layers']['#tree'] = TRUE; - $form['layerstyles']['layers']['baselabels'] = array(); - if(isset($form_state['values']['layerstyles']['projections']['easy_projection'])){ - // Projection was choosen by editing the form - $easy_projection = openlayers_get_projection_by_identifier($form_state['values']['layerstyles']['projections']['easy_projection']); - } else { - // Form was not yet edited, use default - $easy_projection = $defaults['projection']; - } - $base_options = openlayers_ui_get_layer_options('baselayer', $easy_projection); - foreach ($base_options as $id => $description) { - $form['layerstyles']['layers']['baselabels'][$id] = - array('#markup' => $description); - } - $form['layerstyles']['layers']['baselayers'] = array( - '#type' => 'checkboxes', - '#options' => $base_options, - '#default_value' => !empty($defaults['layers']) ? - array_intersect_key($defaults['layers'], $base_options) : - array() - ); - $form['layerstyles']['layers']['default_layer'] = array( - '#type' => 'radios', - '#options' => $base_options, - '#default_value' => !empty($defaults['default_layer']) && - isset($base_options[$defaults['default_layer']]) ? - $defaults['default_layer'] : - NULL, - ); - - // Overlay layers - $overlay_options = openlayers_ui_get_layer_options('overlay', $easy_projection); - $form['layerstyles']['layers']['overlaylabels'] = array(); - if (!empty($overlay_options)) { - - // Have enabled layers maintain their order - $available = array_keys($overlay_options); - $enabled = array_intersect(array_keys($defaults['layers']), $available); - $disabled = array_diff($available, $enabled); - $overlay_options_keys = array_merge($disabled, $enabled); - - // Create overlay options. - $form['layerstyles']['layer_styles']['#tree'] = TRUE; - $form['layerstyles']['layer_styles_select']['#tree'] = TRUE; - $form['layerstyles']['layer_styles_temporary']['#tree'] = TRUE; - $form['layerstyles']['layer_weight']['#tree'] = TRUE; - foreach ($overlay_options_keys as $id) { - $description = $overlay_options[$id]; - $form['layerstyles']['layers']['overlaylabels'][$id] = array('#markup' => $description); - - // Layer styles that define the default style of layer. - $form['layerstyles']['layer_styles'][$id] = array( - '#type' => 'select', - '#options' => array('<' . t('use default style') . '>') + openlayers_ui_get_style_options(), - '#default_value' => !empty($defaults['layer_styles'][$id]) ? - $defaults['layer_styles'][$id] : '', - ); - - // Layer select style. - $form['layerstyles']['layer_styles_select'][$id] = array( - '#type' => 'select', - '#options' => array('<' . t('use default style') . '>') + openlayers_ui_get_style_options(), - '#default_value' => !empty($defaults['layer_styles_select'][$id]) ? - $defaults['layer_styles_select'][$id] : '', - ); - - // Layer temporary style. - $form['layerstyles']['layer_styles_temporary'][$id] = array( - '#type' => 'select', - '#options' => array('<' . t('use default style') . '>') + openlayers_ui_get_style_options(), - '#default_value' => !empty($defaults['layer_styles_temporary'][$id]) ? - $defaults['layer_styles_temporary'][$id] : '', - ); - - // Weight of layer. This will affect how the layer shows up in the - // switcher and is rendered. - $form['layerstyles']['layer_weight'][$id] = array( - '#type' => 'weight', - '#default_value' => !empty($defaults['layer_weight'][$id]) ? $defaults['layer_weight'][$id] : 0, - '#attributes' => array( - 'class' => array('layer-weight') - ) - ); - } - - // Checkbox options for overlay layers. - $form['layerstyles']['layers']['overlays'] = array( - '#type' => 'checkboxes', - '#options' => $overlay_options, - '#default_value' => !empty($defaults['layers']) ? - array_intersect_key($defaults['layers'], $overlay_options) : array(), - ); - $form['layerstyles']['layer_activated'] = array( - '#type' => 'checkboxes', - '#options' => $overlay_options, - '#default_value' => !empty($defaults['layer_activated']) ? - array_intersect_key($defaults['layer_activated'], $overlay_options) : array(), - ); - $form['layerstyles']['layer_switcher'] = array( - '#type' => 'checkboxes', - '#options' => $overlay_options, - '#default_value' => !empty($defaults['layer_switcher']) ? - array_intersect_key($defaults['layer_switcher'], $overlay_options) : array(), - ); - } - - // Data overlay help. - $form['layerstyles']['help_data_overlays'] = array( - '#type' => 'item', - '#description' => t('Add Data Overlays: You can add regular - overlays, like GeoJSON or KML, - or you can utilize Views to create data overlays. - To create a Views-based overlay, you must choose the OpenLayers - Data Overlay Display Type, and then explicitly set the the - same for the Format. The options in the Format - Settings will only use fields you have added. To learn more, take - a look at the online documentation on Drupal.org.', - array( - '!views_url' => url('admin/structure/views'), - '!geojson' => url('admin/structure/openlayers/layers/add/openlayers_layer_type_geojson'), - '!kml' => url('admin/structure/openlayers/layers/add/openlayers_layer_type_kml'), - '!online_url' => url('http://drupal.org/node/595872'), - ) - ), - ); - - - // Styles - $form['layerstyles']['styles'] = array( - '#type' => 'fieldset', - '#title' => t('Default Styles'), - '#description' => t('Define default style designations for layers when there - are no overrides.'), - '#tree' => TRUE, - ); - $form['layerstyles']['styles']['default'] = array( - '#type' => 'select', - '#title' => t('Default style'), - '#description' => t('Default style for features in a vector.'), - '#options' => openlayers_ui_get_style_options(), - '#default_value' => !empty($defaults['styles']['default']) ? - $defaults['styles']['default'] : NULL, - ); - $form['layerstyles']['styles']['select'] = array( - '#type' => 'select', - '#title' => t('Select style'), - '#description' => t('Style for features in a vector that are selected.'), - '#options' => openlayers_ui_get_style_options(), - '#default_value' => !empty($defaults['styles']['select']) ? - $defaults['styles']['select'] : NULL, - ); - $form['layerstyles']['styles']['temporary'] = array( - '#type' => 'select', - '#title' => t('Temporary Style'), - '#description' => t('Default temporary style for any features in a vector. - This can be used with the "Hover behavior" or things like Tooltips.'), - '#options' => openlayers_ui_get_style_options(), - '#default_value' => !empty($defaults['styles']['temporary']) ? - $defaults['styles']['temporary'] : NULL, - ); - - // Behaviors - $form['behaviors'] = array( - '#title' => t('Behaviors'), - '#description' => t('Configure interactive map behaviors. Behaviors are general interactions for the map, they can be anything from popups or keyboard handling. Enable the ones you want and their respective options. Note that some behaviors do not work with each other or one may encompass another.'), - '#theme' => 'openlayers_ui_maps_form_behaviors', - '#tree' => TRUE, - '#type' => 'fieldset', - '#group' => 'ui' - ); - $form['behaviors'] = $form['behaviors'] + openlayers_ui_get_behavior_options('map', $defaults); - - // Displays - $form['displays'] = array( - '#title' => t('Displays'), - '#description' => t('Learn how to display your maps.'), - '#tree' => TRUE, - '#type' => 'fieldset', - '#group' => 'ui' - ); - if (module_exists('openlayers_views')) { - $form['displays']['views'] = array( - '#type' => 'item', - '#title' => t('Views'), - '#description' => t('Utilize the Views module to - display your map as page or in a block. By creating a new Views Display of - type Page or Block you can then choose - the OpenLayers Map Format. For more details, check out - the online documentation on Drupal.org.', - array( - '!views_url' => url('admin/structure/views'), - '!online_url' => url('http://drupal.org/node/595872') - ) - ), - '#suffix' => theme('image', array('path' => - 'https://img.skitch.com/20111106-c6ukwxgpgykxx8m41yrn8qew4n.png')), - ); - $form['displays']['api'] = array( - '#type' => 'item', - '#title' => t('API'), - '#description' => t('You can always utilize the API to directly display - your maps. The key function to use is openlayers_render_map(). - Most of the code is well documented. To learn how to extend the module, - take a look at the online documentation on - Drupal.org as well as the files in the docs/ folder.', - array('!online_url' => url('http://drupal.org/node/595872')) - ), - ); - } - - $form['buttons']['submit']['#weight'] = 0; - $form['buttons']['delete']['#weight'] = 20; - - $form['buttons']['saveandedit'] = array( - '#type' => 'submit', - '#value' => t('Save and edit'), - '#weight' => 10 - ); - - // Add preview button. - $form['buttons']['preview'] = array( - '#type' => 'button', - '#value' => t('Preview'), - '#weight' => 30 - ); - } - - /** - * Prepare the tag values before they are added to the database. - */ - function edit_form_submit(&$form, &$form_state) { - module_load_include('inc', 'openlayers_ui', 'includes/openlayers_ui.maps'); - $form_state['values']['data'] = openlayers_ui_maps_form_process($form_state['values']); - parent::edit_form_submit($form, $form_state); - } - - /** - * Implements ctools_export_ui::edit_execute_form(). - * - * This is hacky, but since CTools Export UI uses drupal_goto() we have to - * effectively change the plugin to modify the redirect path dynamically. - */ - function edit_execute_form(&$form_state) { - $output = parent::edit_execute_form($form_state); - if (!empty($form_state['executed'])) { - $clicked = $form_state['clicked_button']['#value']; - if (t('Save and edit') == $clicked) { - // We always want to redirect back to this page when adding an item, - // but we want to preserve the destination so we can be redirected back - // to where we came from after clicking "Save". - $options = array(); - if (!empty($_GET['destination'])) { - $options['query']['destination'] = $_GET['destination']; - unset($_GET['destination']); - } - - // Sets redirect path and options. - $op = $form_state['op']; - $name = $form_state['values']['name']; - $path = ('add' != $op) ? current_path() : 'admin/structure/openlayers/maps/list/' . $name . '/edit'; - $this->plugin['redirect'][$op] = array($path, $options); - } - } - return $output; - } - - /** - * Build a row based on the item. - * - * By default all of the rows are placed into a table by the render - * method, so this is building up a row suitable for theme('table'). - * This doesn't have to be true if you override both. - */ - function list_build_row($item, &$form_state, $operations) { - // Set up sorting - $name = $item->{$this->plugin['export']['key']}; - $schema = ctools_export_get_schema($this->plugin['schema']); - - // Note: $item->{$schema['export']['export type string']} should have already been set up by export.inc so - // we can use it safely. - switch ($form_state['values']['order']) { - case 'disabled': - $this->sorts[$name] = empty($item->disabled) . $name; - break; - case 'title': - $this->sorts[$name] = $item->{$this->plugin['export']['admin_title']}; - break; - case 'name': - $this->sorts[$name] = $name; - break; - case 'storage': - $this->sorts[$name] = $item->{$schema['export']['export type string']} . $name; - break; - } - - $this->rows[$name]['data'] = array(); - $this->rows[$name]['class'] = !empty($item->disabled) ? array('ctools-export-ui-disabled') : array('ctools-export-ui-enabled'); - - // If we have an admin title, make it the first row. - if (!empty($this->plugin['export']['admin_title'])) { - $this->rows[$name]['data'][] = array('data' => check_plain($item->{$this->plugin['export']['admin_title']}), 'class' => array('ctools-export-ui-title')); - } - - $layers = openlayers_layers_load(); - $layers_names = array(); - foreach ($item->data['layers'] as $layer) { - if (isset($layers[$layer])) { - $layers_names[] = empty($layers[$layer]->title) ? $layer : filter_xss_admin($layers[$layer]->title); - } - } - - sort($layers_names); - $layers_names = implode(',', $layers_names); - - $this->rows[$name]['data'][] = array('data' => $item->title, 'class' => array('ctools-export-ui-title')); - $this->rows[$name]['data'][] = array('data' => $layers_names, 'class' => array('ctools-export-ui-layers')); - $this->rows[$name]['data'][] = array('data' => $item->description, 'class' => array('ctools-export-ui-description')); - $this->rows[$name]['data'][] = array('data' => check_plain($item->{$schema['export']['export type string']}), 'class' => array('ctools-export-ui-storage')); - - $ops = theme('links__ctools_dropbutton', array('links' => $operations, 'attributes' => array('class' => array('links', 'inline')))); - - $this->rows[$name]['data'][] = array('data' => $ops, 'class' => array('ctools-export-ui-operations')); - - // Add an automatic mouseover of the description if one exists. - if (!empty($this->plugin['export']['admin_description'])) { - $this->rows[$name]['title'] = $item->{$this->plugin['export']['admin_description']}; - } - } - - /** - * Provide the table header. - * - * If you've added columns via list_build_row() but are still using a - * table, override this method to set up the table header. - */ - function list_table_header() { - $header = array(); - if (!empty($this->plugin['export']['admin_title'])) { - $header[] = array('data' => t('Name'), 'class' => array('ctools-export-ui-name')); - } - - $header[] = array('data' => t('Title'), 'class' => array('ctools-export-ui-title')); - $header[] = array('data' => t('Layers'), 'class' => array('ctools-export-ui-layers')); - $header[] = array('data' => t('Description'), 'class' => array('ctools-export-ui-description')); - $header[] = array('data' => t('Storage'), 'class' => array('ctools-export-ui-storage')); - $header[] = array('data' => t('Operations'), 'class' => array('ctools-export-ui-operations')); - - return $header; - } - /** * hook_menu() entry point. * @@ -705,41 +11,8 @@ class openlayers_maps_ui extends ctools_export_ui { function hook_menu(&$items) { parent::hook_menu($items); $items['admin/structure/openlayers/maps']['type'] = MENU_LOCAL_TASK; - $items['admin/structure/openlayers/maps/list/%ctools_export_ui/clone']['context'] = MENU_CONTEXT_INLINE; - $items['admin/structure/openlayers/maps/list/%ctools_export_ui/edit']['context'] = MENU_CONTEXT_INLINE; - $items['admin/structure/openlayers/maps/list/%ctools_export_ui/export']['context'] = MENU_CONTEXT_INLINE; - $items['admin/structure/openlayers/maps/list/%ctools_export_ui/revert']['context'] = MENU_CONTEXT_INLINE; - $items['admin/structure/openlayers/maps/list/%ctools_export_ui/clone']['type'] = MENU_LOCAL_TASK; - $items['admin/structure/openlayers/maps/list/%ctools_export_ui/edit']['type'] = MENU_LOCAL_TASK; - $items['admin/structure/openlayers/maps/list/%ctools_export_ui/export']['type'] = MENU_LOCAL_TASK; - $items['admin/structure/openlayers/maps/list/%ctools_export_ui/revert']['type'] = MENU_LOCAL_TASK; - } - - /** - * Provide a list of sort options. - * - * Override this if you wish to provide more or change how these work. - * The actual handling of the sorting will happen in build_row(). - */ - function list_sort_options() { - if (!empty($this->plugin['export']['admin_title'])) { - $options = array( - 'disabled' => t('Enabled, title'), - $this->plugin['export']['admin_title'] => t('Title'), - ); - } - else { - $options = array( - 'disabled' => t('Enabled, title'), - ); - } - - $options += array( - 'storage' => t('Storage'), - ); - - return $options; + $items['admin/structure/openlayers/maps']['context'] = MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE; + $items['admin/structure/openlayers/maps']['weight'] = -10; } - } diff --git a/modules/openlayers_ui/plugins/export_ui/openlayers_projections.inc b/modules/openlayers_ui/plugins/export_ui/openlayers_projections.inc deleted file mode 100644 index 4166c07e1902f46dd339bd9a1e52a1f1f3017914..0000000000000000000000000000000000000000 --- a/modules/openlayers_ui/plugins/export_ui/openlayers_projections.inc +++ /dev/null @@ -1,47 +0,0 @@ - 'openlayers_projections', - 'access' => 'administer openlayers', - 'menu' => array( - 'menu prefix' => 'admin/structure/openlayers', - 'menu item' => 'projections', - // TODO Translation? - 'menu title' => 'Projections', - // TODO Translation? - 'menu description' => 'Administer OpenLayers projections.', - ), - - 'handler' => array( - 'class' => 'openlayers_projections_ui', - ), - - 'export' => array( - 'key' => 'identifier' - ), - - // TODO What is this good for? - 'title singular' => t('projections'), - 'title plural' => t('projections'), - 'title singular proper' => t('OpenLayers projection'), - 'title plural proper' => t('OpenLayers projections'), - - 'strings' => array( - 'confirmation' => array( - 'add' => array( - 'success' => t('Projection saved.'), - ), - 'delete' => array( - 'success' => t('Projection was deleted.'), - ) - ) - ), - ); -} diff --git a/modules/openlayers_ui/plugins/export_ui/openlayers_projections_ui.class.php b/modules/openlayers_ui/plugins/export_ui/openlayers_projections_ui.class.php deleted file mode 100644 index e9a1e1e47945ffac5bbb9ffe971c46591e4b4d40..0000000000000000000000000000000000000000 --- a/modules/openlayers_ui/plugins/export_ui/openlayers_projections_ui.class.php +++ /dev/null @@ -1,88 +0,0 @@ - 'projectionauthority', - '#type' => 'textfield', - '#weight' => 1, - '#title' => t('Projection Authority'), - '#default_value' => $projectionData->authority, - '#description' => t('Authority defining the projection'), - '#required' => TRUE - ); - $form['info']['code'] = array( - '#id' => 'projectioncode', - '#type' => 'textfield', - '#weight' => 2, - '#title' => t('Projection Code'), - '#default_value' => $projectionData->code, - '#description' => t('Identifier (unique within authority)'), - '#required' => TRUE - ); - $form['info']['definition'] = array( - '#id' => 'projectiondefinition', - '#type' => 'textarea', - '#weight' => 3, - '#title' => t('proj4 Definition'), - '#default_value' => $projectionData->definition, - '#description' => t('Description that can be used to handle rough conversions between coordinate systems. A correct definition is essential for coordinate displays or scale bars to work properly.'), - '#required' => TRUE - ); - $form['info']['projectedextentleft'] = array( - '#id' => 'projectionprojectedextentleft', - '#type' => 'textfield', - '#weight' => 4, - '#title' => t('Left Extent Boundary'), - '#default_value' => $projectionData->projectedextentleft, - '#description' => t("Leftmost value in this projection's coordinates"), - '#required' => TRUE - ); - $form['info']['projectedextentbottom'] = array( - '#id' => 'projectionprojectedextentbottom', - '#type' => 'textfield', - '#weight' => 5, - '#title' => t('Bottom Extent Boundary'), - '#default_value' => $projectionData->projectedextentbottom, - '#description' => t("Bottommost value in this projection's coordinates"), - '#required' => TRUE - ); - $form['info']['projectedextentright'] = array( - '#id' => 'projectionprojectedextentright', - '#type' => 'textfield', - '#weight' => 6, - '#title' => t('Right Extent Boundary'), - '#default_value' => $projectionData->projectedextentright, - '#description' => t("Rightmost value in this projection's coordinates"), - '#required' => TRUE - ); - $form['info']['projectedextenttop'] = array( - '#id' => 'projectionprojectedextenttop', - '#type' => 'textfield', - '#weight' => 7, - '#title' => t('Top Extent Boundary'), - '#default_value' => $projectionData->projectedextenttop, - '#description' => t("Topmost value in this projection's coordinates"), - '#required' => TRUE - ); - } - - function edit_form_submit(&$form, &$form_state) { - // Fill identifier with data from required fields. No empty string must result as ctools can't handle it. - $form_state['values']['identifier'] = $form_state['values']['authority'].':'.$form_state['values']['code']; - - parent::edit_form_submit($form, $form_state); - } - - function hook_menu(&$items) { - parent::hook_menu($items); - $items['admin/structure/openlayers/projections']['type'] = MENU_LOCAL_TASK; - } -} \ No newline at end of file diff --git a/modules/openlayers_ui/plugins/export_ui/openlayers_sources.inc b/modules/openlayers_ui/plugins/export_ui/openlayers_sources.inc new file mode 100644 index 0000000000000000000000000000000000000000..57e408558722be500e8a09d433546f524efd2a57 --- /dev/null +++ b/modules/openlayers_ui/plugins/export_ui/openlayers_sources.inc @@ -0,0 +1,118 @@ + 'openlayers_sources', + 'access' => 'administer openlayers', + 'menu' => array( + 'menu prefix' => 'admin/structure/openlayers', + 'menu item' => 'sources', + 'menu title' => 'Sources', + 'menu description' => 'Administer OpenLayers sources.', + ), + + 'handler' => array( + 'class' => 'openlayers_sources_ui', + 'parent' => 'ctools_export_ui' + ), + + 'export' => array( + 'admin_title' => 'name', + 'admin_description' => 'description', + ), + + 'use wizard' => TRUE, + 'form info' => array( + 'order' => array( + 'start' => t('Administrative settings'), + 'second' => t('Source type'), + 'third' => t('Source type options'), + ), + 'forms' => array( + 'start' => array( + 'form id' => 'openlayers_source_form_start' + ), + 'second' => array( + 'form id' => 'openlayers_source_form_second' + ), + 'third' => array( + 'form id' => 'openlayers_source_form_third' + ), + ) + ), + + + 'title singular' => t('source'), + 'title plural' => t('sources'), + 'title singular proper' => t('OpenLayers source preset'), + 'title plural proper' => t('OpenLayers sources presets'), + + 'strings' => array( + 'confirmation' => array( + 'add' => array( + 'success' => t('Source saved.'), + ), + 'delete' => array( + 'success' => t('Source was deleted.'), + ) + ) + ), + ); +} + +function openlayers_source_form_start($form, &$form_state) { + $class = new ctools_export_ui(); + $class->init($form_state['plugin']); + $class->edit_form($form, $form_state); + return $form; +} + +function openlayers_source_form_start_validate($form, &$form_state) { + $class = new ctools_export_ui(); + $class->init($form_state['plugin']); + $class->edit_form_validate($form, $form_state); +} + +function openlayers_source_form_start_submit($form, &$form_state) { + $class = new ctools_export_ui(); + $class->init($form_state['plugin']); + $class->edit_form_submit($form, $form_state); +} + +function openlayers_source_form_second($form, &$form_state) { + $sources = ctools_get_plugins('openlayers', 'source'); + $options = array('' => t('')); + foreach ($sources as $class => $plugin) { + $options[$class] = $class; + } + + $form['class'] = array( + '#type' => 'select', + '#title' => t('Source Type'), + '#default_value' => isset($form_state['item']->class) ? $form_state['item']->class: '', + '#description' => t('Select the type of source.'), + '#options' => $options, + '#required' => TRUE + ); + + return $form; +} + +function openlayers_source_form_second_submit($form, &$form_state) { + $form_state['item']->class = $form_state['values']['class']; +} + + +function openlayers_source_form_third($form, &$form_state) { + $source = openlayer_object_factory_create('source', $form_state['item']->class, $form_state['item']); + $form['options'] = $source->options_form(); + $form['options']['#tree'] = TRUE; + + return $form; +} +function openlayers_source_form_third_submit($form, &$form_state) { + $form_state['item']->options = array_replace_recursive((array) $form_state['item']->options, $form_state['values']['options']); +} diff --git a/modules/openlayers_ui/plugins/export_ui/openlayers_sources_ui.class.php b/modules/openlayers_ui/plugins/export_ui/openlayers_sources_ui.class.php new file mode 100644 index 0000000000000000000000000000000000000000..27b733bf3df2f8b1f76e8ce8d043cb2a0c9fbed2 --- /dev/null +++ b/modules/openlayers_ui/plugins/export_ui/openlayers_sources_ui.class.php @@ -0,0 +1,92 @@ +plugin['export']['admin_title'])) { + $header[] = array('data' => t('Name'), 'class' => array('ctools-export-ui-title')); + } + + $header[] = array('data' => t('Machine name'), 'class' => array('ctools-export-ui-name')); + $header[] = array('data' => t('Class'), 'class' => array('ctools-export-ui-class')); + $header[] = array('data' => t('Storage'), 'class' => array('ctools-export-ui-storage')); + $header[] = array('data' => t('Operations'), 'class' => array('ctools-export-ui-operations')); + + return $header; + } + + /** + * Build a row based on the item. + * + * By default all of the rows are placed into a table by the render + * method, so this is building up a row suitable for theme('table'). + * This doesn't have to be true if you override both. + */ + function list_build_row($item, &$form_state, $operations) { + // Set up sorting + $name = $item->{$this->plugin['export']['key']}; + $schema = ctools_export_get_schema($this->plugin['schema']); + + // Note: $item->{$schema['export']['export type string']} should have already been set up by export.inc so + // we can use it safely. + switch ($form_state['values']['order']) { + case 'disabled': + $this->sorts[$name] = empty($item->disabled) . $name; + break; + case 'title': + $this->sorts[$name] = $item->{$this->plugin['export']['admin_title']}; + break; + case 'name': + $this->sorts[$name] = $name; + break; + case 'class': + $this->sorts[$name] = $name; + break; + case 'storage': + $this->sorts[$name] = $item->{$schema['export']['export type string']} . $name; + break; + } + + $this->rows[$name]['data'] = array(); + $this->rows[$name]['class'] = !empty($item->disabled) ? array('ctools-export-ui-disabled') : array('ctools-export-ui-enabled'); + + // If we have an admin title, make it the first row. + if (!empty($this->plugin['export']['admin_title'])) { + $this->rows[$name]['data'][] = array('data' => check_plain($item->{$this->plugin['export']['admin_title']}), 'class' => array('ctools-export-ui-title')); + } + $this->rows[$name]['data'][] = array('data' => check_plain($name), 'class' => array('ctools-export-ui-name')); + $this->rows[$name]['data'][] = array('data' => check_plain($item->class), 'class' => array('ctools-export-ui-class')); + $this->rows[$name]['data'][] = array('data' => check_plain($item->{$schema['export']['export type string']}), 'class' => array('ctools-export-ui-storage')); + + $ops = theme('links__ctools_dropbutton', array('links' => $operations, 'attributes' => array('class' => array('links', 'inline')))); + + $this->rows[$name]['data'][] = array('data' => $ops, 'class' => array('ctools-export-ui-operations')); + + // Add an automatic mouseover of the description if one exists. + if (!empty($this->plugin['export']['admin_description'])) { + $this->rows[$name]['title'] = $item->{$this->plugin['export']['admin_description']}; + } + } + + + +} diff --git a/modules/openlayers_ui/plugins/export_ui/openlayers_styles.inc b/modules/openlayers_ui/plugins/export_ui/openlayers_styles.inc deleted file mode 100644 index 6fdfc16445155f0f9d115865fbc2a2eca82ff1ce..0000000000000000000000000000000000000000 --- a/modules/openlayers_ui/plugins/export_ui/openlayers_styles.inc +++ /dev/null @@ -1,42 +0,0 @@ - 'openlayers_styles', - 'access' => 'administer openlayers', - 'menu' => array( - 'menu prefix' => 'admin/structure/openlayers', - 'menu item' => 'styles', - 'menu title' => 'Styles', - 'menu description' => 'Administer OpenLayers Styles presets.', - ), - - 'handler' => array( - 'class' => 'openlayers_styles_ui', - ), - - 'export' => array( - 'admin_title' => 'name', - 'admin_description' => 'description', - ), - - 'title singular' => t('style'), - 'title plural' => t('styles'), - 'title singular proper' => t('OpenLayers Style preset'), - 'title plural proper' => t('OpenLayers Styles presets'), - - 'strings' => array( - 'confirmation' => array( - 'add' => array( - 'success' => t('Style saved.'), - ), - 'delete' => array( - 'success' => t('Style was deleted.'), - ) - ) - ), - ); -} diff --git a/modules/openlayers_ui/plugins/export_ui/openlayers_styles_ui.class.php b/modules/openlayers_ui/plugins/export_ui/openlayers_styles_ui.class.php deleted file mode 100644 index 99f41530d35cf65dc24774d10940c5a0f37dcc19..0000000000000000000000000000000000000000 --- a/modules/openlayers_ui/plugins/export_ui/openlayers_styles_ui.class.php +++ /dev/null @@ -1,472 +0,0 @@ -name)) { - $style = NULL; - } - - module_load_include('inc', 'openlayers_ui', 'includes/openlayers_ui.styles'); - - $properties = array( - 'externalGraphic' => array( - 'default' => '', - 'desc' => t('The URL of an icon for points in a layer. The following options are available: -
  • Full path, such as http://example.com/icon.png
  • -
  • Relative Drupal path, such as sites/all/modules/example/icon.png
  • -
  • Absolute path, such as /icon.png (though this is not suggested for maintainability reasons)
'), - 'maxlength' => 2083 - ), - 'backgroundGraphic' => array( - 'default' => '', - 'desc' => t('Url to a graphic to be used as the background under an externalGraphic.'), - 'maxlength' => 2083 - ), - 'backgroundGraphicZIndex' => array( - 'default' => '', - 'desc' => t('The integer z-index value to use in rendering the background graphic.'), - ), - 'backgroundXOffset' => array( - 'default' => '', - 'desc' => t('The x offset (in pixels) for the background graphic.'), - ), - 'backgroundYOffset' => array( - 'default' => '', - 'desc' => t('The y offset (in pixels) for the background graphic.'), - ), - 'backgroundHeight' => array( - 'default' => '', - 'desc' => t('The height of the background graphic. If not provided, the graphicHeight will be used.'), - ), - 'backgroundWidth' => array( - 'default' => '', - 'desc' => t('The width of the background width. If not provided, the graphicWidth will be used.'), - ), - 'pointRadius' => array( - 'default' => 6, - 'desc' => t('The radius of a vector point or the size of - an icon. Note that, when using icons, this value should be half the - width of the icon image.'), - ), - 'fillColor' => array( - 'default' => '#EE9900', - 'desc' => t('This is the color used for - filling in Polygons. It is also used in the center of marks for - points: the interior color of circles or other shapes. It is - not used if an externalGraphic is applied to a point. This should be - a hexadecimal value like #FFFFFF.'), - ), - 'fillOpacity' => array( - 'default' => 1, - 'desc' => t('This is the opacity used for filling in Polygons. - It is also used in the center of marks for points: the interior - color of circles or other shapes. It is not used if an - externalGraphic is applied to a point. This should be a value - between 0 and 1.'), - ), - 'strokeColor' => array( - 'default' => '#EE9900', - 'desc' => t('This is color of the line on features. On - polygons and point marks, it is used as an outline to the feature. - On lines, this is the representation of the feature. This should be - a hexadecimal value like #FFFFFF.'), - ), - 'strokeWidth' => array( - 'default' => 1, - 'desc' => t('This is width of the line on features. On - polygons and point marks, it is used as an outline to - the feature. On lines, this is the representation of the - feature. This is a value in pixels.'), - ), - 'strokeOpacity' => array( - 'default' => 1, - 'desc' => t('This is opacity of the line on features. - On polygons and point marks, it is used as an outline to the - feature. On lines, this is the representation of the feature. - This should be a value between 0 and 1.'), - ), - 'strokeLinecap' => array( - 'default' => 'round', - 'desc' => t('Options are butt, round, square. This property - is similar to the SVG stroke-linecap property. It determines - what the end of lines should look like. See the SVG link for - image examples.'), - 'options' => array( - 'butt' => t('Butt'), - 'round' => t('Round'), - 'square' => t('Square'), - ), - ), - 'strokeDashstyle' => array( - 'default' => 'solid', - 'desc' => t('Options are dot, dash, dashdot, longdash, longdashdot, solid.'), - 'options' => array( - 'dot' => t('Dot'), - 'dash' => t('Dash'), - 'dashdot' => t('Dash-dot'), - 'longdash' => t('Long-dash'), - 'longdashdot' => t('Long-dash-dot'), - 'solid' => t('Solid'), - ), - ), - 'cursor' => array( - 'default' => '', - 'desc' => t('Cursor used when mouse is over the feature. Default - is an empty string, which inherits from parent elements. See - CSS cursor styles.', array( - '!url' => 'http://www.w3schools.com/css/pr_class_cursor.asp', - )), - ), - 'graphicWidth' => array( - 'default' => '', - 'desc' => t('This properties define the width of an externalGraphic. - This is an alternative to the pointRadius symbolizer property - to be used when your graphic has different sizes in the X and - Y direction. This should be in pixels.'), - ), - 'graphicHeight' => array( - 'default' => '', - 'desc' => t('This properties define the height of an externalGraphic. - This is an alternative to the pointRadius symbolizer property - to be used when your graphic has different sizes in the X and - Y direction. This should be in pixels.'), - ), - 'graphicOpacity' => array( - 'default' => '1', - 'desc' => t('Opacity of an external graphic. This should be a - value between 0 and 1. Graphics that are already semitransparent, - like alpha PNGs, should have this set to 1, or rendering problems in - Internet Explorer will ensue.'), - ), - 'graphicXOffset' => array( - 'default' => '', - 'desc' => t('Where the X value of the "center" of an - externalGraphic should be. This should be in pixels.'), - ), - 'graphicYOffset' => array( - 'default' => '', - 'desc' => t('Where the Y value of the "center" of an - externalGraphic should be. This should be in pixels.'), - ), - 'graphicName' => array( - 'default' => '', - 'desc' => t('Name of a type of symbol to be used - for a point mark.'), - ), - 'graphicZIndex' => array( - 'default' => '', - 'desc' => t('The integer z-index value to use in rendering.'), - ), - 'rotation' => array( - 'default' => '', - 'desc' => t('The rotation angle in degrees clockwise for - a point symbolizer.'), - ), - 'display' => array( - 'default' => '', - 'desc' => t('Can be set to "none" to hide features - from rendering.'), - 'options' => array( - '' => t('On'), - 'none' => t('None (off)'), - ), - ), - 'title' => array( - 'default' => '', - 'desc' => t('Tooltip when hovering over a feature. Not supported by the canvas renderer.') - ), - 'label' => array( - 'default' => '', - 'desc' => t('The text for an optional label. For browsers that use the canvas renderer, this requires either fillText or mozDrawText to be available. Typically used with ${attribute} syntax.') - ), - 'labelAlign' => array( - 'default' => 'cm', - 'desc' => t('Label alignment.'), - 'options' => array( - 'cm' => t('Center, middle'), - 'ct' => t('Center, top'), - 'cb' => t('Center, bottom'), - 'lm' => t('Left, middle'), - 'lt' => t('Left, top'), - 'lb' => t('Left, bottom'), - 'rm' => t('Right, middle'), - 'rt' => t('Right, top'), - 'rb' => t('Right, bottom'), - ), - ), - 'labelXOffset' => array( - 'default' => '', - 'desc' => t('Label X offset. Positive numbers move label right.'), - ), - 'labelYOffset' => array( - 'default' => '', - 'desc' => t('Label Y offset. Positive numbers move label up.'), - ), - 'fontColor' => array( - 'default' => '', - 'desc' => t('The font color for the label, to be provided like CSS.'), - ), - 'fontOpacity' => array( - 'default' => '', - 'desc' => t('Opacity (0-1) for the label'), - ), - 'fontFamily' => array( - 'default' => '', - 'desc' => t('The font family for the label, to be provided like in CSS.'), - ), - 'fontSize' => array( - 'default' => '', - 'desc' => t('The font size for the label, to be provided like in CSS.'), - ), - 'fontStyle' => array( - 'default' => '', - 'desc' => t('The font style for the label, to be provided like in CSS.'), - ), - 'fontWeight' => array( - 'default' => '', - 'desc' => t('The font weight for the label, to be provided like in CSS.'), - ), - ); - - $form['info']['title'] = array( - '#id' => 'styletitle', - '#type' => 'textfield', - '#weight' => -1, - '#title' => t('Style title'), - '#default_value' => isset($style->title) ? $style->title : '', - '#description' => t('The friendly name of your style, which will appear in the administration interface as well on the map interface.'), - ); - $form['info']['name']['#machine_name']['source'] = array('info', 'title'); - - $fields = array(); - $views = views_get_all_views(); - foreach($views as $vid => $view) { - if (isset($view->display)) { - foreach ($view->display as $vdid => $display) { - if (isset($display->display_options)) { - if (isset($display->display_options['style_plugin'])) { - if ($display->display_options['style_plugin'] == 'openlayers_data') { - foreach ($display->display_options['fields'] as $fid => $fdata) { - $fields[] = t('@fid (from view @viewname and display @displayname.)', array('@fid' => '${' . $fid . '}', '@viewname' => $view->name, '@displayname' => $vdid)); - } - } - } - } - } - } - } - - $form['available_fields'] = array( - '#type' => 'fieldset', - '#tree' => TRUE, - '#collapsible' => TRUE, - '#collapsed' => TRUE, - '#title' => t('Available fields to use as token'), - '#description' => t('Notice: Since OpenLayers beta 9, the rendering of - . the fields has changed, it\'s not using the raw value of the field, - . but the full row rendering. You must disable all the HTML element by - . selecting None in the Style setting fieldset of the field in Views or - . you might get a mix of HTML with the raw value of the field.'), - ); - - if ($fields) { - $form['available_fields']['fields'] = array( - '#markup' => theme('item_list', array('items' => $fields)), - ); - } - else { - $form['available_fields']['fields'] = array( - '#prefix' => '

', - '#markup' => t('There are no available fields to use as tokens.'), - '#suffix' => '

', - ); - - $form['available_fields']['fields_instruction'] = array( - '#access' => user_access('administer views'), - '#prefix' => '

', - '#markup' => t( - 'Go to the Views administration page and create an "OpenLayers Data Overlay" display.', - array( - '!attributes' => drupal_attributes(array('href' => url('admin/structure/views'))), - ) - ), - '#suffix' => '

', - ); - } - - // OpenLayers style properties - $form['data'] = array( - '#type' => 'fieldset', - '#tree' => TRUE, - '#title' => t('Style Properties'), - '#description' => t('The specific properties for the style.'), - ); - foreach ($properties as $key => $prop) { - $form['data'][$key] = array( - '#type' => !isset($prop['options']) ? 'textfield' : 'select', - '#title' => !isset($prop['title']) ? check_plain($key) : check_plain($prop['title']), - '#description' => filter_xss($prop['desc']), - '#default_value' => isset($style->data[$key]) ? - $style->data[$key] : $prop['default'], - '#element_validate' => isset($prop['element_validate']) ? - $prop['element_validate'] : array(), - '#element_validate' => isset($prop['element_validate']) ? - $prop['element_validate'] : array() ); - - // Add options if needed - if (isset($prop['options']) && is_array($prop['options'])) { - $form['data'][$key]['#options'] = $prop['options']; - } - // Add maxlength if needed - if (isset($prop['maxlength']) && is_numeric($prop['maxlength'])) { - $form['data'][$key]['#maxlength'] = $prop['maxlength']; - } - } - - // Add preview button. - $form['buttons']['preview'] = array( - '#type' => 'button', - '#value' => t('Preview'), - ); - - } - - function edit_form_validate(&$form, &$form_state) {} - - /** - * Prepare the tag values before they are added to the database. - */ - function edit_form_submit(&$form, &$form_state) { - // Cast and unset values so JS can handle them better, - // Unless values are in the form ${attribute} - foreach ($form_state['values']['data'] as $key => $value) { - if (is_numeric($form_state['values']['data'][$key])) { - $form_state['values']['data'][$key] = (float) $form_state['values']['data'][$key]; - } - if (empty($form_state['values']['data'][$key])) { - unset($form_state['values']['data'][$key]); - } - } - - parent::edit_form_submit($form, $form_state); - } - - /** - * Build a row based on the item. - * - * By default all of the rows are placed into a table by the render - * method, so this is building up a row suitable for theme('table'). - * This doesn't have to be true if you override both. - */ - function list_build_row($item, &$form_state, $operations) { - // Set up sorting - $name = $item->{$this->plugin['export']['key']}; - $schema = ctools_export_get_schema($this->plugin['schema']); - - // Note: $item->{$schema['export']['export type string']} should have already been set up by export.inc so - // we can use it safely. - switch ($form_state['values']['order']) { - case 'disabled': - $this->sorts[$name] = empty($item->disabled) . $name; - break; - case 'title': - $this->sorts[$name] = $item->{$this->plugin['export']['admin_title']}; - break; - case 'name': - $this->sorts[$name] = $name; - break; - case 'storage': - $this->sorts[$name] = $item->{$schema['export']['export type string']} . $name; - break; - } - - $this->rows[$name]['data'] = array(); - $this->rows[$name]['class'] = !empty($item->disabled) ? array('ctools-export-ui-disabled') : array('ctools-export-ui-enabled'); - - $this->rows[$name]['data'][] = array('data' => openlayers_ui_style_preview($item), 'class' => array('ctools-export-ui-preview')); - - // If we have an admin title, make it the first row. - if (!empty($this->plugin['export']['admin_title'])) { - $this->rows[$name]['data'][] = array('data' => check_plain($item->{$this->plugin['export']['admin_title']}), 'class' => array('ctools-export-ui-admin-title')); - } - - $this->rows[$name]['data'][] = array('data' => $item->title, 'class' => array('ctools-export-ui-title')); - $this->rows[$name]['data'][] = array('data' => $item->description, 'class' => array('ctools-export-ui-description')); - $this->rows[$name]['data'][] = array('data' => check_plain($item->{$schema['export']['export type string']}), 'class' => array('ctools-export-ui-storage')); - - $ops = theme('links__ctools_dropbutton', array('links' => $operations, 'attributes' => array('class' => array('links', 'inline')))); - - $this->rows[$name]['data'][] = array('data' => $ops, 'class' => array('ctools-export-ui-operations')); - - // Add an automatic mouseover of the description if one exists. - if (!empty($this->plugin['export']['admin_description'])) { - $this->rows[$name]['title'] = $item->{$this->plugin['export']['admin_description']}; - } - } - - - /** - * Provide the table header. - * - * If you've added columns via list_build_row() but are still using a - * table, override this method to set up the table header. - */ - function list_table_header() { - $header = array(); - - $header[] = array('data' => t('Preview'), 'class' => array('ctools-export-ui-preview')); - if (!empty($this->plugin['export']['admin_title'])) { - $header[] = array('data' => t('Name'), 'class' => array('ctools-export-ui-name')); - } - $header[] = array('data' => t('Title'), 'class' => array('ctools-export-ui-title')); - $header[] = array('data' => t('Description'), 'class' => array('ctools-export-ui-description')); - $header[] = array('data' => t('Storage'), 'class' => array('ctools-export-ui-storage')); - $header[] = array('data' => t('Operations'), 'class' => array('ctools-export-ui-operations')); - - return $header; - } - - /** - * hook_menu() entry point. - * - * Child implementations that need to add or modify menu items should - * probably call parent::hook_menu($items) and then modify as needed. - */ - function hook_menu(&$items) { - parent::hook_menu($items); - $items['admin/structure/openlayers/styles']['type'] = MENU_LOCAL_TASK; - } - - /** - * Provide a list of sort options. - * - * Override this if you wish to provide more or change how these work. - * The actual handling of the sorting will happen in build_row(). - */ - function list_sort_options() { - if (!empty($this->plugin['export']['admin_title'])) { - $options = array( - 'disabled' => t('Enabled, title'), - $this->plugin['export']['admin_title'] => t('Title'), - ); - } - else { - $options = array( - 'disabled' => t('Enabled, title'), - ); - } - - $options += array( - 'storage' => t('Storage'), - ); - - return $options; - } -} diff --git a/modules/openlayers_ui/themes/openlayers-ui-styles-preview.tpl.php b/modules/openlayers_ui/themes/openlayers-ui-styles-preview.tpl.php deleted file mode 100644 index c1f4f865a75b5e5584afb299f5b6b20163b39681..0000000000000000000000000000000000000000 --- a/modules/openlayers_ui/themes/openlayers-ui-styles-preview.tpl.php +++ /dev/null @@ -1 +0,0 @@ -
diff --git a/modules/openlayers_views/includes/openlayers_views.theme.inc b/modules/openlayers_views/includes/openlayers_views.theme.inc deleted file mode 100644 index 8f0b3082e5d5871623ec3b232f83a9cc81dcb909..0000000000000000000000000000000000000000 --- a/modules/openlayers_views/includes/openlayers_views.theme.inc +++ /dev/null @@ -1,32 +0,0 @@ -' - . $args['name'] - . '' : '') . - (!empty($args['description']) ? - '
' - . $args['description'] - . '
' : ''); -} - -/** - * Theme function for openlayers_views_render_feature - */ -function theme_openlayers_views_render_feature($args) { - return $args['feature']; -} diff --git a/modules/openlayers_views/openlayers_views.info b/modules/openlayers_views/openlayers_views.info deleted file mode 100644 index 1072afd8615862cb9d2f08da8aa57fec3a3a8fcb..0000000000000000000000000000000000000000 --- a/modules/openlayers_views/openlayers_views.info +++ /dev/null @@ -1,19 +0,0 @@ -name = OpenLayers Views -description = Provides OpenLayers Views plugins. -core = 7.x -package = OpenLayers -dependencies[] = openlayers -dependencies[] = views -dependencies[] = geophp -; Core files -files[] = openlayers_views.module -files[] = views/openlayers_views.views.inc -files[] = views/openlayers_views_style_map.inc -files[] = views/openlayers_views_style_data.inc -files[] = views/openlayers_views_style_data_image.inc -files[] = views/openlayers_views_plugin_display_openlayers.inc -files[] = views/openlayers_views_plugin_row_point.inc -files[] = views/openlayers_views_plugin_row_bounding_box.inc -files[] = views/openlayers_views_plugin_row_geometry.inc -files[] = plugins/layer_types/openlayers_views_vector.inc -files[] = plugins/layer_types/openlayers_views_image.inc diff --git a/modules/openlayers_views/openlayers_views.install b/modules/openlayers_views/openlayers_views.install deleted file mode 100644 index 62b9c71d166a8ff82f571269838941382fa536c2..0000000000000000000000000000000000000000 --- a/modules/openlayers_views/openlayers_views.install +++ /dev/null @@ -1,23 +0,0 @@ -' - . t('The OpenLayers Views module provides a set of plugins ' - . 'for Views.') - . '

'; - } -} - -/** - * Implements hook_theme(). - */ -function openlayers_views_theme($existing, $type, $theme, $path) { - return array( - 'openlayers_views_group_display_item' => array( - 'arguments' => array( - 'name' => '', - 'description' => '', - ), - 'file' => 'includes/openlayers_views.theme.inc', - ), - 'openlayers_views_render_feature' => array( - 'arguments' => array( - 'feature' => '', - 'record' => '', - ), - 'file' => 'includes/openlayers_views.theme.inc', - ), - 'openlayers_image_formatter' => array( - 'variables' => array( - 'item' => NULL, - 'node' => NULL, - 'field' => array(), - 'display_settings' => array(), - ), - 'file' => 'views/openlayers_views.views.theme.inc', - ), - 'openlayers_views_map' => array( - 'arguments' => array( - 'map' => array(), - 'title' => '', - ), - 'file' => 'views/openlayers_views.views.theme.inc', - ), - ); -} - -/** - * Implements hook_views_api(). - */ -function openlayers_views_views_api() { - return array( - 'api' => 3, - 'path' => drupal_get_path('module', 'openlayers_views') .'/views', - ); -} - -/** - * Implements hook_ctools_plugin_directory(). - */ -function openlayers_views_ctools_plugin_directory($module, $plugin) { - if ($module == 'openlayers' && !empty($plugin)) { - return 'plugins/' . $plugin; - } -} - -/** - * Implements hook_ctools_plugin_api(). - */ -function openlayers_views_ctools_plugin_api($module, $api) { - if ($module == "openlayers") { - switch ($api) { - case 'openlayers_layers': - return array('version' => 1); - } - } -} - -/** - * Implements hook_openlayers_layers(). - */ -function openlayers_views_openlayers_layers() { - $layers = array(); - - // Attempt to load information from cache. - // For now use a arg based check for skipping cache. - if (arg(0) != 'admin') { - $cache = cache_get('openlayers_views'); - if (isset($cache->data)) { - return $cache->data; - } - } - - $views = views_get_all_views(); - - // Provide each OpenLayers Data display as a layer - foreach ($views as $view) { - foreach ($view->display as $display => $data) { - $view->set_display($display); - - // Check for OpenLayers Data Overlays - if ($view->display_handler->get_option('style_plugin') == 'openlayers_data' && $display != 'default') { - //Build Layer - $layer = new openlayers_layer_type_openlayers_views_vector(); - $layer->api_version = 1; - $layer->name = $view->name . '_' . $display; - $layer->title = empty($data->display_options['title']) ? $view->name : $data->display_options['title']; - $layer->title .= ' - ' . $data->display_title; - $layer->description = $view->description; - $layer->data['views'] = array('view' => $view->name, 'display' => $display); - $layers[$layer->name] = $layer; - } - - // Check for OpenLayers Data Image Overlays - if ($view->display_handler->get_option('style_plugin') == 'openlayers_data_image' && $display != 'default') { - //Build Layer - $layer = new openlayers_layer_type_openlayers_views_image(); - $layer->api_version = 1; - $layer->name = $view->name . '_' . $display; - $layer->title = empty($data->display_options['title']) ? $view->name : $data->display_options['title']; - $layer->title .= ' - ' . $data->display_title; - $layer->description = $view->description; - $layer->data['views'] = array('view' => $view->name, 'display' => $display); - $layers[$layer->name] = $layer; - } - - // Make GeoJSON layers from the views_geojson module - if ($view->display_handler->get_option('style_plugin') == 'views_geojson' && - $view->display_handler->display->display_plugin == 'page' && - $view->display_handler->get_option('path') != '' - ) { - $layer = new openlayers_layer_type_geojson(); - $layer->api_version = 1; - $layer->name = $view->name . '_' . $display; - $layer->title = empty($data->display_options['title']) ? $view->name : $data->display_options['title']; - $layer->title .= ' - ' . $data->display_title; - $layer->description = $view->description; - - // Determine if we should use a BBOX strategy. - $useBBOX = FALSE; - if (isset($data->display_options['arguments']) && - isset($data->display_options['arguments']['bbox_argument']) && - $view->data->display_options['arguments']['bbox_argument']['arg_id'] == 'bbox') { - $useBBOX = TRUE; - } - - $layer->data['url'] = url($view->display_handler->get_option('path'), array('absolute' => TRUE)); - $layer->data['geojson_data'] = ''; - $layer->data['views'] = array('view' => $view->name, 'display' => $display); - $layer->data['useBBOX'] = $useBBOX; - - $layers[$layer->name] = $layer; - } - } - $view->destroy(); - } - cache_set('openlayers_views', $layers); - return $layers; -} diff --git a/modules/openlayers_views/plugins/layer_types/openlayers_views_image.inc b/modules/openlayers_views/plugins/layer_types/openlayers_views_image.inc deleted file mode 100644 index 978d2c80991f2387d7362633701252d3ade98c40..0000000000000000000000000000000000000000 --- a/modules/openlayers_views/plugins/layer_types/openlayers_views_image.inc +++ /dev/null @@ -1,136 +0,0 @@ - t('OpenLayers Views Image'), - 'description' => t('OpenLayers Views Image'), - 'layer_type' => array( - 'file' => 'openlayers_views_image.inc', - 'class' => 'openlayers_layer_type_openlayers_views_image', - 'parent' => 'openlayers_layer_type', - ), - ); -} - -class openlayers_layer_type_openlayers_views_image - extends openlayers_layer_type { - /** - * Provide initial values for options. - */ - function options_init() { - return array( - 'layer_type' => 'openlayers_views_image', - 'layer_handler' => 'image', - 'projection' => array('EPSG:3857'), - 'isBaseLayer' => TRUE, - 'vector' => FALSE, - 'type' => 'image', - 'url' => array(), - 'options' => array(), - 'events' => array(), - 'views' => array(), - ); - } - - /** - * Options form which generates layers - */ - function options_form($defaults = array()) { - $form = array(); - - $views = views_get_all_views(); - - $options = array('' => ''); - foreach ($views as $view) { - foreach ($view->display as $display => $data) { - $view->set_display($display); - if ($data->display_plugin == 'openlayers' && ($view->display_handler->get_option('style_plugin') == 'openlayers_data_image')) {; - $options[$view->name . '::' . $display] = $view->human_name . ': ' . $display; - } - } - } - - $default = NULL; - if (isset($this->data['views']['view']) && isset($this->data['views']['display'])) { - $default = $this->data['views']['view'] . '::' . $this->data['views']['display']; - } - - $form['views']['composite'] = array( - '#type' => 'select', - '#options' => $options, - '#title' => 'View name', - '#default_value' => isset($default) ? - $default : '', - ); - return $form; - } - - function options_form_validate($form, &$form_state) { - if (!empty($form_state['data']['views']['composite'])) { - list($view, $display) = explode('::', $form_state['data']['views']['composite']); - $form_state['data']['views']['view'] = $view; - $form_state['data']['views']['display'] = $display; - unset($form_state['data']['views']['composite']); - } - else { - $field = $form_state['data']['layer_type'] . '][views][composite'; - form_set_error($field, t('A View must be set.')); - } - } - - function get_features() { - if ($view = views_get_view($this->data['views']['view'])) { - $args = array(); - // Retrieve args/filters from current view - // to pass on to our vector layer. - $current_view = views_get_current_view(); - if (!empty($current_view)) { - $args = $current_view->args; - if (isset($current_view->exposed_input)) { - $view->set_exposed_input($current_view->exposed_input); - } - } - - if (isset($this->data['views']['arguments'])) { - $args = $this->data['views']['arguments']; - } - - $features = $view->execute_display($this->data['views']['display'], $args); - - // Get dynamic title from view - $this->title = $view->get_title(); - - $view->destroy(); - } - - if (is_array($features)) { - $this->data = array_merge($this->data, $features); - } else { - $this->data['layer_type'] = 'openlayers_layer_type_dummy'; - $this->data['layer_handler'] = 'dummy'; - } - - return $this->data; - } - - /** - * Render. - */ - function render(&$map) { - if ($this->data['layer_handler'] == 'dummy') { - drupal_add_js(drupal_get_path('module', 'openlayers') . - '/plugins/layer_types/openlayers_layer_type_dummy.js'); - } else { - drupal_add_js(drupal_get_path('module', 'openlayers') . - '/plugins/layer_types/openlayers_layer_type_image.js'); - } - return $this->get_features(); - } -} diff --git a/modules/openlayers_views/plugins/layer_types/openlayers_views_vector.inc b/modules/openlayers_views/plugins/layer_types/openlayers_views_vector.inc deleted file mode 100644 index bafab69feeaa03f21d05504fdf956cabf9df78ad..0000000000000000000000000000000000000000 --- a/modules/openlayers_views/plugins/layer_types/openlayers_views_vector.inc +++ /dev/null @@ -1,146 +0,0 @@ - t('OpenLayers Views'), - 'description' => t('OpenLayers Views Vector'), - 'layer_type' => array( - 'file' => 'openlayers_views_vector.inc', - 'class' => 'openlayers_layer_type_openlayers_views_vector', - 'parent' => 'openlayers_layer_type', - ), - ); -} - -class openlayers_layer_type_openlayers_views_vector - extends openlayers_layer_type { - /** - * Provide initial values for options. - */ - function options_init() { - return array( - 'layer_handler' => 'openlayers_views_vector', - 'layer_type' => 'openlayers_views_vector', - 'projection' => array('EPSG:4326'), - 'isBaseLayer' => FALSE, - 'vector' => TRUE, - 'type' => 'Vector', - 'url' => array(), - 'options' => array( - 'rendererOptions' => array( - 'yOrdering' => TRUE - ) - ), - 'events' => array(), - 'views' => array(), - ); - } - - /** - * Options form which generates layers - */ - function options_form($defaults = array()) { - $form = array(); - - $views = views_get_all_views(); - - $options = array('' => ''); - foreach ($views as $view) { - foreach ($view->display as $display => $data) { - $view->set_display($display); - if ($data->display_plugin == 'openlayers' && ($view->display_handler->get_option('style_plugin') == 'openlayers_data')) {; - $options[$view->name . '::' . $display] = $view->human_name . ': ' . $display; - } - } - } - - $default = NULL; - if (isset($this->data['views']['view']) && isset($this->data['views']['display'])) { - $default = $this->data['views']['view'] . '::' . $this->data['views']['display']; - } - - $form['views']['composite'] = array( - '#type' => 'select', - '#options' => $options, - '#title' => 'View name', - '#default_value' => isset($default) ? - $default : '', - ); - return $form; - } - - function options_form_validate($form, &$form_state) { - if (!empty($form_state['data']['views']['composite'])) { - list($view, $display) = explode('::', $form_state['data']['views']['composite']); - $form_state['data']['views']['view'] = $view; - $form_state['data']['views']['display'] = $display; - unset($form_state['data']['views']['composite']); - } - else { - $field = $form_state['data']['layer_type'] . '][views][composite'; - form_set_error($field, t('A View must be set.')); - } - } - - - /** - * Get features for this view - * - * @param $view_name - * the view name - * @param $display_name - * the view display name - * @return - * array of features - */ - function get_features() { - if ($view = views_get_view($this->data['views']['view'])) { - $args = array(); - // Retrieve args/filters from current view - // to pass on to our vector layer. - $current_view = views_get_current_view(); - if (!empty($current_view)) { - $args = $current_view->args; - if (isset($current_view->exposed_input)) { - $view->set_exposed_input($current_view->exposed_input); - } - } - - if (isset($this->data['views']['arguments'])) { - $args = $this->data['views']['arguments']; - } - - $features = $view->execute_display($this->data['views']['display'], $args); - - // Get dynamic title from view - $this->title = $view->get_title(); - - $view->destroy(); - } - - $this->data['features'] = isset($features) ? $features : array(); - return $this->data['features']; - } - - function attached() { - return array( - 'js' => array( - drupal_get_path('module', 'openlayers_views') . '/plugins/layer_types/openlayers_views_vector.js' - ) - ); - } - - /** - * Render. - */ - function render(&$map) { - $this->get_features(); - } -} diff --git a/modules/openlayers_views/plugins/layer_types/openlayers_views_vector.js b/modules/openlayers_views/plugins/layer_types/openlayers_views_vector.js deleted file mode 100644 index 17165940ddf245fc3f6a3d97bdb75f85a5c58caa..0000000000000000000000000000000000000000 --- a/modules/openlayers_views/plugins/layer_types/openlayers_views_vector.js +++ /dev/null @@ -1,29 +0,0 @@ - -/** - * OpenLayers Views Vector Layer Handler - */ -Drupal.openlayers.layer.openlayers_views_vector = function(title, map, options) { - // More explanations on this at: https://drupal.org/node/1993172#comment-7819199 - if (typeof(Drupal.settings.openlayers.maps[map.id]) !== undefined) { - Drupal.settings.openlayers.maps[map.id] = undefined; - } - - // Note, so that we do not pass all the features along to the Layer - // options, we use the options.options to give to Layer - options.options.drupalID = options.drupalID; - // Allow to set z-order of features (#2241477) - options.options.rendererOptions = {yOrdering: true}; - // Create projection - options.projection = new OpenLayers.Projection(options.projection); - // Get style map - options.options.styleMap = Drupal.openlayers.getStyleMap(map, options.drupalID); - // Create layer object - var layer = new OpenLayers.Layer.Vector(title, options.options); - - // Add features if there are any - if (options.features) { - Drupal.openlayers.addFeatures(map, layer, options.features); - } - - return layer; -}; diff --git a/modules/openlayers_views/views/openlayers_views.views.inc b/modules/openlayers_views/views/openlayers_views.views.inc deleted file mode 100644 index 7ab96ac7e2409bfb4bca9ba85af9a201a2b7e4f9..0000000000000000000000000000000000000000 --- a/modules/openlayers_views/views/openlayers_views.views.inc +++ /dev/null @@ -1,72 +0,0 @@ - 'openlayers_views', - 'display' => array( - 'openlayers' => array( - 'title' => t('OpenLayers Data Overlay'), - 'help' => t('Data layer for OpenLayers maps.'), - 'handler' => 'openlayers_views_plugin_display_openlayers', - 'path' => drupal_get_path('module', 'openlayers_views') . '/views', - 'uses hook menu' => FALSE, - 'use ajax' => FALSE, - 'use pager' => TRUE, - 'accept attachments' => FALSE, - 'admin' => t('OpenLayers Data Overlay'), - ), - ), - 'style' => array( - 'openlayers_map' => array( - 'title' => t('OpenLayers Map'), - 'help' => t('Displays a View as an OpenLayers map.'), - 'handler' => 'openlayers_views_style_map', - 'theme' => 'openlayers_views_map', - 'theme path' => drupal_get_path('module', 'openlayers_views') . '/views', - 'path' => drupal_get_path('module', 'openlayers_views') . '/views', - 'uses fields' => FALSE, - 'uses row plugin' => FALSE, - 'uses options' => TRUE, - 'uses grouping' => FALSE, - 'type' => 'normal', - 'even empty' => FALSE, - ), - 'openlayers_data' => array( - 'title' => t('OpenLayers Vector Data Overlay'), - 'help' => t('Provides Data to Power an OpenLayers map.'), - 'handler' => 'openlayers_views_style_data', - 'theme' => 'openlayers_views_data', - 'theme path' => drupal_get_path('module', 'openlayers_views') . '/views', - 'path' => drupal_get_path('module', 'openlayers_views') . '/views', - 'uses fields' => TRUE, - 'uses row plugin' => TRUE, - 'uses options' => TRUE, - 'uses grouping' => TRUE, - 'type' => 'openlayers', - 'even empty' => TRUE, - ), - 'openlayers_data_image' => array( - 'title' => t('OpenLayers Image Data Overlay'), - 'help' => t('Provides an image to use as a layer in an OpenLayers map.'), - 'handler' => 'openlayers_views_style_data_image', - 'path' => drupal_get_path('module', 'openlayers_views') . '/views', - 'uses fields' => TRUE, - 'uses row plugin' => TRUE, - 'uses options' => TRUE, - 'uses grouping' => TRUE, - 'type' => 'openlayers', - 'even empty' => TRUE, - ), - ), - ); -} diff --git a/modules/openlayers_views/views/openlayers_views.views.theme.inc b/modules/openlayers_views/views/openlayers_views.views.theme.inc deleted file mode 100644 index fc166ef73d9b07475ee5d5c18cd622e9e37bac2a..0000000000000000000000000000000000000000 --- a/modules/openlayers_views/views/openlayers_views.views.theme.inc +++ /dev/null @@ -1,18 +0,0 @@ -' . $args['title'] . '' : '') . - '
' - . $args['map'] - . '
'; -} diff --git a/modules/openlayers_views/views/openlayers_views_plugin_display_openlayers.inc b/modules/openlayers_views/views/openlayers_views_plugin_display_openlayers.inc deleted file mode 100644 index c08ed34422c9853e0772113e33d928bb7ad12d30..0000000000000000000000000000000000000000 --- a/modules/openlayers_views/views/openlayers_views_plugin_display_openlayers.inc +++ /dev/null @@ -1,47 +0,0 @@ -view->render(); - } - - function preview() { - return '
' . check_plain($this->view->render()) . '
'; - } - - function render() { - return $this->view->style_plugin->render($this->view->result); - } - - function option_definition() { - $options = parent::option_definition(); - $options['title']['translatable'] = 0; - $options['displays'] = array('default' => array()); - $options['style_plugin']['default'] = 'openlayers_data'; - $options['row_plugin']['default'] = 'fields'; - $options['defaults']['default']['row_plugin'] = FALSE; - return $options; - } - - function options_summary(&$categories, &$options) { - parent::options_summary($categories, $options); - unset($options['header']); - unset($options['footer']); - unset($options['empty']); - unset($options['exposed_block']); - unset($options['analyze-theme']); - } -} diff --git a/modules/openlayers_views/views/openlayers_views_style_data.inc b/modules/openlayers_views/views/openlayers_views_style_data.inc deleted file mode 100644 index f85e1fe83b80b05c238bc4549ce1b447e9ecc330..0000000000000000000000000000000000000000 --- a/modules/openlayers_views/views/openlayers_views_style_data.inc +++ /dev/null @@ -1,467 +0,0 @@ -render - */ - function render() { - $grouped_results = $this->render_grouping($this->view->result, $this->options['grouping']); - $data = $this->map_features($grouped_results); - - // If we are not in preview, just return the data - if (empty($this->view->live_preview)) { - return $data; - } - else { - // If we are in preview mode, dump out some useful information about this data layer - $output = "You can use the following parameters in your styles as dynamic values"; - $output .= "\n------------\n"; - if (!empty($data)) { - $keys = array_keys($data); - foreach ($data[$keys[0]]['attributes'] as $key => $value) { - $output .= '${' . $key . "}\n"; - } - } - $output .= "\n------------\n"; - - $output .= t('The following is a dump of the data that is rendered from this display. It is used for debugging purposes only.') . ' - ' . var_export($data, TRUE); - - return $output; - } - } - - /** - * Set default options - * - * Overrides views_plugin_style->option_definition - */ - function option_definition() { - $options = parent::option_definition(); - $options['data_source'] = array('default' => 'openlayers_wkt'); - return $options; - } - - /** - * Options form - * - * Overrides views_plugin_style->options_form - */ - function options_form(&$form, &$form_state) { - parent::options_form($form, $form_state); - - // Get list of fields in this view & flag available geodata fields - $handlers = $this->display->handler->get_handlers('field'); - - // Check for any fields, as the view needs them - if (empty($handlers)) { - $form['error_markup'] = array( - '#value' => t('You need to enable at least one field before you can ' - . 'configure your field settings'), - '#prefix' => '
', - '#suffix' => '
', - ); - return; - } - - $fields = array(); - foreach ($handlers as $field_id => $handler) { - $fields[$field_id] = $handler->ui_name() . ' (' . $field_id .')'; - } - - $form['data_source'] = array( - '#type' => 'fieldset', - '#tree' => TRUE, - '#title' => t('Data Source'), - '#collapsible' => TRUE, - '#collapsed' => FALSE, - ); - $form['data_source']['value'] = array( - '#type' => 'select', - '#title' => t('Map Data Sources'), - '#description' => t('Choose which sources of data that the map will ' - . 'provide features for.'), - '#options' => array( - 'other_latlon' => t('Lat/Lon Pair'), - 'other_boundingbox' => t('Bounding Box'), - 'wkt' => t('WKT') - ), - '#default_value' => $this->options['data_source']['value'], - ); - if (count($fields > 0)) { - $form['data_source']['other_lat'] = array( - '#type' => 'select', - '#title' => t('Latitude Field'), - '#description' => t('Choose a field for Latitude. This should be a ' - . 'field that is a decimal or float value.'), - '#options' => $fields, - '#default_value' => $this->options['data_source']['other_lat'], - '#states' => $this->datasource_dependent('other_latlon') - ); - $form['data_source']['other_lon'] = array( - '#type' => 'select', - '#title' => t('Longitude Field'), - '#description' => t('Choose a field for Longitude. This should be a ' - . 'field that is a decimal or float value.'), - '#options' => $fields, - '#default_value' => $this->options['data_source']['other_lon'], - '#states' => $this->datasource_dependent('other_latlon') - ); - - $form['data_source']['wkt'] = array( - '#type' => 'select', - '#title' => t('WKT Field'), - '#description' => t('Choose the OpenLayers WKT field.'), - '#options' => $fields, - '#default_value' => $this->options['data_source']['wkt'], - '#states' => $this->datasource_dependent('wkt') - ); - - $form['data_source']['other_top'] = array( - '#type' => 'select', - '#title' => t('Top Field'), - '#description' => t('Choose a field for Top. This should be a ' - . 'field that is a decimal or float value.'), - '#options' => $fields, - '#default_value' => $this->options['data_source']['other_top'], - '#states' => $this->datasource_dependent('other_boundingbox') - ); - $form['data_source']['other_right'] = array( - '#type' => 'select', - '#title' => t('Right Field'), - '#description' => t('Choose a field for Right. This should be a field ' - . 'that is a decimal or float value.'), - '#options' => $fields, - '#default_value' => $this->options['data_source']['other_right'], - '#states' => $this->datasource_dependent('other_boundingbox') - ); - $form['data_source']['other_bottom'] = array( - '#type' => 'select', - '#title' => t('Bottom Field'), - '#description' => t('Choose a field for Bottom. This should be a ' - . 'field that is a decimal or float value.'), - '#options' => $fields, - '#default_value' => $this->options['data_source']['other_bottom'], - '#states' => $this->datasource_dependent('other_boundingbox') - ); - $form['data_source']['other_left'] = array( - '#type' => 'select', - '#title' => t('Left Field'), - '#description' => t('Choose a field for Left. This should be a field ' . - 'that is a decimal or float value.'), - '#options' => $fields, - '#default_value' => $this->options['data_source']['other_left'], - '#states' => $this->datasource_dependent('other_boundingbox') - ); - } - $form['data_source']['name_field'] = array( - '#type' => 'select', - '#title' => t('Title Field'), - '#description' => t('Choose the field which will appear as a title on ' . - 'tooltips.'), - '#options' => array_merge(array('' => ''), $fields), - '#default_value' => $this->options['data_source']['name_field'], - ); - - $desc_options = array_merge(array( - '' => '', - '#row' => '<' . t('entire row') . '>', - ), $fields); - - // Description field - $form['data_source']['description_field'] = array( - '#type' => 'select', - '#title' => t('Description Content'), - '#description' => t('Choose the field or rendering method which will - appear as a description on tooltips or popups.'), - '#required' => FALSE, - '#options' => $desc_options, - '#default_value' => $this->options['data_source']['description_field'], - ); - - // A simple way to display attributes and styling - $form['attributes'] = array( - '#type' => 'fieldset', - '#title' => t('Attributes and Styling'), - '#description' => t('Attributes are field data attached to each ' - . 'feature. This can be used with styling to create Variable styling.'), - '#collapsible' => TRUE, - '#collapsed' => TRUE, - ); - $variable_fields = array(); - foreach ($this->view->display_handler->get_handlers('field') as - $field => $handler) { - $variable_fields[$field] = '${' . $field . '}'; - } - if (!empty($this->options['data_source']['name_field'])) { - $variable_fields['name'] = '${name}'; - } - if (!empty($this->options['data_source']['description_field'])) { - $variable_fields['description'] = '${description}'; - } - - $form['attributes']['display'] = array( - '#title' => 'Select attributes to include in the features', - '#type' => 'checkboxes', - '#options' => $variable_fields, - '#default_value' => !empty($this->options['attributes']['display']) ? - $this->options['attributes']['display'] : array_combine(array_keys($variable_fields), array_keys($variable_fields)), - '#description' => t('Any fields that you select will be attached to ' - . 'their respective feature (point, line, polygon) as attributes. ' - . 'These attributes can then be used to add variable styling to your ' - . 'themes. This is accomplished by using the %syntax syntax in the ' - . 'values for a style. You can see a list of available variables in ' - . 'the view preview; these can be placed right in the style interface. ' - . 'The field has been processed by Views.' - . 'By disabling some of them, you can reduce the size ' - . 'of the Javascript included in your pages.' - . 'Please note that this does not apply to Grouped Displays.', - array( - '%syntax' => '${field_name}' - )) - ); - } - - - /** - * @param $records ... - * - * openlayers_views_style_data specific - */ - function map_features($sets = array()) { - $features = $excluded_fields = array(); - $handlers = $this->display->handler->get_handlers('field'); - - foreach ($sets as $title => $records) { - foreach ($records as $id => $record) { - $this->view->row_index = $id; - $attributes = array(); - $wkt = NULL; - $field_exclude = array(); - - // Save the 'exclude' options of fields as backup. - foreach ($this->view->field as $fid => $field) { - $field_exclude[$fid] = $field->options['exclude']; - } - // Loop through each fields and render it if there were only one - // field in the row, so we have all the goodness of Views's field - // wrapping, class customizations and label. - foreach ($handlers as $hid => $handler) { - $field_id = $handler->options['id']; - // Exclude all the field from rendering - foreach ($this->view->field as $field) { - $field->options['exclude'] = TRUE; - } - // Enable only the field we want to render the row. - $this->view->field[$field_id]->options['exclude'] = FALSE; - // Render the row. - $attributes[$hid] = trim($this->row_plugin->render($record)); - } - // Restore the state of the exclude options in the fields. - foreach ($this->view->field as $fid => $field) { - $this->view->field[$fid]->options['exclude'] = $field_exclude[$fid]; - } - - // Add the 'name' attribute. - if (isset($this->options['data_source']['name_field'])) { - if (isset($attributes[$this->options['data_source']['name_field']])) { - $attributes['name'] = $attributes[$this->options['data_source']['name_field']]; - } - } - - // Add the 'description' attribute. - if (isset($this->options['data_source']['description_field'])) { - // Handle rendering the whole record. - if ($this->options['data_source']['description_field'] === '#row') { - $attributes['description'] = trim($this->row_plugin->render($record)); - } else { - if (isset($attributes[$this->options['data_source']['description_field']])) { - $attributes['description'] = $attributes[$this->options['data_source']['description_field']]; - } - } - } - - // We do not need the rendered value for these fields, - // just the raw value. - // This is why we use $this->rendered_fields. - if (isset($this->options['data_source']['value'])) { - switch ($this->options['data_source']['value']) { - case 'wkt': - $handler = $handlers[$this->options['data_source']['wkt']]; - $wkt = $handler->allow_advanced_render() ? $handler->advanced_render($record) : $handler->render($record); - break; - case 'other_latlon': - $handler = $handlers[$this->options['data_source']['other_lon']]; - $other_lon = $handler->allow_advanced_render() ? $handler->advanced_render($record) : $handler->render($record); - $handler = $handlers[$this->options['data_source']['other_lat']]; - $other_lat = $handler->allow_advanced_render() ? $handler->advanced_render($record) : $handler->render($record); - $wkt = 'POINT(' . $other_lon . ' ' . $other_lat . ')'; - break; - } - } - - // Only render features that has been enabled in the configuration - // of the display. - if (isset($this->options['attributes']['display'])) { - foreach($this->options['attributes']['display'] as $fid => $value) { - if ($this->options['attributes']['display'][$fid] === 0) { - unset($attributes[$fid]); - } - } - } - - // Create features array. - $feature = array( - 'projection' => 'EPSG:4326', - 'attributes' => $attributes, - 'wkt' => $wkt, - ); - - $features = $this->reduce_features($this->options['grouping'], $features, $feature, $title); - } - } - - // For grouping, handle a bit differently. - if ($this->options['grouping']) { - $features = $this->coalesce_groups($features, $handlers, $this->options['data_source']); - } - - return $features; - } - - /** - * Basically a macro because - * #state is rather verbose - * - * openlayers_views_style_data specific - */ - function datasource_dependent($type) { - return array('visible' => array('#edit-style-options-data-source-value' => array('value' => $type))); - } - - /** - * Coalesce features into single grouped feature when grouping is enabled. - * - * openlayers_views_style_data specific - */ - function coalesce_groups($features, $handlers, $ds) { - - // Combine wkt into geometry collections if they are an array - foreach ($features as &$feature) { - if (is_array($feature['wkt'])) { - if (count($feature['wkt']) > 1) { - $feature['wkt'] = $this->get_group_wkt($feature['wkt']); - } - else { - $feature['wkt'] = $feature['wkt'][0]; - } - } - } - - // Process title and description for groups - foreach ($features as $k => &$feature) { - $feature['attributes']['name'] = $k; - $feature['attributes'] = array_merge($feature['attributes'], $feature['features'][0]['attributes']); - - $formatted_features = array(); - foreach ($feature['features'] as $subfeature) { - - // Create name and description attributes. Note that there are a - // couple exceptions to using fields. - $exceptions = array('#row'); - - // Run the output through a theme. - $formatted_features[] = theme('openlayers_views_group_display_item', - array( - 'name' => isset($handlers[$ds['name_field']]) ? - $subfeature['attributes'][$ds['name_field']] : FALSE, - 'description' => (in_array($ds['description_field'], $exceptions) || - isset($handlers[$ds['description_field']])) ? - $subfeature['attributes'][$ds['description_field']] : FALSE - ) - ); - - // Remove rendered rows to keep data size down for JS. - if (in_array($ds['description_field'], $exceptions)) { - unset($subfeature['attributes'][$ds['description_field']]); - } - } - - // Then run all gathered features through item_ist theme. - $feature['attributes']['description'] = theme('item_list', - array('items' => $formatted_features) - ); - } - return $features; - } - - /** - * Combine all group wkt into a single geometry collection - * - * openlayers_views_style_data specific - */ - function get_group_wkt($wkt_array) { - geophp_load(); - $geophp = geoPHP::load($wkt_array, 'wkt'); - return $geophp->out('wkt'); - } - - /** - * Split string according to first match of passed regEx index of $regExes - */ - function preg_explode($regEx, $str) { - $matches = array(); - preg_match($this->regExes[$regEx], $str, $matches); - return empty($matches)?array(trim($str)):explode($matches[0], trim($str)); - } - - /** - * Basically an algebraic reduction; given whether to group, - * a feature, a list of features, etc., return a full $features - * array with the element added, either straight non-grouped, - * or within a new or existing group - * - * openlayers_views_style_data specific - */ - function reduce_features($is_grouped, $features, $feature, $group) { - if ($is_grouped) { - if (isset($features[$group])) { - $features[$group]['attributes']['count']++; - $features[$group]['wkt'][] = $feature['wkt']; - $features[$group]['features'][] = $feature; - return $features; - } - else { - $features[$group] = array( - 'attributes' => array('count' => 1), - 'wkt' => array($feature['wkt']), - 'projection' => $feature['projection'], - 'features' => array($feature) - ); - return $features; - } - } - else { - array_push($features, $feature); - return $features; - } - } - -} diff --git a/modules/openlayers_views/views/openlayers_views_style_data_image.inc b/modules/openlayers_views/views/openlayers_views_style_data_image.inc deleted file mode 100644 index 720b471d0634262189fc6610bcaedf3628286af3..0000000000000000000000000000000000000000 --- a/modules/openlayers_views/views/openlayers_views_style_data_image.inc +++ /dev/null @@ -1,149 +0,0 @@ -option_definition - */ - function option_definition() { - $options = parent::option_definition(); - $options['config'] = array(); - return $options; - } - - /** - * Render the map. - * - * Overrides views_plugin_style->render - */ - function render() { - $view = $this->view; - - // Render fields to trigger rewriting and other field processing. - $this->view->style_plugin->render_fields($this->view->result); - $image_field = isset($this->options['config']['image_field']) ? $this->options['config']['image_field'] : NULL; - $factor_x = !empty($this->options['config']['factors']['x']) ? $this->options['config']['factors']['x'] : 1; - $factor_y = !empty($this->options['config']['factors']['y']) ? $this->options['config']['factors']['y'] : 1; - $numzoomlevels = !empty($this->options['config']['numZoomLevels']) ? $this->options['config']['numZoomLevels'] : 1; - $maxextent = !empty($this->options['config']['maxExtent']) ? $this->options['config']['maxExtent'] : NULL; - - foreach ($this->view->result as $count => $row) { - if (isset($view->style_plugin->rendered_fields[$count][$image_field])) { - $image = $view->style_plugin->rendered_fields[$count][$image_field]; - $value = $view->style_plugin->get_field_value($count, $image_field); - $field_output = array_shift($value); - - $data[] = array( - 'file' => $image, - 'size' => array( - 'w' => floatval($field_output['width']), - 'h' => floatval($field_output['height']) - ), - 'factors' => array( - 'x' => floatval($factor_x), - 'y' => floatval($factor_y) - ), - 'numZoomLevels' => floatval($numzoomlevels), - 'maxExtent' => $maxextent - ); - } - } - - if (!empty($data)) { - // Skip rendering if view is being edited or previewed. - if (empty($this->view->live_preview)) { - return $data[0]; - } else { - return print_r($data[0], 1); - } - } else { - return ''; - } - } - - /** - * Options form - * - * Overrides views_plugin_style->options_form - */ - function options_form(&$form, &$form_state) { - parent::options_form($form, $form_state); - - // Get list of fields in this view & flag available geodata fields - $handlers = $this->display->handler->get_handlers('field'); - - // Check for any fields, as the view needs them - if (empty($handlers)) { - $form['error_markup'] = array( - '#value' => t('You need to enable at least one field before you can ' - . 'configure your field settings'), - '#prefix' => '
', - '#suffix' => '
', - ); - return; - } - - $fields = array(); - foreach ($handlers as $field_id => $handler) { - $fields[$field_id] = $handler->ui_name(); - } - - $form['config'] = array( - '#type' => 'fieldset', - '#tree' => TRUE, - '#title' => t('Image Source'), - '#collapsible' => TRUE, - '#collapsed' => FALSE, - ); - $form['config']['image_field'] = array( - '#type' => 'select', - '#title' => t('Map Data Sources'), - '#description' => t('Choose which sources of data that the map will ' - . 'provide features for.'), - '#options' => $fields, - '#default_value' => $this->options['config']['image_field'], - ); - $form['config']['factors'] = array( - '#tree' => TRUE, - 'x' => array( - '#title' => 'Width divider', - '#type' => 'textfield', - '#default_value' => isset($this->options['config']['factors']['x']) ? $this->options['config']['factors']['x'] : 1, - '#description' => t('Width divider.'), - ), - 'y' => array( - '#title' => 'Height divider', - '#type' => 'textfield', - '#default_value' => isset($this->options['config']['factors']['y']) ? $this->options['config']['factors']['y'] : 1, - '#description' => t('Height divider.'), - ), - ); - $form['config']['maxExtent'] = array( - '#type' => 'textfield', - '#title' => t('Max Extent'), - '#default_value' => isset($this->options['config']['maxExtent']) ? implode(', ', $this->options['config']['maxExtent']) : '', - '#description' => t('Should consist of four values (left, bottom, right, top). The maximum extent for the layer. Image is stretched to cover whole map if left empty.'), - ); - $form['config']['numZoomLevels'] = array( - '#title' => 'Zoomlevels', - '#type' => 'textfield', - '#default_value' => isset($this->options['config']['numZoomLevels']) ? $this->options['config']['numZoomLevels'] : 1 - ); - } -} diff --git a/modules/openlayers_views/views/openlayers_views_style_map.inc b/modules/openlayers_views/views/openlayers_views_style_map.inc deleted file mode 100644 index e19fec9b407d1c47a2732bb3e8e067a6eea51689..0000000000000000000000000000000000000000 --- a/modules/openlayers_views/views/openlayers_views_style_map.inc +++ /dev/null @@ -1,74 +0,0 @@ - variable_get('openlayers_default_map', 'default')); - return $options; - } - - /** - * Options form - */ - function options_form(&$form, &$form_state) { - parent::options_form($form, $form_state); - - // Map - $form['map'] = array( - '#type' => 'select', - '#title' => t('Map'), - '#description' => t('This is map that will be used to render the view.'), - '#options' => openlayers_map_options(), - '#default_value' => $this->options['map'] ? - $this->options['map'] : - variable_get('openlayers_default_map', 'default'), - ); - } - - /** - * Query - override to make sure this doesn't get run - */ - function query() { - if (isset($this->view->query->fields)) { - $this->view->query->fields = array(); - } - $this->view->executed = TRUE; - $this->view->result = TRUE; - $map = openlayers_map_load($this->options['map']); - $build = openlayers_render_map_data($map->data); - $render = render($build); - $this->view->result = $render || !$map->data['hide_empty_map'] ? TRUE : FALSE; - if ($this->view->result) { - $this->render = $render; - } - } - - /** - * Renders views (map) - */ - function render() { - return theme($this->theme_functions(), array( - 'view' => $this->view, - 'options' => $this->options, - 'map' => $this->render - )); - } -} diff --git a/openlayers.info b/openlayers.info index a9ead1c20db696d70f22c1a4c67da5b8732cf910..0721d4c7abd93c1cd5c118e287482cfe9d552639 100644 --- a/openlayers.info +++ b/openlayers.info @@ -3,26 +3,15 @@ description = "OpenLayers base API module" core = 7.x package = "OpenLayers" dependencies[] = libraries (>=2.1) -dependencies[] = proj4js dependencies[] = ctools dependencies[] = file dependencies[] = image ; Core files files[] = openlayers.module -files[] = plugins/layer_types/openlayers_layer_type_bing.inc -files[] = plugins/layer_types/openlayers_layer_type_cloudmade.inc -files[] = plugins/layer_types/openlayers_layer_type_dummy.inc -files[] = plugins/layer_types/openlayers_layer_type_geojson.inc -files[] = plugins/layer_types/openlayers_layer_type_google.inc -files[] = plugins/layer_types/openlayers_layer_type_gpx.inc -files[] = plugins/layer_types/openlayers_layer_type_image.inc -files[] = plugins/layer_types/openlayers_layer_type_kml.inc -files[] = plugins/layer_types/openlayers_layer_type_maptiler.inc -files[] = plugins/layer_types/openlayers_layer_type_osm.inc -files[] = plugins/layer_types/openlayers_layer_type_pointgrid.inc -files[] = plugins/layer_types/openlayers_layer_type_raw.inc -files[] = plugins/layer_types/openlayers_layer_type_tms.inc -files[] = plugins/layer_types/openlayers_layer_type_wms.inc -files[] = plugins/layer_types/openlayers_layer_type_wmts.inc -files[] = plugins/layer_types/openlayers_layer_type_xyz.inc +files[] = includes/openlayers.object.inc +files[] = includes/openlayers.interaction.inc +files[] = includes/openlayers.map.inc +files[] = includes/openlayers.layer.inc +files[] = includes/openlayers.source.inc +files[] = includes/openlayers.control.inc diff --git a/openlayers.install b/openlayers.install index c0d48bf9ccaee5f7a24f03e86ac02a40c214ebbf..eed2ae6d094d51d2f6588c75f4dbf078daa2b4aa 100644 --- a/openlayers.install +++ b/openlayers.install @@ -1,19 +1,5 @@ 'Storage for User defined OpenLayers maps.', 'export' => array( - 'key' => 'name', - 'key name' => 'Name', - 'primary key' => 'name', - 'identifier' => 'openlayers_maps', - 'default hook' => 'openlayers_maps', + 'key' => 'machine_name', + 'key name' => 'Machine name', + 'primary key' => 'machine_name', + 'identifier' => 'map', + 'default hook' => 'default_maps', + //'load all callback' => 'openlayers_maps_load_all', + //'load all' => 'openlayers_maps_load', + 'object factory' => 'openlayers_maps_factory', 'api' => array( 'owner' => 'openlayers', - 'api' => 'openlayers_maps', + 'api' => 'default_maps', 'minimum_version' => 1, 'current_version' => 1, ), ), 'fields' => array( - 'name' => array( + 'machine_name' => array( 'description' => 'The primary identifier for the map.', 'type' => 'varchar', 'length' => 255, 'not null' => TRUE, ), - 'title' => array( + 'name' => array( 'description' => 'The title of the map.', 'type' => 'varchar', 'length' => 255, @@ -67,521 +56,263 @@ function openlayers_schema() { 'type' => 'text', 'not null' => TRUE, ), - 'data' => array( + 'class' => array( + 'type' => 'text', + 'not null' => TRUE, + 'description' => 'Map class.', + ), + 'options' => array( 'description' => 'The serialized map.', 'type' => 'text', 'not null' => TRUE, 'serialize' => TRUE, ), ), - 'primary key' => array('name'), + 'primary key' => array('machine_name'), + 'unique keys' => array( + 'machine_name' => array('machine_name'), + ), ); - // Layer table (ctools extras) + // table (ctools extras) $schema['openlayers_layers'] = array( 'description' => 'Storage for user defined OpenLayers layers.', 'export' => array( - 'key' => 'name', - 'key name' => 'Name', - 'primary key' => 'name', - 'identifier' => 'openlayers_layers', - 'default hook' => 'openlayers_layers', + 'admin_title' => 'machine_name', + 'key' => 'machine_name', + 'key name' => 'Machine name', + 'primary key' => 'machine_name', + 'identifier' => 'layer', + 'default hook' => 'default_layers', + //'load all callback' => 'openlayers_layers_load_all', + //'load all' => 'openlayers_layers_load', + 'object factory' => 'openlayers_layers_factory', 'api' => array( 'owner' => 'openlayers', - 'api' => 'openlayers_layers', + 'api' => 'default_layers', 'minimum_version' => 1, 'current_version' => 1, ), ), 'fields' => array( - 'name' => array( + 'machine_name' => array( 'type' => 'varchar', 'length' => '255', 'not null' => TRUE, - 'default' => '', - 'description' => 'Layer name.', + 'description' => 'system name.', ), - 'title' => array( + 'name' => array( 'type' => 'varchar', 'length' => '255', 'not null' => TRUE, 'default' => '', - 'description' => 'Layer title.', + 'description' => 'name.', ), 'description' => array( 'type' => 'text', 'not null' => TRUE, - 'description' => 'Layer description.', + 'description' => 'description.', + ), + 'class' => array( + 'type' => 'text', + 'not null' => TRUE, + 'description' => 'class.', ), - 'data' => array( + 'options' => array( 'type' => 'text', 'not null' => FALSE, - 'description' => 'Layer data serialized.', + 'description' => 'options serialized.', 'serialize' => TRUE, ), ), - 'primary key' => array('name'), + 'primary key' => array('machine_name'), + 'unique keys' => array( + 'machine_name' => array('machine_name'), + ), ); - // Projection table (ctools extras) - // TODO: Translations missing? - $schema['openlayers_projections'] = array( - 'description' => 'Storage for user defined OpenLayers projections.', + // table (ctools extras) + $schema['openlayers_sources'] = array( + 'description' => 'Storage for user defined OpenLayers sources.', 'export' => array( - 'key' => 'identifier', - 'key name' => 'Identifier', - 'primary key' => 'identifier', - 'identifier' => 'openlayers_projections', - 'default hook' => 'openlayers_projections', + 'admin_title' => 'machine_name', + 'key' => 'machine_name', + 'key name' => 'Machine name', + 'primary key' => 'machine_name', + 'identifier' => 'source', + 'default hook' => 'default_sources', + 'load all callback' => 'openlayers_sources_load_all', + 'object factory' => 'openlayers_sources_factory', 'api' => array( 'owner' => 'openlayers', - 'api' => 'openlayers_projections', + 'api' => 'default_sources', 'minimum_version' => 1, 'current_version' => 1, ), ), 'fields' => array( - 'identifier' => array( + 'machine_name' => array( 'type' => 'varchar', - 'length' => 255, + 'length' => '255', 'not null' => TRUE, - 'description' => 'Opaque identifier. Guaranteed to be unique but does not have any other meaning.' + 'description' => 'Source system name.', ), - 'authority' => array( - 'type' => 'text', + 'name' => array( + 'type' => 'varchar', + 'length' => '255', 'not null' => TRUE, - 'description' => 'Projection authority.', + 'default' => '', + 'description' => 'Source name.', ), - 'code' => array( + 'description' => array( 'type' => 'text', 'not null' => TRUE, - 'description' => 'Projection code.', + 'description' => 'Source description.', ), - 'definition' => array( + 'class' => array( 'type' => 'text', 'not null' => TRUE, - 'description' => 'Projection definition (proj4 format).', + 'description' => 'Source class.', ), - 'projectedextentleft' => array( - 'type' => 'numeric', - 'not null' => TRUE, - 'description' => "Leftmost value in this projection's coordinates", - ), - 'projectedextentbottom' => array( - 'type' => 'numeric', - 'not null' => TRUE, - 'description' => "Bottommost value in this projection's coordinates", - ), - 'projectedextentright' => array( - 'type' => 'numeric', - 'not null' => TRUE, - 'description' => "Rightmost value in this projection's coordinates", - ), - 'projectedextenttop' => array( - 'type' => 'numeric', - 'not null' => TRUE, - 'description' => "Topmost value in this projection's coordinates", - ), - // TODO Hopefully never used - 'data' => array( + 'options' => array( 'type' => 'text', 'not null' => FALSE, - 'description' => 'Projection data serialized.', + 'description' => 'Source options serialized.', 'serialize' => TRUE, ), ), - 'primary key' => array('identifier'), + 'primary key' => array('machine_name'), + 'unique keys' => array( + 'machine_name' => array('machine_name'), + ), ); - // Styles table (ctools extras) - $schema['openlayers_styles'] = array( - 'description' => 'Storage for user defined OpenLayers styles.', + $schema['openlayers_controls'] = array( + 'description' => 'Storage for user defined OpenLayers controls.', 'export' => array( - 'key' => 'name', - 'key name' => 'Name', - 'primary key' => 'name', - 'identifier' => 'openlayers_styles', - 'default hook' => 'openlayers_styles', + 'admin_title' => 'machine_name', + 'key' => 'machine_name', + 'key name' => 'Machine name', + 'primary key' => 'machine_name', + 'identifier' => 'control', + 'default hook' => 'default_controls', 'api' => array( 'owner' => 'openlayers', - 'api' => 'openlayers_styles', + 'api' => 'default_controls', 'minimum_version' => 1, 'current_version' => 1, ), ), 'fields' => array( - 'name' => array( + 'machine_name' => array( 'type' => 'varchar', 'length' => '255', 'not null' => TRUE, 'default' => '', - 'description' => 'Style name.', + 'description' => 'Control system name.', ), - 'title' => array( + 'name' => array( 'type' => 'varchar', 'length' => '255', 'not null' => TRUE, 'default' => '', - 'description' => 'Style title.', + 'description' => 'Control name.', ), 'description' => array( 'type' => 'text', 'not null' => TRUE, - 'description' => 'Style description.', + 'description' => 'Control description.', ), - 'data' => array( + 'class' => array( + 'type' => 'text', + 'not null' => TRUE, + 'description' => 'Control class.', + ), + 'options' => array( 'type' => 'text', 'not null' => FALSE, - 'description' => 'Style data serialized.', + 'description' => 'Control options serialized.', 'serialize' => TRUE, ), ), - 'primary key' => array('name'), + 'primary key' => array('machine_name'), + 'unique keys' => array( + 'machine_name' => array('machine_name'), + ), + $schema['openlayers_interactions'] = array( + 'description' => 'Storage for user defined OpenLayers interactions.', + 'export' => array( + 'admin_title' => 'machine_name', + 'key' => 'machine_name', + 'key name' => 'Machine name', + 'primary key' => 'machine_name', + 'identifier' => 'interaction', + 'default hook' => 'default_interactions', + 'api' => array( + 'owner' => 'openlayers', + 'api' => 'default_interactions', + 'minimum_version' => 1, + 'current_version' => 1, + ), + ), + 'fields' => array( + 'machine_name' => array( + 'type' => 'varchar', + 'length' => '255', + 'not null' => TRUE, + 'default' => '', + 'description' => 'Interaction system name.', + ), + 'name' => array( + 'type' => 'varchar', + 'length' => '255', + 'not null' => TRUE, + 'default' => '', + 'description' => 'Interaction name.', + ), + 'description' => array( + 'type' => 'text', + 'not null' => TRUE, + 'description' => 'Interaction description.', + ), + 'class' => array( + 'type' => 'text', + 'not null' => TRUE, + 'description' => 'Interaction class.', + ), + 'options' => array( + 'type' => 'text', + 'not null' => FALSE, + 'description' => 'Interaction options serialized.', + 'serialize' => TRUE, + ), + ), + 'primary key' => array('machine_name'), + 'unique keys' => array( + 'machine_name' => array('machine_name'), + ), + ) ); return $schema; } -/** - * Implements hook_requirements(). - */ function openlayers_requirements($phase) { - $req = array(); - $t = get_t(); + $requirements = array(); - // We should not require a specfic version of the OpenLayers library, but - // we should tell the administrator that specific versions are more - // compatible than others. - if ($phase == 'runtime') { - $ol_library_version = 0; - $current_library = variable_get('openlayers_source', OPENLAYERS_DEFAULT_LIBRARY); + if ($phase != 'install') { + $ol3 = libraries_detect('openlayers3'); - // As of 2.11, the hosted version supports the newest hosted - // stable with an actual version number. This used to be just under - // the 'api' path. - if (strpos($current_library, (string) OPENLAYERS_SUGGESTED_LIBRARY) !== FALSE) { - $ol_library_version = OPENLAYERS_SUGGESTED_LIBRARY; - } - - // Check if it is the default hosted. - if ($current_library == 'http://openlayers.org/api/OpenLayers.js') { - $ol_library_version = OPENLAYERS_HOSTED_API_LIBRARY; - } - - // Finally, let's see if the client has sent us a value - // from the UI module AJAX magic. - $client = variable_get('openlayers_ui_version_check', ''); - if (strpos($client, (string) OPENLAYERS_SUGGESTED_LIBRARY) !== FALSE) { - $ol_library_version = OPENLAYERS_SUGGESTED_LIBRARY; - } - - // Check if suggest version. - if ($ol_library_version == OPENLAYERS_SUGGESTED_LIBRARY) { - $req['openlayers_old_presets'] = array( - 'title' => $t('OpenLayers library version'), - 'value' => $t('Using suggested compatible version %suggested.', - array( - '%suggested' => OPENLAYERS_SUGGESTED_LIBRARY, - )), + if ($ol3) { + $requirements['openlayers3'] = array( + 'title' => 'OpenLayers library installed', 'severity' => REQUIREMENT_OK, + 'value' => t('OpenLayers %version library installed at %path', array('%path' => $ol3['library path'], '%version' => $ol3['version'])), ); - } - else { - $req['openlayers_old_presets'] = array( - 'title' => $t('OpenLayers library version'), - 'value' => $t('Not suggested compatible version.'), - 'description' => $t('Though you are very welcome to use whatever version of the OpenLayers library you want, it is suggested that you use version %suggested. You are currently not using that version or we are unable to determine which version you are using. Update your library settings at !settings.', - array( - '%suggested' => OPENLAYERS_SUGGESTED_LIBRARY, - '!settings' => l(t('OpenLayers settings'), 'admin/structure/openlayers'), - )), - 'severity' => REQUIREMENT_WARNING, - ); - } - } - - // There are some backwards compability for the shift from - // preset to maps. We want to communicate to administrators - // that this will not be there forever. - if ($phase == 'runtime') { - // Check preset hook - $presets = module_invoke_all('openlayers_presets'); - $found_presets = (count($presets) > 0) ? TRUE : FALSE; - - // Check features - $feature_names = array(); - $found_features = FALSE; - if (module_exists('features')) { - $features = features_get_features(); - foreach ($features as $feature) { - // Only utilize enabled features and look for presets - if ($feature->status > 0 && !empty($feature->info['features']['openlayers_map_presets'])) { - $feature_names[] = $feature->name; - $found_features = TRUE; - } - } - } - - // Create requirement entries - if ($found_presets) { - $req['openlayers_old_presets'] = array( - 'title' => $t('OpenLayers Presets'), - 'value' => $t('Found old presets.'), - 'description' => $t('With the 7.x-2.x version of the OpenLayers module, map presets were renamed to just maps. This has some implications on APIs and hooks. One or more of of the modules installed on this site is utilizing the deprecated %hook. Please read the upgrade page, then contact the module owner or fix the custom module yourself.', - array( - '%hook' => 'hook_openlayers_presets()', - '@url' => url('http://drupal.org/node/1136810'), - )), - 'severity' => REQUIREMENT_ERROR, - ); - } - if ($found_features) { - $req['openlayers_old_features'] = array( - 'title' => $t('OpenLayers Presets'), - 'value' => $t('Found Features with presets.'), - 'description' => $t('With the 7.x-2.x version of the OpenLayers module, map presets were renamed to just maps. This has some implications on APIs and hooks. There are Features on this site that contain the old map presets. Please read the upgrade page, and rebuild the following Features: %features', - array( - '@url' => url('http://drupal.org/node/1136810'), - '%features' => implode(',', $feature_names), - )), + } else { + $requirements['openlayers3'] = array( + 'title' => t('OpenLayers'), 'severity' => REQUIREMENT_ERROR, + 'value' => t('OpenLayers library was not found.'), ); } } - return $req; -} - -/** - * Implements hook_update_N(). - * - * Rename of presets to maps. - */ -function openlayers_update_7201() { - // Change table name - db_rename_table('openlayers_map_presets', 'openlayers_maps'); - // Set default map variable - variable_set('openlayers_default_map', variable_get('openlayers_default_preset', 'default')); - variable_del('openlayers_default_preset'); -} - -/** - * Drop name indexes duplicates of primary key. - */ -function openlayers_update_7202() { - db_drop_index('openlayers_layers', 'name'); - db_drop_index('openlayers_styles', 'name'); -} - -/** - * Rename the 'baselayer' in 'isBaseLayer' in layers. - */ -function openlayers_update_7204() { - openlayers_update_create_projection_table(); - - foreach (openlayers_layers_load() as $key => $layer) { - if ($layer->export_type != 1) continue; - if (isset($layer->data['baselayer'])) { - $layer->data['isBaseLayer'] = $layer->data['baselayer']; - unset($layer->data['baselayer']); - ctools_export_crud_save('openlayers_layers', $layer); - } - } + return $requirements; } - -/** - * Change the case of machine_name for layers, maps and styles. - * Warning, it can break things. - */ -function openlayers_update_7205() { - db_query('UPDATE {openlayers_layers} SET name = LOWER(name);'); - db_query('UPDATE {openlayers_styles} SET name = LOWER(name);'); - db_query('UPDATE {openlayers_maps} SET name = LOWER(name);'); -} - -/** - * Rename the 'base_url' in 'url' in layer type TMS. - */ -function openlayers_update_7206() { - openlayers_update_create_projection_table(); - - foreach (openlayers_layers_load() as $key => $layer) { - if ($layer->export_type != 1) continue; - if ($layer->data['layer_type'] != 'openlayers_layer_type_tms') continue; - if (isset($layer->data['base_url'])) { - $layer->data['url'] = $layer->data['base_url']; - unset($layer->data['base_url']); - ctools_export_crud_save('openlayers_layers', $layer); - } - } -} - -/** - * Makes projections available that are required for update hooks to work properly. - * Must by called at least once by any of the update hooks. - */ -function openlayers_update_create_projection_table() { - static $hasRun = FALSE; - if($hasRun || db_table_exists('openlayers_projections')){ - return; - } else { - $hasRun = TRUE; - } - - // Create projection table - $openlayers_projections_schema = array( - 'description' => 'Storage for user defined OpenLayers projections.', - 'export' => array( - 'key' => 'identifier', - 'key name' => 'Identifier', - 'primary key' => 'identifier', - 'identifier' => 'openlayers_projections', - 'default hook' => 'openlayers_projections', - 'api' => array( - 'owner' => 'openlayers', - 'api' => 'openlayers_projections', - 'minimum_version' => 1, - 'current_version' => 1, - ), - ), - 'fields' => array( - 'identifier' => array( - 'type' => 'varchar', - 'length' => 255, - 'not null' => TRUE, - 'description' => 'Opaque identifier. Guaranteed to be unique but does not have any other meaning.' - ), - 'authority' => array( - 'type' => 'text', - 'not null' => TRUE, - 'description' => 'Projection authority.', - ), - 'code' => array( - 'type' => 'text', - 'not null' => TRUE, - 'description' => 'Projection code.', - ), - 'definition' => array( - 'type' => 'text', - 'not null' => TRUE, - 'description' => 'Projection definition (proj4 format).', - ), - 'projectedextentleft' => array( - 'type' => 'numeric', - 'not null' => TRUE, - 'description' => "Leftmost value in this projection's coordinates", - ), - 'projectedextentbottom' => array( - 'type' => 'numeric', - 'not null' => TRUE, - 'description' => "Bottommost value in this projection's coordinates", - ), - 'projectedextentright' => array( - 'type' => 'numeric', - 'not null' => TRUE, - 'description' => "Rightmost value in this projection's coordinates", - ), - 'projectedextenttop' => array( - 'type' => 'numeric', - 'not null' => TRUE, - 'description' => "Topmost value in this projection's coordinates", - ), - // TODO Hopefully never used - 'data' => array( - 'type' => 'text', - 'not null' => FALSE, - 'description' => 'Projection data serialized.', - 'serialize' => TRUE, - ), - ), - 'primary key' => array('identifier'), - ); - db_create_table('openlayers_projections', $openlayers_projections_schema); -} - -/** - * Migrate configured projections so that other projections than those of EPSG can be used, too. - */ -function openlayers_update_7207() { - openlayers_update_create_projection_table(); - - // Migrate stored layers - foreach (openlayers_layers_load(TRUE) as $key => $layer) { - $projections = array(); - - // Takeover srs key that no longer exists and migrate it to a projection - if ($layer instanceof openlayers_layer_type_wms && array_key_exists('srs', $layer->data['options']) && !in_array($layer->data['options']['srs'], $layer->data['projection'])) { - $projections[] = $layer->data['options']['srs']; - } - unset($layer->data['options']['srs']); - - foreach ($layer->data['projection'] as $projection) { - if (is_string($projection)) { - $projections[] = $projection; - } - else { - throw new DrupalUpdateException("Unsupported projection type encountered in layer " . $key); - } - } - $layer->data['projection'] = $projections; - ctools_export_crud_save('openlayers_layers', $layer); - } - - // The code for the projection changed but its semantics stayed. - // Only update the display projection as servers might be in use that don't yet support the new code. - foreach (openlayers_maps(TRUE) as $key => $map) { - if ($map->data['displayProjection']==='EPSG:900913') { - $map->data['displayProjection'] = 'EPSG:3857'; - } - ctools_export_crud_save('openlayers_maps', $map); - } -} - -/** - * Ensure projections carry an authority code. - */ -function openlayers_update_7208() { - // Commit 95108d3fa82c34fc5dc5e6e159263232a891a27a introduced authority codes - // for layers and maps but did not migrate existing data. - foreach (openlayers_layers_load(TRUE) as $key => $layer) { - $projections = array(); - foreach ($layer->data['projection'] as $projection) { - if(mb_strpos($projection, 'EPSG:')===FALSE){ - $projections[] = 'EPSG:'.$projection; - } else { - $projections[] = $projection; - } - } - $layer->data['projection'] = $projections; - ctools_export_crud_save('openlayers_layers', $layer); - } - foreach (openlayers_maps(TRUE) as $key => $map) { - foreach(array('projection', 'displayProjection') as $projectionKey){ - $projection = $map->data[$projectionKey]; - if(mb_strpos($projection, 'EPSG:')===FALSE){ - $projection = 'EPSG:'.$projection; - } else { - $projection = $projection; - } - $map->data[$projectionKey] = $projection; - } - ctools_export_crud_save('openlayers_maps', $map); - } -} - -/** - * Drop maxExtent from layers where layers don't handle it. OpenLayers will - * then take the property from the map for the affected layers. - */ -function openlayers_update_7209(){ - foreach (openlayers_layers_load(TRUE) as $key => $layer) { - if($layer instanceof openlayers_layer_type_google - || $layer instanceof openlayers_layer_type_bing - || $layer instanceof openlayers_layer_type_cloudmade - || $layer instanceof openlayers_layer_type_geojson - || $layer instanceof openlayers_layer_type_kml - || $layer instanceof openlayers_layer_type_osm - || $layer instanceof openlayers_layer_type_raw - || $layer instanceof openlayers_layer_type_wms - ){ - unset($layer->data['maxExtent']); - } - ctools_export_crud_save('openlayers_layers', $layer); - } -} \ No newline at end of file diff --git a/openlayers.make.example b/openlayers.make.example index c5316f09b1623c1eb62ab94aca047f957d50db38..e5d35182fcee5e46900779511aa2bfaeaf85f899 100644 --- a/openlayers.make.example +++ b/openlayers.make.example @@ -2,6 +2,6 @@ api = 2 core = 7.x libraries[openlayers][download][type] = "file" -libraries[openlayers][download][url] = http://github.com/openlayers/openlayers/releases/download/release-2.13.1/OpenLayers-2.13.1.zip -libraries[openlayers][directory_name] = openlayers +libraries[openlayers][download][url] = https://github.com/openlayers/ol3/releases/download/v3.0.0/v3.0.0.zip +libraries[openlayers][directory_name] = openlayers3 libraries[openlayers][destination] = "libraries" diff --git a/openlayers.module b/openlayers.module index 74da6789cb7c57c5415e90300f40f1835883a4fe..205449ba9479496cebd0d2df62d21c3bc16d4a73 100644 --- a/openlayers.module +++ b/openlayers.module @@ -1,1603 +1,295 @@ ' . t('The OpenLayers module is the base module for the - OpenLayers suite of modules, and provides the main API.') . '

'; - } - return ''; +function openlayers_ctools_plugin_api($module, $api) { + $path = drupal_get_path('module', 'openlayers') . '/includes'; + return array( + 'version' => 1, + 'path' => $path + ); } /** * Implements hook_ctools_plugin_directory(). */ function openlayers_ctools_plugin_directory($module, $plugin) { - return 'plugins/' . $plugin; + return 'plugins/openlayers/' . $plugin; } /** * Implements hook_ctools_plugin_type(). */ function openlayers_ctools_plugin_type() { - // For backwards compatibility, we allow for the use - // of hooks to define these plugins. - // - // This should be removed in 7.x-3.x return array( - 'behaviors' => array( - 'use hooks' => TRUE, - 'classes' => array('behavior'), + 'map' => array( + 'use hooks' => FALSE, + 'classes' => array('handler') + ), + 'layer' => array( + 'use hooks' => FALSE, + 'classes' => array('handler') + ), + 'source' => array( + 'use hooks' => FALSE, + 'classes' => array('handler') ), - 'layer_types' => array( - 'use hooks' => TRUE, - 'classes' => array('layer_types'), + 'control' => array( + 'use hooks' => FALSE, + 'classes' => array('handler') + ), + 'interaction' => array( + 'use hooks' => FALSE, + 'classes' => array('handler') ) ); } -/** - * Include necessary CSS and JS for rendering maps - * - * @ingroup openlayers_api - */ -function openlayers_include() { - // Get the page language for string translation. - global $language; - $lang = $language->language; - - if ('internal' == variable_get('openlayers_source_type', 'external')) { - $variant = variable_get('openlayers_source_internal_variant', NULL); - if ($variant == 'original') $variant = NULL; - libraries_load('openlayers', $variant); +function openlayer_object_factory_create($object_type, $object_class, $export = NULL) { + ctools_include('plugins'); + $object_class = ctools_plugin_load_class('openlayers', $object_type, $object_class, 'handler'); + $object = call_user_func(array( + new ReflectionClass($object_class), 'newInstance') + ); - if ($lang != 'en') { - drupal_add_js(libraries_get_path('openlayers') . '/lib/OpenLayers/Lang.js', 'file'); - drupal_add_js(libraries_get_path('openlayers') . '/lib/OpenLayers/Lang/' . $lang . '.js', 'file'); - } + if ($export) { + $object->init($export); } - else { - // Use a static variable to prevent running URL check code repeatedly. - static $once; - if (!isset($once)) { - $once = TRUE; - $path = check_plain(variable_get('openlayers_source_external', OPENLAYERS_DEFAULT_LIBRARY)); + // This line is needed for openlayers_object::attached(). + $object->plugin = ctools_get_plugins('openlayers', $object_type, $object_class); + return $object; +} - // Correctly handle URLs beginning with a double backslash, see RFC 1808 Section 4 - if (substr($path, 0, 2) == '//') { - $http_protocol = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https' : 'http'; - $path = $http_protocol . ':' . $path; - } +function openlayers_object_load($object_type, $object_machine_name) { + ctools_include('export'); + $export = ctools_export_crud_load('openlayers_' . $object_type .'s', $object_machine_name); + $object = openlayer_object_factory_create($object_type, $export->class, $export); - // Check for full URL and include it manually if external. - if (valid_url($path, TRUE)) { - drupal_add_js($path, array('type' => 'external', 'weight' => -3)); - } - else { - drupal_add_js($path); - } - if ($lang != 'en') { - drupal_add_js(libraries_get_path('openlayers') . '/lib/OpenLayers/Lang.js', 'file'); - drupal_add_js(libraries_get_path('openlayers') . '/lib/OpenLayers/Lang/' . $lang . '.js', 'file'); - } - } + if (property_exists($export, 'disabled') && ($export->disabled == 1 || $export->disabled == TRUE)) { + $object->disabled = 1; } + + return $object; } -/** - * Render map array - * - * Given a map array, render into HTML to display - * a map. - * - * @ingroup openlayers_api - * - * @param $map - * Associative array of map paramters. - * @return - * Map HTML. - */ -function openlayers_render_map_data($map = array()) { +function openlayers_render_build_map(openlayers_map $map) { // Run map through build process // Get the necessary parts - openlayers_include(); - module_load_include('inc', 'openlayers', 'includes/openlayers.render'); - - // If no map is specified, use the default map. - if (empty($map)) { - if ($loaded_map = openlayers_map_load( - variable_get('openlayers_default_map', 'default'))) { - $map = $loaded_map->data; - } - } + libraries_load('openlayers3'); // Hook to alter map before main processing. Styles, behaviors, // layers may all be added here. // hook_openlayers_map_preprocess_alter($map) drupal_alter('openlayers_map_preprocess', $map); - // Styles and layer styles are not required parameters - $map['styles'] = isset($map['styles']) ? $map['styles'] : array(); - $map['layer_styles'] = isset($map['layer_styles']) ? $map['layer_styles'] : array(); - $map['layer_styles_select'] = isset($map['layer_styles_select']) ? $map['layer_styles_select'] : array(); - $map['layer_styles_temporary'] = isset($map['layer_styles_temporary']) ? $map['layer_styles_temporary'] : array(); + $objects = array(); + $objects['layer'] = $map->getLayers(); + $objects['source'] = $map->getSources(); + $objects['control'] = $map->getControls(); + $objects['interaction'] = $map->getInteractions(); + + foreach($objects as $type => $list) { + if (is_array($list)) { + foreach($list as $index => $machine_name) { + $object = openlayers_object_load($type, $machine_name); + unset($object->plugin); + unset($object->name); + unset($object->description); + $objects[$type][$index] = $object; + } + } + } - // Process map parts. - $map['layers'] = _openlayers_layers_process($map['layers'], $map); - $map['behaviors'] = _openlayers_behaviors_render($map['behaviors'], $map); - $map['styles'] = _openlayers_styles_process($map['styles'], $map['layer_styles'], $map['layer_styles_select'], $map['layer_styles_temporary'], $map); + $map->setOption('target', $map->getId()); + $objects['map'] = $map->toArray(); - // Restrict map to its projection extent (data outwith cannot be represented). - // Layer can additionally specfiy their maxExtent in case they use - // non-default grids. - $projection = openlayers_get_projection_by_identifier($map['projection']); - $map['maxExtent'] = $projection->getProjectedExtent(); + $attached = $map->attached(); - // Hook to alter map one last time. Final modification to existing - // styles, behaviors, layers can happen here, but adding new styles, - // behaviors will not get rendered. - // hook_openlayers_map_alter($map) drupal_alter('openlayers_map', $map); - // Check map for errors - $map['errors'] = openlayers_error_check_map($map); - - // Given hide_empty_map flag, check if the map has any features - // defined. If not, assume it is an empty map and shouldn't be displayed. - if (isset($map['hide_empty_map']) && $map['hide_empty_map'] == TRUE) { - $empty = TRUE; - foreach ($map['layers'] as $layer) { - if (isset($layer['features']) && count($layer['features'])) { - $empty = FALSE; - } - } - if ($empty) { - // Abort early because there are no features to display on the map anyway - return ''; - } - } - // Return themed map if no errors found - if (empty($map['errors'])) { - $styles = array( - 'width' => $map['width'], - 'height' => $map['height'] - ); + $setting = array( + 'openlayers' => array( + 'maps' => array( + $map->getId() => $objects + ) + ) + ); - $css_styles = ''; - foreach ($styles as $property => $value) { - $css_styles .= $property . ':' . $value . ';'; - } + $attached['js'][] = array( + 'data' => $setting, + 'type' => 'setting' + ); - $map['map_name'] = isset($map['map_name']) ? $map['map_name'] : substr(str_shuffle(md5(time())), 0, 8); - $css_map_name = drupal_clean_css_identifier($map['map_name']); + $styles = array( + 'width' => $map->getOption('width'), + 'height' => $map->getOption('height') + ); - // Create ID for map as this will help with alters. - $map['id'] = _openlayers_create_map_id('openlayers-map-' . $css_map_name); + $css_styles = ''; + foreach ($styles as $property => $value) { + $css_styles .= $property . ':' . $value . ';'; + } - // TODO: contextual links - $links = array( - '#type' => 'contextual_links', - '#contextual_links' => array( - 'openlayers' => array( - 'admin/structure/openlayers/maps/list', array($map['map_name']), - ), - ) - ); + $current_path = current_path(); + if ('system/ajax' == $current_path) { + $current_path = $_SESSION['current_path']; + } - $container_classes = implode(" ", array( - 'contextual-links-region', - 'openlayers-container', - 'openlayers-container-map-' . $css_map_name - )); + $links = array( + 'openlayers' => array( + 'title' => 'Edit', + 'href' => 'admin/structure/openlayers/maps/list/' . $map->machine_name . '/edit', + 'query' => array( + 'destination' => $current_path + ) + ), + ); - $build = array( - '#type' => 'container', + $container_classes = implode(" ", array( + 'contextual-links-region', + 'openlayers-container', + 'openlayers-container-map-' . $map->getId() + )); + + $build = array( + '#type' => 'container', + 'contextual_links' => array( + '#prefix' => '', + '#theme' => 'links__contextual', + '#links' => $links, + '#attributes' => array('class' => array('contextual-links')), + '#attached' => array( + 'library' => array(array('contextual', 'contextual-links')), + ), + ), + '#attributes' => array( + 'id' => 'openlayers-container-' . $map->getId(), + 'class' => $container_classes + ), + 'map' => array( + '#theme' => 'html_tag', + '#tag' => 'div', + '#value' => '', '#attributes' => array( - 'id' => 'openlayers-container-' . $map['id'], + 'id' => $map->getId(), 'style' => $css_styles, - 'class' => $container_classes + 'class' => 'openlayers-map openlayers-map-' . $map->getId() ), - 'map' => array( - '#theme' => 'html_tag', - '#tag' => 'div', - '#value' => '', - '#attributes' => array( - 'id' => $map['id'], - 'style' => $css_styles, - 'class' => 'openlayers-map openlayers-map-' . $css_map_name - ) + '#attached' => array( + 'js' => $attached['js'] ) - ); - - $build['#attached'] = array(); - $build['#attached']['js'] = array( - drupal_get_path('module', 'openlayers') . '/js/openlayers.js' => array( - 'weight' => -2 - ) - ); - $build['#attached']['css'] = array( - drupal_get_path('module', 'openlayers') . '/css/openlayers.css' - ); - - // Currently the restricted extent of maps is always given in EPSG:3857 so - // this projection needs to be available in the client for all restricted - // maps. Using EPSG:4326 instead would likely be better. - if(array_key_exists('restrict', $map['center']) && (boolean)$map['center']['restrict']['restrictextent']){ - $build['#attached']['js'][] = array( - 'data' => openlayers_add_js_projection_definition(openlayers_get_projection_by_identifier('EPSG:3857')), - 'type' => 'setting', - ); - } - - $build['#attached']['js'][] = array( - 'data' => openlayers_add_js_projection_definition(openlayers_get_projection_by_identifier($map['projection'])), - 'type' => 'setting', - ); - $build['#attached']['js'][] = array( - 'data' => openlayers_add_js_projection_definition(openlayers_get_projection_by_identifier($map['displayProjection'])), - 'type' => 'setting', - ); - - $build['#attached']['libraries_load'][] = array('proj4js'); - - foreach ($map['layers'] as $layer_name => $layer_object) { - $layer_object->render($map); - - if(in_array($map['projection'], $layer_object->data['projection'])){ - $map['layers'][$layer_name]->data['projection'] = $map['projection']; - } else { - // Client is able to reproject any possible projection because their definitions need to be - // known to be able to set up a layer with a certain projection. Thus choice does not matter. - $layerProjectionIdentifier = reset($layer_object->data['projection']); - if($layerProjectionIdentifier===FALSE){ - throw new Exception( - t('Layer !title lacks its projection. Please edit it to select a projection.', array( - '!title' => $layer['title'] - )) - ); - } - $map['layers'][$layer_name]->data['projection'] = $layerProjectionIdentifier; - } - - // In case the layer offers the same projection as the map, use this and do not provide - // projection definition to client. Otherwise rely on the client to reproject on the fly. - // Provide client with projection definition so that it can reproject - $build['#attached']['js'][] = array( - 'data' => openlayers_add_js_projection_definition(openlayers_get_projection_by_identifier($map['layers'][$layer_name]->data['projection'])), - 'type' => 'setting', - ); - - // Ensure JavaScript gets proper type. - $map['layers'][$layer_name]->data['isBaseLayer'] = (boolean)($layer_object->data['isBaseLayer']); - - - $map['layers'][$layer_name] = $layer_object->data; - $build['#attached'] = array_merge_recursive($build['#attached'], $layer_object->attached()); - } - foreach ($map['behaviors'] as $behavior_name => $behavior_object) { - $map['behaviors'][$behavior_name] = $behavior_object->options; - $build['#attached'] = array_merge_recursive($build['#attached'], $behavior_object->attached()); - } + ) + ); - $build['#attached']['js'][] = array( - 'data' => array('openlayers' => array('maps' => array($map['id'] => $map))), - 'type' => 'setting', - ); - $build['#map'] = $map['map_name']; + if ($map->getOption('contextualLinks') == FALSE) { + unset($build['contextual_links']); } - return $build; -} -/** - * Load projection transformations in case OpenLayers does not support projections in use natively - * @param openlayers_projection $projection - */ -function openlayers_add_js_projection_definition(openlayers_projection $projection) { - $openlayers_natively_supported = array('EPSG:4326', 'EPSG:900913'); - // Only load Proj4js if projection not supported by OpenLayers anyway - if (!in_array($projection->identifier, $openlayers_natively_supported)) { - return proj4js_load_definition_js_settings($projection->identifier, $projection->getDefinition()); - } + return $build; } -/** - * Render a map by name - * - * Given a map name render it into a full map object. - * - * @ingroup openlayers_api - * - * @param $map - * Name of the map - * @return - * Map HTML. - */ -function openlayers_render_map($map = '') { - - // If it's an array, then we have been passed the map data array - if (is_array($map)) { - $build = openlayers_render_map_data($map); - return render($build); - } - - // If it's a string, then we are passing a map name instead of the whole map object - // so we need to load the object - if (!$map || is_string($map)) { - $map_name = $map; - if (!$map_name) { - $map_name = variable_get('openlayers_default_map', 'default'); - } - $map = openlayers_map_load($map_name); - if (!is_object($map)) { - throw new Exception("Failed to load map called " . $map_name); - } - } - - $build = openlayers_render_map_data($map->data); +function openlayers_render_map(openlayers_map $map) { + $build = openlayers_render_build_map($map); return render($build); } /** - * Get layer object - * - * @ingroup openlayers_api - * @return openlayers_layer_type|FALSE - * array of layer info - */ -function openlayers_get_layer_object($layer, $map = array()) { - ctools_include('plugins'); - - // Static cache because this function will possibly be called in big loops - static $layer_types; - if (!isset($layer_types)) { - $layer_types = openlayers_layer_types(); - } - - $layer->title = t($layer->title); - $layer->description = t($layer->description); - - // Attempt to get ctool class - if (isset($layer_types[$layer->data['layer_type']]) && - $class = ctools_plugin_get_class( - $layer_types[$layer->data['layer_type']], - 'layer_type') - ) { - $layer_object = new $class($layer, $map); - return $layer_object; - } - else { - watchdog('openlayers', 'Layer !layer_name is unavailable because its - layer type or the module that provides its layer type is missing', - array('!layer_name' => $layer->title), - WATCHDOG_ERROR); - return FALSE; - } -} - -/** - * Menu loader for layers. (%openlayers_layer) - * @ingroup openlayers_api - * - * @param $name - * Layer name - * @param $reset - * Boolean whether to reset cache or not - * @return openlayers_layer_type|FALSE - * Layer export - */ -function openlayers_layer_load($name, $reset = FALSE) { - ctools_include('export'); - if ($reset) ctools_export_load_object_reset('openlayers_layers'); - $layer = ctools_export_load_object('openlayers_layers', 'names', array($name)); - - if (is_array($layer) && isset($layer[$name])) { - $layer_object = openlayers_get_layer_object($layer[$name]); - if (openlayers_layer_sanity_check($layer_object)) { - return $layer_object; - } - } - else { - return FALSE; - } -} - -/** - * Get all openlayers layers as objects. - * @ingroup openlayers_api - * - * @param $reset - * Boolean whether to reset cache or not - * @return array - * array of layer info - */ -function openlayers_layers_load($reset = FALSE, $include_disabled = FALSE) { - ctools_include('export'); - $layer_objects = array(); - if ($reset) ctools_export_load_object_reset('openlayers_layers'); - $layers = ctools_export_load_object('openlayers_layers', 'all', array()); - foreach ($layers as $layer) { - if (!$include_disabled && isset($layer->disabled) && $layer->disabled) { - continue; - } - - $layer_objects[$layer->name] = openlayers_get_layer_object($layer); - } - - return array_filter($layer_objects, 'openlayers_layer_sanity_check'); -} - -/** - * Check the plugin definition of a layer. - * Some field *MUST* be there to work correctly with OL. - * - * @ingroup openlayers_api - * @param $definition - * @return bool + * Implements hook_libraries_info(). */ -function openlayers_layer_definition_check($definition) { - $mandatory_fields = array( - array('title'), - array('description'), - array('name'), - array('path'), - array('layer_type', 'file'), - array('layer_type', 'class'), - array('layer_type', 'parent'), +function openlayers_libraries_info() { + $libraries['openlayers3'] = array( + 'name' => 'OpenLayers3', + 'vendor url' => 'http://openlayers.org/', + 'download url' => 'TODO', + 'version arguments' => array( + 'file' => 'build/ol.js', + 'pattern' => '@Version: (.*)@', + 'lines' => 3, + ), + 'files' => array( + 'js' => array('closure-library/closure/goog/base.js', 'build/ol-deps.js', 'build/ol.js'), + 'css' => array('css/ol.css') + ), + 'integration files' => array( + 'openlayers' => array( + 'js' => array('js/openlayers.js'), + 'css' => array('css/openlayers.css' => array('weight' => 10)) + ), + ), ); - foreach ($mandatory_fields as $field) { - $missing = drupal_array_nested_key_exists($definition, $field); - if (!$missing) { - drupal_set_message(t("Key !key is missing in in the plugin definition of the layer type !type. The layer will be disabled.", array( - '!key' => htmlspecialchars(implode(', ', $field)), - '!type' => htmlspecialchars($definition['name']), - )), 'warning'); - watchdog('openlayers', 'Layer !layer is unavailable because its - plugin definition is incomplete.', - array('!layer' => $definition['name']), - WATCHDOG_ERROR); - return FALSE; - } - } - - return TRUE; + return $libraries; } /** - * Check the plugin definition of a behavior. - * Some field *MUST* be there to work correctly with OL. + * Implements hook_element_info(). * - * @ingroup openlayers_api - * @param $definition - * @return bool + * @return array */ -function openlayers_behavior_definition_check($definition) { - $mandatory_fields = array( - array('title'), - array('description'), - array('name'), - array('path'), - array('type'), - array('behavior', 'file'), - array('behavior', 'class'), - array('behavior', 'parent'), +function openlayers_element_info() { + return array( + 'openlayers' => array( + '#input' => FALSE, + '#tree' => TRUE, + '#process' => array('openlayers_element_process_callback'), + '#theme_wrappers' => array('form_element') + ) ); - - foreach ($mandatory_fields as $field) { - $missing = drupal_array_nested_key_exists($definition, $field); - if (!$missing) { - drupal_set_message(t("Key !key is missing in the definition of the behavior !behavior. The behavior will be disabled.", array( - '!key' => htmlspecialchars(implode(', ', $field)), - '!behavior' => htmlspecialchars($definition['name']), - )), 'warning'); - watchdog('openlayers', 'Behavior !behavior is unavailable because its - plugin definition is incomplete.', - array('!behavior' => $definition['name']), - WATCHDOG_ERROR); - return FALSE; - } - } - - return TRUE; } - -/** - * Check layer to determine whether it has all the - * necessary attributes to be rendered. This is necessary - * because of API changes, and is a consolidation from other - * layer-error-checking in this module - * - * @param $layer - * Layer object - * @param $projection - * Projection number (EPSG) to check compatibility with - * @param $strict - * reject invalid layers - * @return boolean - * layer validity if strict is set, otherwise always true - */ -function openlayers_layer_sanity_check($layer, $projection = FALSE, $strict = FALSE) { - // Handle layers after they've been rendered for a map - $layer = (is_array($layer)) ? (object) $layer : $layer; - - if (!isset($layer->name)) { - return !$strict; - } - - if (!isset($layer->data['projection']) || !is_array($layer->data['projection'])) { - watchdog('openlayers', 'Layer %name does not have a projection set.', - array('%name' => $layer->name)); - drupal_set_message( - t('OpenLayers layers failed the sanity check. See the - Drupal log for details', - array('@drupallog' => url('admin/reports/dblog'))) - ); - return !$strict; - } - - if (!isset($layer->data['layer_type'])) { - watchdog('openlayers', 'Layer %name does not have its layer_type set.', - array('%name' => $layer->name)); - drupal_set_message( - t('OpenLayers layers failed the sanity check. See the - Drupal log for details', - array('@drupallog' => url('admin/reports/dblog'))) - ); - return !$strict; - } - - if ($projection && empty($layer->data['vector']) && - (!in_array($projection, $layer->data['projection']))) { - watchdog('openlayers', - 'The layer %layer_name cannot be reprojected to the map projection: EPSG: %map_proj', - array( - '%layer_name' => $layer->name, - // TODO: $map is not defined. - '%map_proj' => $map['projection'], - ) +function openlayers_element_process_callback($element, &$form_state) { + if (is_string($element['#map'])) { + $map = openlayers_object_load('map', $element['#map']); + $build = openlayers_render_map($map); + $element['map'] = array( + '#markup' => $build ); - return !$strict; - } - - return TRUE; -} - -/** - * Delete a layer object from the database. - * - * @ingroup openlayers_api - * - * @param $layer - * String identifier of a layer or layer object with name. - * @return - * The results of DB delete. - */ -function openlayers_layer_delete($layer) { - return openlayers_object_delete($layer, 'layer'); -} - -/** - * Get all layer types. - * - * @ingroup openlayers_api - * - * @param $reset - * Boolean whether to reset cache or not. - * @return - * Array of layer type info. - */ -function openlayers_layer_types($reset = FALSE, $include_disabled = FALSE) { - ctools_include('plugins'); - $layers = ctools_get_plugins('openlayers', 'layer_types'); - - if (!$include_disabled) { - $layers = array_filter($layers, 'openlayers_object_enabled'); } - return array_filter($layers, 'openlayers_layer_definition_check'); -} - -/** - * Confirm that an object is not disabled. - * - * @ingroup openlayers_api - * - * @param Object $object - * An object -- a layer, behavior, style or map. - * - * @return Boolean - * Returns TRUE if the object is not disabled. - */ -function openlayers_object_enabled($object) { - return (!isset($object->disabled) || !$object->disabled); -} - -/** - * Menu loader for layer types. - * - * @ingroup openlayers_api - * - * @param $name - * String identifier of layer type. - * @param $reset - * Boolean whether to reset cache or not. - * @return openlayers_layer_type - * An instantiated layer type object or FALSE if not found. - */ -function openlayers_layer_type_load($name, $reset = FALSE) { - ctools_include('plugins'); - - if ($layer_type_class = ctools_plugin_load_class( - 'openlayers', - 'layer_types', - $name, - 'layer_type')) { - $layer_type = new $layer_type_class(); - return $layer_type; - } - return FALSE; + return $element; } /** - * Get all behaviors. - * - * @ingroup openlayers_api - * - * @param $reset - * Boolean whether to reset cache or not. - * @return - * Array of behavior info. + * Implements hook_block_info(). */ -function openlayers_behaviors($reset = FALSE, $include_disabled = FALSE) { - ctools_include('plugins'); - $behaviors = ctools_get_plugins('openlayers', 'behaviors'); +function openlayers_block_info() { + ctools_include('export'); + $all_maps = ctools_export_crud_load_all('openlayers_maps'); + $blocks = array(); - if (!$include_disabled) { - $behaviors = array_filter($behaviors, 'openlayers_object_enabled'); + foreach ($all_maps as $key => $map) { + $map = openlayers_object_load('map', $map->machine_name); + if ($map->getOption('provideBlock', 1)) { + $blocks[$key]['info'] = t('OpenLayers block for ' . $map->name); + } } - return array_filter($behaviors, 'openlayers_behavior_definition_check'); - + return $blocks; } /** - * Get all openlayers styles. - * - * @ingroup openlayers_api - * - * @param $reset - * Boolean whether to reset cache or not. - * @return - * Array of all available styles. + * Implements hook_block_view(). */ -function openlayers_styles($reset = FALSE, $include_disabled = FALSE) { +function openlayers_block_view($delta = '') { ctools_include('export'); - if ($reset) { - ctools_export_load_object_reset('openlayers_styles'); - } - - $styles = ctools_export_load_object('openlayers_styles', 'all', array()); + $block = array(); - if (!$include_disabled) { - $styles = array_filter($styles, 'openlayers_object_enabled'); + if ($map = openlayers_object_load('map', $delta)) { + if ($map->getOption('provideBlock', 1)) { + $block['subject'] = $map->name; + $block['content'] = openlayers_render_map($map); + } } - return $styles; -} - -/** - * Load a style object by name. - * - * This function can also be used as a - * menu loader for a style. - * - * @ingroup openlayers_api - * - * @param $name - * The string identifier of the style. - * @param $reset - * Boolean whether to reset the cache or not. - * @return - * A style object or FALSE if not found. - */ -function openlayers_style_load($name, $reset = FALSE) { - $styles = openlayers_styles($reset); - return !empty($styles[$name]) ? $styles[$name] : FALSE; -} - -/** - * Save style. - * - * @ingroup openlayers_api - * - * @param $style - * The style object to save. - * @return - * The results of DB write or FALSE if no name. - */ -function openlayers_style_save($style) { - if (!empty($style->name)) { - return (db_select('openlayers_styles') - ->fields('openlayers_styles', array('name')) - ->condition('name', $style->name) - ->execute() - ->fetchCol()) ? - drupal_write_record('openlayers_styles', $style, 'name') : - drupal_write_record('openlayers_styles', $style); - } - return FALSE; + return $block; } - -/** - * Delete a style object from the database. - * - * @ingroup openlayers_api - * - * @param $style - * String identifier of a style or style object with name. - * @return - * The results of DB delete. - */ -function openlayers_style_delete($style) { - return openlayers_object_delete($style, 'style'); -} - -/** - * Get maps from DB or code, via cache. - * - * @ingroup openlayers_api - * - * @param $reset - * Boolean whether to reset or not. - * @return - * Return array of maps. - */ -function openlayers_maps($reset = FALSE, $include_disabled = FALSE) { - ctools_include('export'); - if ($reset) { - ctools_export_load_object_reset('openlayers_maps'); - } - - $maps = ctools_export_load_object('openlayers_maps', 'all', array()); - - if (!$include_disabled) { - $maps = array_filter($maps, 'openlayers_object_enabled'); - } - - return $maps; -} - -/** - * Given a map name, get full map object. - * - * This function can also be used as a - * menu loader for a style. - * - * @ingroup openlayers_api - * - * @param $name - * String identifier of the map. - * @param $reset - * Boolean whether to reset cache. - * @return - * map object or FALSE if not found. - */ -function openlayers_map_load($name = '', $reset = FALSE) { - ctools_include('export'); - if ($reset) { - ctools_export_load_object_reset('openlayers_maps'); - } - - $maps = ctools_export_load_object('openlayers_maps', 'names', array($name)); - - if (empty($maps[$name])) { - return FALSE; - } - else { - $map = $maps[$name]; - $map->data['map_name'] = $name; - return clone $map; - } -} - -/** - * Save a map object to the database. - * - * @ingroup openlayers_api - * - * @param $map - * map object. - * @return - * The results of DB write or FALSE if no name. - */ -function openlayers_map_save($map) { - if (!empty($map->name)) { - return (db_select('openlayers_maps') - ->fields('openlayers_maps', array('name')) - ->condition('name', $map->name) - ->execute() - ->fetchCol()) ? - drupal_write_record('openlayers_maps', $map, 'name') : - drupal_write_record('openlayers_maps', $map); - } - return FALSE; -} - -/** - * Delete a map object from the database. - * - * @ingroup openlayers_api - * - * @param $map - * String identifier of a map or map object with name. - * @return - * The results of DB delete. - */ -function openlayers_map_delete($map) { - return openlayers_object_delete($map, 'map'); -} - -/** - * Get map options in an array suitable for a FormAPI element. - * - * @ingroup openlayers_api - * - * @param $reset - * Boolean whether to reset or not. - * @return - * Return array of formatted data. - */ -function openlayers_map_options($reset = FALSE) { - $maps = openlayers_maps($reset); - $options = array(); - foreach ($maps as $map) { - $options[$map->name] = $map->title; - } - return $options; -} - -/** - * Delete an object from the database. - * - * @ingroup openlayers_api - * - * @param $ol_object - * String identifier of an object or the object with name. - * @param $type - * Type of object to delete. The options are the following: - * - 'layer' - * - 'style' - * = 'map' - * @return - * The results of the DB delete. - */ -function openlayers_object_delete($ol_object, $type) { - // Check for object or name - $tables = array( - 'style' => 'openlayers_styles', - 'layer' => 'openlayers_layers', - 'map' => 'openlayers_maps'); - if (is_object($ol_object) && isset($ol_object->name) && isset($tables[$type])) { - $ol_object = $ol_object->name; - return db_delete($tables[$type])->condition('name', $ol_object)->execute(); - } -} - -/** - * Checks map array for incompatibilities or errors. - * - * @ingroup openlayers_api - * - * @param $map - * Map array - * @param $log_errors - * Boolean whether to log errors. - * @return - * FALSE if passed. Array of descriptive errors if fail. - */ -function openlayers_error_check_map($map, $log_errors = TRUE) { - $errors = array(); - - // Check for layers - if (!is_array($map['layers'])) { - $errors[] = t('Map contains no renderable layers.'); - } - else { - // Check layer projections - foreach ($map['layers'] as $layer) { - openlayers_layer_sanity_check( - array('data' => $layer), - $map['projection'], - TRUE); - } - } - - // Check if any errors found to log - if (count($errors) > 0 && $log_errors) { - // Log the Error(s) - watchdog('openlayers', implode(', ', $errors), array(), WATCHDOG_ERROR); - } - - // Check if errors and return - return (count($errors) > 0) ? $errors : FALSE; -} - -/** - * Models a projection, a description of a coordinate system. - */ -class openlayers_projection { - /** - * @var String Opaque primary key (should not be exposed but ctools API doesn't allow for a more rigid structure) - */ - public $identifier; - - /** - * @var String proj4 definition for on-the-fly reprojections of vector data. - */ - private $definition; - - /** - * @var number Leftmost boundary where coordinate system is valid - */ - private $projectedextentleft; - /** - * @var number Bottommost boundary where coordinate system is valid - */ - private $projectedextentbottom; - /** - * @var number Rightmost boundary where coordinate system is valid - */ - private $projectedextentright; - /** - * @var number Topmost boundary where coordinate system is valid - */ - private $projectedextenttop; - - public function __construct($identifier, $definition, $projectedextentleft, $projectedextentbottom, $projectedextentright, $projectedextenttop) { - $this->identifier = $identifier; - $this->definition = $definition; - $this->projectedextentleft = $projectedextentleft; - $this->projectedextentbottom = $projectedextentbottom; - $this->projectedextentright = $projectedextentright; - $this->projectedextenttop = $projectedextenttop; - } - - /** - * @return string Textual representation for the user. - */ - public function getLocalizedMessage() { - return $this->identifier; - } - - /** - * @return array Boundaries of projection in projected coordinates - */ - public function getProjectedExtent() { - return array_map('floatval', array($this->projectedextentleft, $this->projectedextentbottom, $this->projectedextentright, $this->projectedextenttop)); - } - - /** - * @return String Proj4 style definition - */ - public function getDefinition() { - return $this->definition; - } -} - -/** - * @param stdClass $record Object as returned by ctools_export_crud_load for type openlayers_projections - * @return openlayers_projection - */ -function openlayers_projection_from_record($record) { - return new openlayers_projection($record->identifier, $record->definition, - $record->projectedextentleft, $record->projectedextentbottom, $record->projectedextentright, $record->projectedextenttop); -} - -/** - * @param String $authority Organization who defined the code - * @param String $code Projection identifier - * @return openlayers_projection - */ -function openlayers_get_projection($authority, $code) { - static $projections; - if (!isset($projections)) { - $projections = array(); - } - $identifier = $authority . ':' . $code; - if (!array_key_exists($identifier, $projections)) { - $projections[$identifier] = openlayers_get_projection_by_identifier($identifier); - } - return $projections[$identifier]; -} - -/** - * @param String $identifier Identifier, such as “EPSG:4326” - * @return openlayers_projection - */ -function openlayers_get_projection_by_identifier($identifier) { - ctools_include('export'); - - $records = ctools_export_load_object('openlayers_projections', 'names', array($identifier)); - - if (empty($records)) { - if(mb_strpos($identifier, ':')===FALSE){ - throw new Exception(t("Projection !projection lacks an authority code. Read http://drupal.org/node/1944074 for hints.", array( - '!projection' => $identifier - ))); - } - throw new Exception(t("Projection !projection requested but not supported.", array( - '!projection' => $identifier - ))); - } - return openlayers_projection_from_record($records[key($records)]); -} - -/** - * @return array - */ -function openlayers_get_all_projections($reset = FALSE, $include_disabled = FALSE) { - ctools_include('export'); - $projections = array(); - - foreach (ctools_export_crud_load_all('openlayers_projections', $reset) as $record) { - if (!$include_disabled && isset($record->disabled) && $record->disabled) { - continue; - } - - $projections[] = openlayers_projection_from_record($record); - } - - return $projections; -} - -/** - * Rerenders form part “Layers & Styles” when map projections changes - * @param array $form - * @param array $form_state - * @return array Form part to rerender - */ -function openlayers_map_layerlist(&$form, &$form_state) { - module_load_include('inc', 'openlayers_ui', '/include/openlayers_ui.theme'); - - // Remove group property as Drupal otherwise returns NULL instead of the rendered form part - unset($form['layerstyles']['#group']); - // Force a diffent, fixed identifier so that the form part can reliably replaced - $form['layerstyles']['#id']= 'edit-layerstyles'; - // Rerender the form part - return $form['layerstyles']; -} - -/** - * Get extent given projection - * - * Returns standard world-max-extents for common projections. - * Layers implementing other projections and subsets of the - * world should define their maxExtent in the layer array. - * - * @ingroup openlayers_api - * - * @param $authority - * String Organization code, such as EPSG. - * @param $projection - * String of the projection value, such as 4326. - * @return - * Array of maxExtent in OpenLayers toArray() format. - */ -function openlayers_get_extent($authority, $projection) { - // Use projected extend from openlayers_projection instead but keep this function for now as it's marked as API - return openlayers_get_projection($authority, $projection)->getProjectedExtent(); -} - -/** - * Get resolution given projection - * - * Returns a default set of resolutions for standard - * TMS, WMS, etc servers serving up common projections. - * Layers supporting less common projections and resolutions - * can easily define custom resolutions arrays. - * - * @ingroup openlayers_api - * - * @param $projection - * String specifying which projection this should take, like EPSG:900913. - * @param $zoom_start - * Integer of first zoom level, default 0. - * @param $zoom_end - * Integer of last zoom level, default FALSE. - * @return - * Array of resolutions. - */ -function openlayers_get_resolutions($projection, $zoom_start = 0, $zoom_end = FALSE) { - // TODO This is conceptually flawed and should not exist. Resolutions depend on the server in use in combination with the tile size. - switch ($projection) { - case 'EPSG:900913': - // 16 zoom levels, taken from - // openlayers.org TMS map - $res = array( - 156543.0339, - 78271.51695, - 39135.758475, - 19567.8792375, - 9783.93961875, - 4891.969809375, - 2445.9849046875, - 1222.99245234375, - 611.496226171875, - 305.7481130859375, - 152.87405654296876, - 76.43702827148438, - 38.21851413574219, - 19.109257067871095, - 9.554628533935547, - 4.777314266967774, - 2.388657133483887, - 1.1943285667419434, - 0.5971642833709717, - 0.29858214169740677, - 0.14929107084870338, - 0.07464553542435169 - ); - break; - case 'EPSG:4326': - // 16 zoom levels, taken from - // openlayers.org default WMS map - $res = array( - 0.703125, - 0.3515625, - 0.17578125, - 0.087890625, - 0.0439453125, - 0.02197265625, - 0.010986328125, - 0.0054931640625, - 0.00274658203125, - 0.001373291015625, - 0.0006866455078125, - 0.00034332275390625, - 0.000171661376953125, - 0.0000858306884765625, - 0.00004291534423828125, - 0.000021457672119140625, - 0.000010728836059570312, - ); - break; - default: - $res = array(); - break; - } - $length = ($zoom_end == FALSE) ? NULL : $zoom_end - $zoom_start; - // By default this will not actually clip the array - $resolutions = array_slice($res, $zoom_start, $length); - - return $resolutions; -} - -/** - * We define base classes in the core module. - * All other parent classes can be autoloaded through ctools. - */ -class openlayers_behavior { - var $options; - - protected $map; - - function __construct($options = array(), $map = array()) { - $this->options = $options + $this->options_init(); - $this->map = $map; - } - - /* - * @return array of JavaScript functions required to be defined - * in order for this function to work - */ - function js_dependency() { - return array(); - } - - function options_init() { - return array(); - } - - /* - * @param $defaults default values for the form as an array - * @return a FormAPI form - */ - function options_form($defaults = array()) { - return array(); - } - - function attached() { - return array(); - } - - function render(&$map) {} -} - -/** - * We define base classes in the core module. - * All other parent classes can be autoloaded through ctools. - */ -class openlayers_layer_type { - - /** - * Stores the options for this layer. - * @var array - */ - public $data = array(); - - /** - * Set configuration and store map. - * - * @param stdClass $layer - * Configuration object with the options for the layer. - * @param $map - * Array with the current map. - */ - function __construct($layer = array(), $map = array()) { - foreach (array('name', 'title', 'description', 'data', 'export_type') as $k) { - if (isset($layer->{$k})) { - $this->{$k} = $layer->{$k}; - } - } - - // Extend options with the defaults. - $this->data += $this->options_init(); - } - - /** - * @return array - * List of all projections that are supported by the layer. - */ - public function getProjections() { - $projections = array(); - // TODO Ignore incomplete data until cause is fixed (projection for every layer set during migration) - if (isset($this->data['projection'])) { - foreach ($this->data['projection'] as $projection) { - $projections[] = openlayers_get_projection_by_identifier($projection); - } - } - return $projections; - } - - /** - * Provides the default options for the layer. - * - * @return - * An associative array with the default options. - */ - function options_init() { - return array( - 'layer_type' => get_class($this), - 'isBaseLayer' => TRUE, - // TODO: Remove hard-coded resolutions - 'projection' => array('EPSG:900913'), - 'serverResolutions' => openlayers_get_resolutions('EPSG:900913'), - 'resolutions' => openlayers_get_resolutions('EPSG:900913'), - 'base_url' => NULL, - 'transitionEffect' => 'resize', - 'weight' => 0 - ); - } - - /** - * Options form to configure layer instance options. - * - * @return - * Array with form elements. - */ - function options_form($default = array()) { - $allProjectionOptions = array(); - foreach (openlayers_get_all_projections() as $projection) { - $allProjectionOptions[$projection->identifier] = $projection->getLocalizedMessage(); - } - return array( - 'projection' => array( - '#type' => 'select', - '#title' => t('Projection'), - '#multiple' => TRUE, - '#options' => $allProjectionOptions, - '#default_value' => isset($default->data['projection']) ? - $default->data['projection'] : - openlayers_get_projection('EPSG', '3857')->identifier - ), - 'isBaseLayer' => array( - '#type' => 'checkbox', - '#title' => t('Base Layer'), - '#description' => t('Uncheck to make this map an overlay'), - '#default_value' => !empty($default->data['isBaseLayer']) ? - $default->data['isBaseLayer'] : FALSE - ), - ); - } - - /** - * Validate the options_form(). - * - * @param array $default - */ - function options_form_validate($form, &$form_state) { - - } - - /** - * Submit the options_form(). - * - * @param array $form - * @param array $form_state - */ - function options_form_submit($form, &$form_state) { - $form_state['values']['data']['projection'] = array_keys($form_state['values']['data']['projection']); - // TODO Resolutions should be processed only in layers - // that provide a form field for it. - $form_state['values']['data']['resolutions'] = array_map('floatval', array_values($form_state['values']['data']['resolutions'])); - } - - /** - * Options form to configure layer-type-wide options. - * - * @return - * Array with form elements. - */ - function settings_form() { - return array(); - } - - function attached() { - return array(); - } - - /** - * Render the layer and return the layer options. - * - * Has no return value. - * - * @param $map - */ - function render(&$map) {} - -} - -/** - * Implements hook_ctools_plugin_api(). - */ -function openlayers_ctools_plugin_api($module, $api) { - if ($module == "openlayers") { - switch ($api) { - case 'openlayers_maps': - return array('version' => 1); - - case 'openlayers_layers': - return array('version' => 1); - - case 'openlayers_projections': - return array('version' => 1); - - case 'openlayers_styles': - return array('version' => 1); - - case 'openlayers_layer_types': - return array('version' => 1); - - case 'openlayers_behaviors': - return array('version' => 1); - - } - } - elseif ($module == 'boxes' && $api == 'plugins') { - return array('version' => 1); - } -} - -/** - * Implements hook_openlayers_behaviors(). - */ -function openlayers_openlayers_behaviors() { - module_load_include('inc', 'openlayers', 'includes/openlayers.behaviors'); - return _openlayers_openlayers_behaviors(); -} - -/** - * Implements hook_openlayers_layer_types(). - */ -function openlayers_openlayers_layer_types() { - module_load_include('inc', 'openlayers', 'includes/openlayers.layer_types'); - return _openlayers_openlayers_layer_types(); -} - -/** - * Implements hook_openlayers_layers(). - */ -function openlayers_openlayers_layers() { - module_load_include('inc', 'openlayers', 'includes/openlayers.layers'); - return _openlayers_openlayers_layers(); -} - -/** - * Implements hook_openlayers_projections(). - */ -function openlayers_openlayers_projections() { - module_load_include('inc', 'openlayers', 'includes/openlayers.projections'); - return _openlayers_openlayers_projections(); -} - -/** - * Implements hook_openlayers_styles(). - */ -function openlayers_openlayers_styles() { - module_load_include('inc', 'openlayers', 'includes/openlayers.styles'); - return _openlayers_openlayers_styles(); -} - -/** - * Implements hook_openlayers_maps(). - */ -function openlayers_openlayers_maps() { - module_load_include('inc', 'openlayers', 'includes/openlayers.maps'); - return _openlayers_openlayers_maps(); -} - -/** - * Implements hook_boxes_plugins(). - */ -function openlayers_boxes_plugins() { - return array( - 'openlayers_simple' => array( - 'title' => 'OpenLayers', - 'handler' => array( - 'parent' => 'boxes_box', - 'class' => 'openlayers_simple', - 'file' => 'openlayers_simple.inc', - 'path' => drupal_get_path('module', 'openlayers') . '/plugins/boxes' - ) - ) - ); -} - -/** - * Implements hook_quicktabs_contents(). - */ -function openlayers_quicktabs_contents() { - $info = array(); - $path = drupal_get_path('module', 'openlayers') . '/plugins/quicktabs'; - $info['map'] = array( - 'path' => $path, - 'handler' => array( - 'file' => 'QuickMap.inc', - 'class' => 'QuickMap', - ), - ); - return $info; -} - -/** - * Implements hook_libraries_info(). - */ -function openlayers_libraries_info() { - $libraries['openlayers'] = array( - 'name' => 'OpenLayers', - 'vendor url' => 'http://openlayers.org/', - 'download url' => 'http://openlayers.org/download/OpenLayers-2.13.tar.gz', - 'version arguments' => array( - 'file' => 'lib/OpenLayers.js', - 'pattern' => '/OpenLayers.VERSION_NUMBER="Release (.*?)"/', - 'lines' => 1000, - ), - 'files' => array( - 'js' => array('OpenLayers.js'), - ), - 'variants' => array( - 'original debug' => array( - 'files' => array( - 'js' => array( - 'OpenLayers.debug.js' - ), - ), - ), - 'light' => array( - 'files' => array( - 'js' => array( - 'OpenLayers.light.js' - ), - ), - ), - 'light debug' => array( - 'files' => array( - 'js' => array( - 'OpenLayers.light.debug.js' - ), - ), - ), - 'mobile' => array( - 'files' => array( - 'js' => array( - 'OpenLayers.mobile.js' - ) - ), - ), - 'mobile debug' => array( - 'files' => array( - 'js' => array( - 'OpenLayers.mobile.debug.js' - ) - ), - ), - ), - 'integration files' => array( - 'openlayers' => array( - 'js' => array('js/openlayers.js'), - 'css' => array('css/openlayers.css') - ), - ), - ); - - return $libraries; -} - -/** - * Implements hook_element_info(). - * - * @return array - */ -function openlayers_element_info() { - return array( - 'openlayers' => array( - '#pre_render' => array('openlayers_element_pre_render_callback'), - '#theme_wrappers' => array('form_element') - ) - ); -} - -/** - * Callback. - * - * @param $element - * @return mixed - */ -function openlayers_element_pre_render_callback($element) { - if (is_string($element['#map'])) { - $map = openlayers_map_load($element['#map']); - $element += openlayers_render_map_data($map->data); - } - - return $element; -} - diff --git a/plugins/behaviors/openlayers_behavior_argparser.inc b/plugins/behaviors/openlayers_behavior_argparser.inc deleted file mode 100644 index 302b969fe4c07abc83674cff5f6fc186b6f35c1e..0000000000000000000000000000000000000000 --- a/plugins/behaviors/openlayers_behavior_argparser.inc +++ /dev/null @@ -1,42 +0,0 @@ - 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, - ), - ); - } - - function attached() { - return array( - 'js' => array( - drupal_get_path('module', 'openlayers') . '/plugins/behaviors/openlayers_behavior_argparser.js' - ) - ); - } -} diff --git a/plugins/behaviors/openlayers_behavior_argparser.js b/plugins/behaviors/openlayers_behavior_argparser.js deleted file mode 100644 index f16bec0aea904c7db2fb65938a592db7392a3669..0000000000000000000000000000000000000000 --- a/plugins/behaviors/openlayers_behavior_argparser.js +++ /dev/null @@ -1,12 +0,0 @@ -/** - * @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); -}); diff --git a/plugins/behaviors/openlayers_behavior_attribution.inc b/plugins/behaviors/openlayers_behavior_attribution.inc deleted file mode 100644 index 51995858620384224f5912dde2a14284042a124d..0000000000000000000000000000000000000000 --- a/plugins/behaviors/openlayers_behavior_attribution.inc +++ /dev/null @@ -1,42 +0,0 @@ - '', - ); - } - - function js_dependency() { - return array('OpenLayers.Control.Attribution'); - } - - function options_form($defaults = array()) { - return array( - 'separator' => array( - '#type' => 'textfield', - '#title' => t('separator'), - '#description' => t('For multiple layers that need attribution, provide a separation string.'), - '#default_value' => (isset($defaults['separator'])) ? $defaults['separator'] : FALSE, - ), - ); - } - - function attached() { - return array( - 'js' => array( - drupal_get_path('module', 'openlayers') . '/plugins/behaviors/openlayers_behavior_attribution.js' - ) - ); - } -} diff --git a/plugins/behaviors/openlayers_behavior_attribution.js b/plugins/behaviors/openlayers_behavior_attribution.js deleted file mode 100644 index 1be8655e27459ccef44258a55e8f3496ecd97857..0000000000000000000000000000000000000000 --- a/plugins/behaviors/openlayers_behavior_attribution.js +++ /dev/null @@ -1,12 +0,0 @@ -/** - * @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); -}); diff --git a/plugins/behaviors/openlayers_behavior_boxselect.inc b/plugins/behaviors/openlayers_behavior_boxselect.inc deleted file mode 100644 index d06aecddc7138540bfc36d7b06cb4de32260da43..0000000000000000000000000000000000000000 --- a/plugins/behaviors/openlayers_behavior_boxselect.inc +++ /dev/null @@ -1,40 +0,0 @@ - '', - ); - } - - function js_dependency() { - return array( - 'OpenLayers.Control.DrawFeature', - 'OpenLayers.Layer.Vector', - 'OpenLayers.Handler.RegularPolygon' - ); - } - - function options_form($defaults = array()) { - return array( - ); - } - - function attached() { - return array( - 'js' => array( - drupal_get_path('module', 'openlayers') . '/plugins/behaviors/openlayers_behavior_boxselect.js' - ), - ); - } -} diff --git a/plugins/behaviors/openlayers_behavior_boxselect.js b/plugins/behaviors/openlayers_behavior_boxselect.js deleted file mode 100644 index 19404b3123fb222654e174da4a85061a0babbed3..0000000000000000000000000000000000000000 --- a/plugins/behaviors/openlayers_behavior_boxselect.js +++ /dev/null @@ -1,59 +0,0 @@ -/** - * @file - * JS Implementation of OpenLayers behavior. - */ - -// Not the best, but gets around scoping; -var selections_layer; - -/** - * 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(); - jQuery('#edit-center-restrict-restrictedextent').val(bounding_box); - - // Check box - if (!(jQuery('#restrictextent').attr('checked'))) { - jQuery('#restrictextent') - .attr('checked', 'checked') - .trigger('change'); - } - - // Remove any other features. - jQuery(selections_layer.features).each(function(index, feature) { - if (feature != box) { - selections_layer.features[index].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 (jQuery('#edit-center-restrict-restrictedextent').val()) { - bounds = jQuery('#edit-center-restrict-restrictedextent').val(); - geometry = new OpenLayers.Bounds.fromString(bounds).toGeometry(); - feature = new OpenLayers.Feature.Vector(geometry); - selections_layer.addFeatures([feature]); - } - control.activate(); -}); diff --git a/plugins/behaviors/openlayers_behavior_cluster.inc b/plugins/behaviors/openlayers_behavior_cluster.inc deleted file mode 100644 index 0a14e4710a9d09ce0b094bae53c65c5aeb4c3077..0000000000000000000000000000000000000000 --- a/plugins/behaviors/openlayers_behavior_cluster.inc +++ /dev/null @@ -1,292 +0,0 @@ - array(), - 'distance' => '20', - 'threshold' => NULL, - 'display_cluster_numbers' => TRUE, - 'middle_lower_bound' => '15', - 'middle_upper_bound' => '50', - 'low_color' => 'rgb(141, 203, 61)', - 'low_stroke_color' => 'rgb(141, 203, 61)', - 'low_opacity' => '0.8', - 'low_point_radius' => '10', - 'low_label_outline' => '1', - 'middle_color' => 'rgb(49, 190, 145)', - 'middle_stroke_color' => 'rgb(49, 190, 145)', - 'middle_opacity' => '0.8', - 'middle_point_radius' => '16', - 'middle_label_outline' => '1', - 'high_color' => 'rgb(35, 59, 177)', - 'high_stroke_color' => 'rgb(35, 59, 177)', - 'high_opacity' => '0.8', - 'high_point_radius' => '22', - 'high_label_outline' => '1', - 'label_low_color' => '#000000', - 'label_low_opacity' => '0.8', - 'label_middle_color' => '#000000', - 'label_middle_opacity' => '0.8', - 'label_high_color' => '#000000', - 'label_high_opacity' => '0.8', - ); - } - - /** - * 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'), - ), - 'display_cluster_numbers' => array( - '#type' => 'checkbox', - '#title' => t('Display numbers in clusters?'), - '#default_value' => isset($defaults['display_cluster_numbers']) ? $defaults['display_cluster_numbers'] : TRUE - ), - 'middle_lower_bound' => array( - '#type' => 'textfield', - '#default_value' => (isset($defaults['middle_lower_bound'])) ? - $defaults['middle_lower_bound'] : 15, - '#size' => 5, - '#title' => t('Middle lower bound'), - '#description' => t(''), - ), - 'middle_upper_bound' => array( - '#type' => 'textfield', - '#default_value' => (isset($defaults['middle_upper_bound'])) ? - $defaults['middle_upper_bound'] : 50, - '#size' => 5, - '#title' => t('Middle upper bound'), - '#description' => t(''), - ), - 'low_color' => array( - '#type' => 'textfield', - '#default_value' => (isset($defaults['low_color'])) ? - $defaults['low_color'] : 'rgb(141, 203, 61)', - '#size' => 5, - '#title' => t('Low color'), - '#description' => t(''), - ), - 'low_stroke_color' => array( - '#type' => 'textfield', - '#default_value' => (isset($defaults['low_stroke_color'])) ? - $defaults['low_stroke_color'] : 'rgb(141, 203, 61)', - '#size' => 5, - '#title' => t('Low stroke color'), - '#description' => t(''), - ), - 'low_opacity' => array( - '#type' => 'textfield', - '#default_value' => (isset($defaults['low_opacity'])) ? - $defaults['low_opacity'] : '0.8', - '#size' => 5, - '#title' => t('Low opacity'), - '#description' => t(''), - ), - 'low_point_radius' => array( - '#type' => 'textfield', - '#default_value' => (isset($defaults['low_point_radius'])) ? - $defaults['low_point_radius'] : '10', - '#size' => 5, - '#title' => t('Low point radius'), - '#description' => t(''), - ), - 'low_label_outline' => array( - '#type' => 'textfield', - '#default_value' => (isset($defaults['low_label_outline'])) ? - $defaults['low_label_outline'] : '1', - '#size' => 5, - '#title' => t('Low label outline'), - '#description' => t(''), - ), - 'middle_color' => array( - '#type' => 'textfield', - '#default_value' => (isset($defaults['middle_color'])) ? - $defaults['middle_color'] : 'rgb(49, 190, 145)', - '#size' => 5, - '#title' => t('Middle color'), - '#description' => t(''), - ), - 'middle_stroke_color' => array( - '#type' => 'textfield', - '#default_value' => (isset($defaults['middle_stroke_color'])) ? - $defaults['middle_stroke_color'] : 'rgb(49, 190, 145)', - '#size' => 5, - '#title' => t('Middle stroke color'), - '#description' => t(''), - ), - 'middle_opacity' => array( - '#type' => 'textfield', - '#default_value' => (isset($defaults['middle_opacity'])) ? - $defaults['middle_opacity'] : '0.8', - '#size' => 5, - '#title' => t('Middle opacity'), - '#description' => t(''), - ), - 'middle_point_radius' => array( - '#type' => 'textfield', - '#default_value' => (isset($defaults['middle_point_radius'])) ? - $defaults['middle_point_radius'] : '16', - '#size' => 5, - '#title' => t('Middle point radius'), - '#description' => t(''), - ), - 'middle_label_outline' => array( - '#type' => 'textfield', - '#default_value' => (isset($defaults['middle_label_outline'])) ? - $defaults['middle_label_outline'] : '1', - '#size' => 5, - '#title' => t('Middle label outline'), - '#description' => t(''), - ), - 'high_color' => array( - '#type' => 'textfield', - '#default_value' => (isset($defaults['high_color'])) ? - $defaults['high_color'] : 'rgb(35, 59, 177)', - '#size' => 5, - '#title' => t('High color'), - '#description' => t(''), - ), - 'high_stroke_color' => array( - '#type' => 'textfield', - '#default_value' => (isset($defaults['high_stroke_color'])) ? - $defaults['high_stroke_color'] : 'rgb(35, 59, 177)', - '#size' => 5, - '#title' => t('High stroke color'), - '#description' => t(''), - ), - 'high_opacity' => array( - '#type' => 'textfield', - '#default_value' => (isset($defaults['high_opacity'])) ? - $defaults['high_opacity'] : '0.8', - '#size' => 5, - '#title' => t('High opacity'), - '#description' => t(''), - ), - 'high_point_radius' => array( - '#type' => 'textfield', - '#default_value' => (isset($defaults['high_point_radius'])) ? - $defaults['high_point_radius'] : '22', - '#size' => 5, - '#title' => t('High point radius'), - '#description' => t(''), - ), - 'high_label_outline' => array( - '#type' => 'textfield', - '#default_value' => (isset($defaults['high_label_outline'])) ? - $defaults['high_label_outline'] : '1', - '#size' => 5, - '#title' => t('High label outline'), - '#description' => t(''), - ), - 'label_low_color' => array( - '#type' => 'textfield', - '#default_value' => (isset($defaults['label_low_color'])) ? - $defaults['label_low_color'] : '#000000', - '#size' => 5, - '#title' => t('Text low color'), - '#description' => t(''), - ), - 'label_low_opacity' => array( - '#type' => 'textfield', - '#default_value' => (isset($defaults['label_low_opacity'])) ? - $defaults['label_low_opacity'] : '0.8', - '#size' => 5, - '#title' => t('Text low opacity'), - '#description' => t(''), - ), - 'label_middle_color' => array( - '#type' => 'textfield', - '#default_value' => (isset($defaults['label_middle_color'])) ? - $defaults['label_middle_color'] : '#000000', - '#size' => 5, - '#title' => t('Text middle color'), - '#description' => t(''), - ), - 'label_middle_opacity' => array( - '#type' => 'textfield', - '#default_value' => (isset($defaults['label_middle_opacity'])) ? - $defaults['label_middle_opacity'] : '0.8', - '#size' => 5, - '#title' => t('Text middle opacity'), - '#description' => t(''), - ), - 'label_high_color' => array( - '#type' => 'textfield', - '#default_value' => (isset($defaults['label_high_color'])) ? - $defaults['label_high_color'] : '#000000', - '#size' => 5, - '#title' => t('Text high color'), - '#description' => t(''), - ), - 'label_high_opacity' => array( - '#type' => 'textfield', - '#default_value' => (isset($defaults['label_high_opacity'])) ? - $defaults['label_high_opacity'] : '0.8', - '#size' => 5, - '#title' => t('Text high opacity'), - '#description' => t(''), - ), - ); - } - - function attached() { - return array( - 'js' => array( - drupal_get_path('module', 'openlayers') . '/plugins/behaviors/openlayers_behavior_cluster.js' - ), - ); - } -} diff --git a/plugins/behaviors/openlayers_behavior_cluster.js b/plugins/behaviors/openlayers_behavior_cluster.js deleted file mode 100644 index 549857108580c82eee36f89bbc733d2906bd9e1b..0000000000000000000000000000000000000000 --- a/plugins/behaviors/openlayers_behavior_cluster.js +++ /dev/null @@ -1,155 +0,0 @@ -/** - * @file - * OpenLayers Behavior implementation for clustering. - */ - -/** - * OpenLayers Cluster Behavior. - */ -Drupal.openlayers.addBehavior('openlayers_behavior_cluster', function (data, options) { - var map = data.openlayers; - var layers = []; - for (var i in options.clusterlayer) { - var selectedLayer = map.getLayersBy('drupalID', options.clusterlayer[i]); - if (selectedLayer[0] instanceof OpenLayers.Layer.Vector) { - layers.push(selectedLayer[0]); - } - } - - // Cluster chosen layers - jQuery(layers).each(function(index, layer){ - var cluster = new OpenLayers.Strategy.Cluster(options); - layer.addOptions({ 'strategies': [cluster] }); - cluster.setLayer(layer); - cluster.features = layer.features.slice(); - cluster.activate(); - cluster.cluster(); - - var showLabel = ""; - if (options.display_cluster_numbers) { - showLabel = "${count}"; - } - - // Define styleMap rules, which set pointRadius size, color and labeling - // based on the number of points in each cluster. - var style = new OpenLayers.Style(); - - // Style for an individual feature (which is not clustered) - var ruleIndividual = new OpenLayers.Rule({ - filter: new OpenLayers.Filter.Comparison({ - type: OpenLayers.Filter.Comparison.LESS_THAN, - property: "count", - value: 2 - }), - // Apply the style you've selected for this layer for the individual points - symbolizer: layer.styleMap.styles["default"].defaultStyle - }); - // Define three rules to style the cluster features. - var ruleSmall = new OpenLayers.Rule({ - filter: new OpenLayers.Filter.Comparison({ - type: OpenLayers.Filter.Comparison.BETWEEN, - property: "count", - lowerBoundary: 2, - upperBoundary: options.middle_lower_bound - }), - symbolizer: { - fillColor: options.low_color, - strokeColor: options.low_stroke_color, - fillOpacity: options.low_opacity, - pointRadius: options.low_point_radius, - label: showLabel, - labelOutlineWidth: options.low_label_outline, - fontColor: options.label_low_color, - fontOpacity: options.label_low_opacity, - fontSize: "12px" - } - }); - var ruleMedium = new OpenLayers.Rule({ - filter: new OpenLayers.Filter.Comparison({ - type: OpenLayers.Filter.Comparison.BETWEEN, - property: "count", - lowerBoundary: options.middle_lower_bound, - upperBoundary: options.middle_upper_bound - }), - symbolizer: { - fillColor: options.middle_color, - strokeColor: options.middle_stroke_color, - fillOpacity: options.middle_opacity, - pointRadius: options.middle_point_radius, - label: showLabel, - labelOutlineWidth: options.middle_label_outline, - fontColor: options.label_middle_color, - fontOpacity: options.label_middle_opacity, - fontSize: "12px" - } - }); - var ruleBig = new OpenLayers.Rule({ - filter: new OpenLayers.Filter.Comparison({ - type: OpenLayers.Filter.Comparison.GREATER_THAN, - property: "count", - value: options.middle_upper_bound - }), - symbolizer: { - fillColor: options.high_color, - strokeColor: options.high_stroke_color, - fillOpacity: options.high_opacity, - pointRadius: options.high_point_radius, - label: showLabel, - labelOutlineWidth: options.high_label_outline, - fontColor: options.label_high_color, - fontOpacity: options.label_high_opacity, - fontSize: "12px" - } - }); - var ruleElse = new OpenLayers.Rule({ - filter: new OpenLayers.Filter.Comparison({ - type: OpenLayers.Filter.Comparison.EQUAL_TO, - property: "count", - value: undefined - }), - symbolizer: layer.styleMap.styles["default"].defaultStyle, - elseFilter: true - }); - - style.addRules([ruleIndividual, ruleSmall, ruleMedium, ruleBig, ruleElse]); - var styleMap = new OpenLayers.StyleMap(style); - - layer.styleMap = styleMap; - layer.redraw(); - }); -}); - -/** - * 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 += '
' + - Drupal.theme.prototype.openlayersPopup(pf) + '
'; - } - return output; - } - else { - return Drupal.theme.prototype.openlayersPopup(feature); - } -}; diff --git a/plugins/behaviors/openlayers_behavior_dragpan.inc b/plugins/behaviors/openlayers_behavior_dragpan.inc deleted file mode 100644 index 7493c33171187887b808abf2616e78a8114f6aee..0000000000000000000000000000000000000000 --- a/plugins/behaviors/openlayers_behavior_dragpan.inc +++ /dev/null @@ -1,56 +0,0 @@ - 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; - } - - function attached() { - return array( - 'js' => array( - drupal_get_path('module', 'openlayers') . '/plugins/behaviors/openlayers_behavior_dragpan.js' - ) - ); - } -} diff --git a/plugins/behaviors/openlayers_behavior_dragpan.js b/plugins/behaviors/openlayers_behavior_dragpan.js deleted file mode 100644 index 7cb0eae9017ce0f6fc8498fa6c769e2a1c0c27ff..0000000000000000000000000000000000000000 --- a/plugins/behaviors/openlayers_behavior_dragpan.js +++ /dev/null @@ -1,12 +0,0 @@ -/** - * @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); -}); diff --git a/plugins/behaviors/openlayers_behavior_drawfeatures.css b/plugins/behaviors/openlayers_behavior_drawfeatures.css deleted file mode 100644 index 8c79f81f59cb38849b154d7b62bffb3241a27d4f..0000000000000000000000000000000000000000 --- a/plugins/behaviors/openlayers_behavior_drawfeatures.css +++ /dev/null @@ -1,20 +0,0 @@ -/** - * @file - * CSS for OpenLayers Draw Features Behavior - */ - -.olControlEditingToolbar .olControlModifyFeatureItemActive { - background-position: -1px -24px; -} - -.olControlEditingToolbar .olControlModifyFeatureItemInactive { - background-position: -1px -1px; -} -.olControlEditingToolbar .olControlDeleteItemInactive { - background-image: url("img/remove_point_off.png"); - background-repeat: no-repeat; -} -.olControlEditingToolbar .olControlDeleteItemActive { - background-image: url("img/remove_point_on.png"); - background-repeat: no-repeat; -} diff --git a/plugins/behaviors/openlayers_behavior_drawfeatures.inc b/plugins/behaviors/openlayers_behavior_drawfeatures.inc deleted file mode 100644 index b2efd219e8d7bf9b64bc5a17f34c0d381cfe5d65..0000000000000000000000000000000000000000 --- a/plugins/behaviors/openlayers_behavior_drawfeatures.inc +++ /dev/null @@ -1,64 +0,0 @@ - '', - '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.'), - ) - ); - } - - function attached() { - return array( - 'js' => array( - drupal_get_path('module', 'openlayers') . '/plugins/behaviors/openlayers_behavior_drawfeatures.js' - ), - 'css' => array( - drupal_get_path('module', 'openlayers') . '/plugins/behaviors/openlayers_behavior_drawfeatures.css' - ) - ); - } -} diff --git a/plugins/behaviors/openlayers_behavior_drawfeatures.js b/plugins/behaviors/openlayers_behavior_drawfeatures.js deleted file mode 100644 index de640131b20a73b474748e9ecbc2d8319a936a15..0000000000000000000000000000000000000000 --- a/plugins/behaviors/openlayers_behavior_drawfeatures.js +++ /dev/null @@ -1,150 +0,0 @@ -/** - * @file - * DrawFeatures Behavior - */ -Drupal.openlayers.addBehavior('openlayers_behavior_drawfeatures', function (data, options) { - // 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 behavior = data && options; - // Create element - var feature_types = options.feature_types; - if (options.element_id != "") { - this.element = jQuery('#' + options.element_id); - } - // Handle vector layer for drawing on - this.feature_limit = options.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 = jQuery.map(control.controls, - function(control) { - return (control.CLASS_NAME == 'OpenLayers.Control.Navigation' || - jQuery.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) { - jQuery.map(evt.data.control.controls, function(c) { c.deactivate(); }); - dataLayer.events.triggerEvent('featuremodified'); - } - ); - } - - var deleteFeatureControl = new OpenLayers.Control.SelectFeature(layer, { - clickout: false, - toggle: false, - title: "Delete", - displayClass: "olControlDelete" - }); - - deleteFeatureControl.events.register("featurehighlighted", this, function(e) { - if (confirm('Are you sure you want to delete this feature?')) { - layer.removeFeatures([e.feature]); - deleteFeatureControl.deactivate(); - } else { - deleteFeatureControl.unselect(e.feature); - } - }); - - controls.addControls([deleteFeatureControl]); - - // Add modify feature tool - control.addControls( - new OpenLayers.Control.ModifyFeature( - dataLayer, { - displayClass: 'olControlModifyFeature', - deleteCodes: [46, 68, 100] - } - ) - ); - -}); diff --git a/plugins/behaviors/openlayers_behavior_fullscreen.css b/plugins/behaviors/openlayers_behavior_fullscreen.css deleted file mode 100644 index 1d818f35473bd760665824a531aa6a2cb6f31b5c..0000000000000000000000000000000000000000 --- a/plugins/behaviors/openlayers_behavior_fullscreen.css +++ /dev/null @@ -1,25 +0,0 @@ -.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; - } diff --git a/plugins/behaviors/openlayers_behavior_fullscreen.inc b/plugins/behaviors/openlayers_behavior_fullscreen.inc deleted file mode 100644 index 4161e5e88a7402165ff5291384b0c3f88a2e2e15..0000000000000000000000000000000000000000 --- a/plugins/behaviors/openlayers_behavior_fullscreen.inc +++ /dev/null @@ -1,45 +0,0 @@ - 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 attached() { - return array( - 'js' => array( - drupal_get_path('module', 'openlayers') . '/plugins/behaviors/openlayers_behavior_fullscreen.js' - ), - 'css' => array( - drupal_get_path('module', 'openlayers') . '/plugins/behaviors/openlayers_behavior_fullscreen.css' - ) - ); - } -} - diff --git a/plugins/behaviors/openlayers_behavior_fullscreen.js b/plugins/behaviors/openlayers_behavior_fullscreen.js deleted file mode 100644 index 56811ee3d875a809be2775cea9a932c13efc5a11..0000000000000000000000000000000000000000 --- a/plugins/behaviors/openlayers_behavior_fullscreen.js +++ /dev/null @@ -1,43 +0,0 @@ -/** - * @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(); - } -}); - -/** - * Toggling function for FullScreen control. - */ -Drupal.openlayers.fullscreenToggle = function () { - var $map = jQuery(this.openlayers.div); - var extent = this.openlayers.getExtent(); - - $map.parent().toggleClass('openlayers_map_fullscreen'); - $map.toggleClass('openlayers_map_fullscreen'); - $map.data('openlayers').openlayers.updateSize(); - $map.data('openlayers').openlayers.zoomToExtent(extent, true); -}; diff --git a/plugins/behaviors/openlayers_behavior_fullscreen.png b/plugins/behaviors/openlayers_behavior_fullscreen.png deleted file mode 100644 index b9b316c5bdcb52b81bd902cad46fd24780161938..0000000000000000000000000000000000000000 Binary files a/plugins/behaviors/openlayers_behavior_fullscreen.png and /dev/null differ diff --git a/plugins/behaviors/openlayers_behavior_geolocate.inc b/plugins/behaviors/openlayers_behavior_geolocate.inc deleted file mode 100644 index 11560a675ffe638eabfb882861cce740fbf183f9..0000000000000000000000000000000000000000 --- a/plugins/behaviors/openlayers_behavior_geolocate.inc +++ /dev/null @@ -1,68 +0,0 @@ - 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 attached() { - return array( - 'js' => array( - drupal_get_path('module', 'openlayers') . '/plugins/behaviors/openlayers_behavior_geolocate.js' - ) - ); - } -} diff --git a/plugins/behaviors/openlayers_behavior_geolocate.js b/plugins/behaviors/openlayers_behavior_geolocate.js deleted file mode 100644 index 568e3cbbbf50bf51cd91cb8beab98ae7dfa662e0..0000000000000000000000000000000000000000 --- a/plugins/behaviors/openlayers_behavior_geolocate.js +++ /dev/null @@ -1,29 +0,0 @@ -/** - * @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(); -}); diff --git a/plugins/behaviors/openlayers_behavior_graticule.inc b/plugins/behaviors/openlayers_behavior_graticule.inc deleted file mode 100644 index 37084f09b242964d9b9203227d411655abd001c1..0000000000000000000000000000000000000000 --- a/plugins/behaviors/openlayers_behavior_graticule.inc +++ /dev/null @@ -1,84 +0,0 @@ - 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, - ), - ) - ); - } - - function attached() { - return array( - 'js' => array( - drupal_get_path('module', 'openlayers') . '/plugins/behaviors/openlayers_behavior_graticule.js' - ) - ); - } -} diff --git a/plugins/behaviors/openlayers_behavior_graticule.js b/plugins/behaviors/openlayers_behavior_graticule.js deleted file mode 100644 index 2365d93c320b88867ca143af8cb806ccebdcdbd7..0000000000000000000000000000000000000000 --- a/plugins/behaviors/openlayers_behavior_graticule.js +++ /dev/null @@ -1,11 +0,0 @@ -/** - * @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); -}); diff --git a/plugins/behaviors/openlayers_behavior_hover.inc b/plugins/behaviors/openlayers_behavior_hover.inc deleted file mode 100644 index 4b32ccce3d8407f95658e853b305b15377246c98..0000000000000000000000000000000000000000 --- a/plugins/behaviors/openlayers_behavior_hover.inc +++ /dev/null @@ -1,47 +0,0 @@ - '', - ); - } - - function options_form($defaults = array()) { - - $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( - '#type' => 'checkboxes', - '#options' => $vector_layers, - '#description' => t('Select vector layer(s).'), - '#default_value' => isset($defaults['layers']) ? $defaults['layers'] : array(), - ) - ); - } - - function attached() { - return array( - 'js' => array( - drupal_get_path('module', 'openlayers') . '/plugins/behaviors/openlayers_behavior_hover.js' - ) - ); - } -} diff --git a/plugins/behaviors/openlayers_behavior_hover.js b/plugins/behaviors/openlayers_behavior_hover.js deleted file mode 100644 index 0ac4f8481c2d059654387198fe75ddbf26b69de1..0000000000000000000000000000000000000000 --- a/plugins/behaviors/openlayers_behavior_hover.js +++ /dev/null @@ -1,38 +0,0 @@ -/** - * @file - * JS Implementation of OpenLayers behavior. - */ - -/** - * Hover Behavior - */ -Drupal.openlayers.addBehavior('openlayers_behavior_hover', function (data, options) { - - var map = data.openlayers; - - var layers = map.getLayersBy('drupalID', { - test: function(id) { - for (var i in options.layers) { - if (options.layers[i] == id) { - return true; - } - } - return false; - } - }); - - jQuery(layers).each(function(index, layer) { - - var highlightCtrl = new OpenLayers.Control.SelectFeature(layer, { - hover: true, - highlightOnly: true, - renderIntent: 'temporary' - }); - highlightCtrl.handlers['feature'].stopDown = false; - highlightCtrl.handlers['feature'].stopUp = false; - - map.addControl(highlightCtrl); - highlightCtrl.activate(); - }); - -}); diff --git a/plugins/behaviors/openlayers_behavior_keyboarddefaults.inc b/plugins/behaviors/openlayers_behavior_keyboarddefaults.inc deleted file mode 100644 index 3a023bd6f4ead5b0732cf9bb9d49d5396ba75879..0000000000000000000000000000000000000000 --- a/plugins/behaviors/openlayers_behavior_keyboarddefaults.inc +++ /dev/null @@ -1,27 +0,0 @@ - '', - ); - } - - function attached() { - return array( - 'js' => array( - drupal_get_path('module', 'openlayers') . '/plugins/behaviors/openlayers_behavior_keyboarddefaults.js' - ) - ); - } -} diff --git a/plugins/behaviors/openlayers_behavior_keyboarddefaults.js b/plugins/behaviors/openlayers_behavior_keyboarddefaults.js deleted file mode 100644 index 0606631f5e0b635de32abe57b7ec306538128caa..0000000000000000000000000000000000000000 --- a/plugins/behaviors/openlayers_behavior_keyboarddefaults.js +++ /dev/null @@ -1,13 +0,0 @@ - -/** - * @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'); -}); diff --git a/plugins/behaviors/openlayers_behavior_layerswitcher.inc b/plugins/behaviors/openlayers_behavior_layerswitcher.inc deleted file mode 100644 index 79ef8b3fc0128eeac7ed0a0f34274fbf181c00cf..0000000000000000000000000000000000000000 --- a/plugins/behaviors/openlayers_behavior_layerswitcher.inc +++ /dev/null @@ -1,100 +0,0 @@ - '', - 'ascending' => TRUE, - 'sortBaseLayer' => '0', - 'roundedCorner' => TRUE, - 'roundedCornerColor' => '#222222', - 'maximizeDefault' => FALSE, - 'div' => 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, - ), - 'div' => array( - '#type' => 'textfield', - '#title' => t('DIV element for LayerSwitcher'), - '#description' => t('To create the LayerSwitcher outside of the map, pass the ID attribute of an HTML div element.'), - '#default_value' => isset($defaults['div']) ? $defaults['div'] : FALSE, - ), - ); - } - - function attached() { - return array( - 'js' => array( - drupal_get_path('module', 'openlayers') . '/plugins/behaviors/openlayers_behavior_layerswitcher.js' - ) - ); - } - - /** - * 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); - } - } - return $this->options; - } -} diff --git a/plugins/behaviors/openlayers_behavior_layerswitcher.js b/plugins/behaviors/openlayers_behavior_layerswitcher.js deleted file mode 100644 index 050f47e5933dac91390e7cb262bc6dc694d7ab1d..0000000000000000000000000000000000000000 --- a/plugins/behaviors/openlayers_behavior_layerswitcher.js +++ /dev/null @@ -1,27 +0,0 @@ -/** - * @file - * JS Implementation of OpenLayers behavior. - */ - -/** - * Layer Switcher Behavior - */ -Drupal.openlayers.addBehavior('openlayers_behavior_layerswitcher', function (data, options) { - options.ascending = !! options.ascending; - - if (options.div) { - options.div = OpenLayers.Util.getElement(options.div); - } else { - // make sure div is set to null so openlayers knows to generate its own id - if (typeof options.div !== "undefined") { - delete options.div; - } - } - - Drupal.openlayers.addControl(data.openlayers, 'LayerSwitcher', options); - - // Maximize if needed. - if (!! options.maximizeDefault == true) { - data.openlayers.getControlsByClass('OpenLayers.Control.LayerSwitcher')[0].maximizeControl(); - } -}); diff --git a/plugins/behaviors/openlayers_behavior_layerzoom.inc b/plugins/behaviors/openlayers_behavior_layerzoom.inc deleted file mode 100644 index acab7dfc5a79e313b156a0e0b27ee0deed2a3de6..0000000000000000000000000000000000000000 --- a/plugins/behaviors/openlayers_behavior_layerzoom.inc +++ /dev/null @@ -1,49 +0,0 @@ -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('EPSG: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('EPSG:900913')), - '#description' => t('The zoom levels at which this layer will display.'), - ), - ); - } - } - return $options; - } - - function attached() { - return array( - 'js' => array( - drupal_get_path('module', 'openlayers') . '/plugins/behaviors/openlayers_behavior_layerzoom.js' - ) - ); - } -} diff --git a/plugins/behaviors/openlayers_behavior_layerzoom.js b/plugins/behaviors/openlayers_behavior_layerzoom.js deleted file mode 100644 index ff4a77430adf5497732225716ea1c7d9f74efc36..0000000000000000000000000000000000000000 --- a/plugins/behaviors/openlayers_behavior_layerzoom.js +++ /dev/null @@ -1,37 +0,0 @@ -/** - * @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); - jQuery(layers).each(function(index, layer){ - // Basically replicate Object.keys because it is not available in IE8. - var keys = []; - for(var key in options[layerName].resolutions){ - if(options[layerName].resolutions.hasOwnProperty(key)){ - keys.push(key); - } - } - - // Restrict zoom level range. - layer.alwaysInRange = false; - layer.minResolution = options[layerName].resolutions[keys[keys.length-1]]; - layer.maxResolution = options[layerName].resolutions[keys[0]]; - - if(layer.getVisibility() && layer.calculateInRange()===false){ - // Ensure layer is redraw if it should be invisible initially due to - // the resolutions set above. - layer.setVisibility(false); - layer.setVisibility(true); - } - }); - } - } -}); diff --git a/plugins/behaviors/openlayers_behavior_mapformvalues.inc b/plugins/behaviors/openlayers_behavior_mapformvalues.inc deleted file mode 100644 index f9b67869e5abc716c60a524c3228058acffcb6da..0000000000000000000000000000000000000000 --- a/plugins/behaviors/openlayers_behavior_mapformvalues.inc +++ /dev/null @@ -1,28 +0,0 @@ - '#edit-center-initial-centerpoint', - 'zoom_form' => '#edit-center-initial-zoom' - ); - } - - function attached() { - return array( - 'js' => array( - drupal_get_path('module', 'openlayers') . '/plugins/behaviors/openlayers_behavior_mapformvalues.js' - ) - ); - } -} diff --git a/plugins/behaviors/openlayers_behavior_mapformvalues.js b/plugins/behaviors/openlayers_behavior_mapformvalues.js deleted file mode 100644 index 25f1185af0f18c1625cebf3a6d7e5019a8212cca..0000000000000000000000000000000000000000 --- a/plugins/behaviors/openlayers_behavior_mapformvalues.js +++ /dev/null @@ -1,53 +0,0 @@ -/** - * @file - * JS Implementation of OpenLayers behavior. - */ - -/** - * 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); - } - } - var centerpoint_form = jQuery(options.center_form); - var zoom_form = jQuery(options.zoom_form); - - if (centerpoint_form.length) { - data.openlayers.centerpoint_form = centerpoint_form; - var 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; - if (centerpoint_form.length) { - data.openlayers.setCenter( - OpenLayers.LonLat.fromString(center_point).transform( - new OpenLayers.Projection('EPSG:4326'), - data.openlayers.projection - ), - parseInt(zoom_form.val()) - ); - } else { - data.openlayers.zoomTo( - parseInt(zoom_form.val()) - ); - } - } - - data.openlayers.events.on({'moveend': updateForm}); -}); diff --git a/plugins/behaviors/openlayers_behavior_mouseposition.inc b/plugins/behaviors/openlayers_behavior_mouseposition.inc deleted file mode 100644 index e9d604b562212fe07df2b543d8b51ee507941863..0000000000000000000000000000000000000000 --- a/plugins/behaviors/openlayers_behavior_mouseposition.inc +++ /dev/null @@ -1,70 +0,0 @@ - '', - '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'] : '', - ), - ); - } - - function attached() { - return array( - 'js' => array( - drupal_get_path('module', 'openlayers') . '/plugins/behaviors/openlayers_behavior_mouseposition.js' - ) - ); - } -} diff --git a/plugins/behaviors/openlayers_behavior_mouseposition.js b/plugins/behaviors/openlayers_behavior_mouseposition.js deleted file mode 100644 index dae0885cf1f21288a4da51f626c3bb211be77480..0000000000000000000000000000000000000000 --- a/plugins/behaviors/openlayers_behavior_mouseposition.js +++ /dev/null @@ -1,11 +0,0 @@ -/** - * @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); -}); diff --git a/plugins/behaviors/openlayers_behavior_navigation.inc b/plugins/behaviors/openlayers_behavior_navigation.inc deleted file mode 100644 index 30d78dffabc323f0e166989edea5233804e71e31..0000000000000000000000000000000000000000 --- a/plugins/behaviors/openlayers_behavior_navigation.inc +++ /dev/null @@ -1,58 +0,0 @@ - '', - '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 SHIFT + clicking.'), - '#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 - ), - ); - } - - function attached() { - return array( - 'js' => array( - drupal_get_path('module', 'openlayers') . '/plugins/behaviors/openlayers_behavior_navigation.js' - ) - ); - } -} diff --git a/plugins/behaviors/openlayers_behavior_navigation.js b/plugins/behaviors/openlayers_behavior_navigation.js deleted file mode 100644 index 682492eddd82f38fb900b40d8ed614cc2af07084..0000000000000000000000000000000000000000 --- a/plugins/behaviors/openlayers_behavior_navigation.js +++ /dev/null @@ -1,12 +0,0 @@ -/** - * @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); -}); diff --git a/plugins/behaviors/openlayers_behavior_panzoom.inc b/plugins/behaviors/openlayers_behavior_panzoom.inc deleted file mode 100644 index 40f4f0ac36c1431c9b8d1720595284dff1e5c316..0000000000000000000000000000000000000000 --- a/plugins/behaviors/openlayers_behavior_panzoom.inc +++ /dev/null @@ -1,32 +0,0 @@ - '', - ); - } - - function options_form($defaults = array()) { - return array( - ); - } - - function attached() { - return array( - 'js' => array( - drupal_get_path('module', 'openlayers') . '/plugins/behaviors/openlayers_behavior_panzoom.js' - ) - ); - } -} diff --git a/plugins/behaviors/openlayers_behavior_panzoom.js b/plugins/behaviors/openlayers_behavior_panzoom.js deleted file mode 100644 index 84d07dd23a965f0fded552ff32a629643a184590..0000000000000000000000000000000000000000 --- a/plugins/behaviors/openlayers_behavior_panzoom.js +++ /dev/null @@ -1,11 +0,0 @@ -/** - * @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'); -}); diff --git a/plugins/behaviors/openlayers_behavior_panzoombar.inc b/plugins/behaviors/openlayers_behavior_panzoombar.inc deleted file mode 100644 index 4b3c6bc21069d5dd6b568fc3af551ee58bc6901d..0000000000000000000000000000000000000000 --- a/plugins/behaviors/openlayers_behavior_panzoombar.inc +++ /dev/null @@ -1,49 +0,0 @@ - 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 - ), - ); - } - - function attached() { - return array( - 'js' => array( - drupal_get_path('module', 'openlayers') . '/plugins/behaviors/openlayers_behavior_panzoombar.js' - ) - ); - } -} diff --git a/plugins/behaviors/openlayers_behavior_panzoombar.js b/plugins/behaviors/openlayers_behavior_panzoombar.js deleted file mode 100644 index 8dab936ed5cc159df86577935019b2df580e7f63..0000000000000000000000000000000000000000 --- a/plugins/behaviors/openlayers_behavior_panzoombar.js +++ /dev/null @@ -1,11 +0,0 @@ -/** - * @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); -}); diff --git a/plugins/behaviors/openlayers_behavior_permalink.inc b/plugins/behaviors/openlayers_behavior_permalink.inc deleted file mode 100644 index 8c12e2ff97f4a35cd9c0ef53cb748c271eaaf336..0000000000000000000000000000000000000000 --- a/plugins/behaviors/openlayers_behavior_permalink.inc +++ /dev/null @@ -1,42 +0,0 @@ - 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, - ), - ); - } - - function attached() { - return array( - 'js' => array( - drupal_get_path('module', 'openlayers') . '/plugins/behaviors/openlayers_behavior_permalink.js' - ) - ); - } -} diff --git a/plugins/behaviors/openlayers_behavior_permalink.js b/plugins/behaviors/openlayers_behavior_permalink.js deleted file mode 100644 index 4a7de4403370b76742d1e669a318326b7a9394b3..0000000000000000000000000000000000000000 --- a/plugins/behaviors/openlayers_behavior_permalink.js +++ /dev/null @@ -1,11 +0,0 @@ -/** - * @file - * JS Implementation of OpenLayers behavior. - */ - -/** - * Permalink Behavior - */ -Drupal.openlayers.addBehavior('openlayers_behavior_permalink', function (data, options) { - Drupal.openlayers.addControl(data.openlayers, 'Permalink', options); -}); diff --git a/plugins/behaviors/openlayers_behavior_popup.inc b/plugins/behaviors/openlayers_behavior_popup.inc deleted file mode 100644 index 1e98cb00ef9010475f71d6beb25f0cf75ec186dc..0000000000000000000000000000000000000000 --- a/plugins/behaviors/openlayers_behavior_popup.inc +++ /dev/null @@ -1,77 +0,0 @@ - array(), - 'panMapIfOutOfView' => FALSE, - 'keepInMap' => TRUE, - 'popupAtPosition' => 'mouse' - ); - } - - /** - * 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(), - ), - 'popupAtPosition' => array( - '#type' => 'select', - '#title' => t('Select where the popup should pop up'), - '#description' => t('When selecting a feature, should the popup appear at the mouse position or in the center of the feature ?'), - '#default_value' => isset($defaults['popupAtPosition']) ? $defaults['popupAtPosition'] : 'mouse', - '#options' => array( - 'mouse' => 'At the mouse position', - 'computed' => 'Computed from the center of the feature' - ) - ), - '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 - ), - ); - } - - function attached() { - return array( - 'js' => array( - drupal_get_path('module', 'openlayers') . '/plugins/behaviors/openlayers_behavior_popup.js' - ) - ); - } -} diff --git a/plugins/behaviors/openlayers_behavior_popup.js b/plugins/behaviors/openlayers_behavior_popup.js deleted file mode 100644 index 4c63fd807032fb8459ea13b0c07bf38fecbab953..0000000000000000000000000000000000000000 --- a/plugins/behaviors/openlayers_behavior_popup.js +++ /dev/null @@ -1,127 +0,0 @@ -/** - * @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 += '
' + feature.attributes.name + '
'; - } - if (feature.attributes.description) { - output += '
' + feature.attributes.description + '
'; - } - - 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, - { - eventListeners:{ - featurehighlighted:function(e){ - lonlat = map.getLonLatFromPixel( - new OpenLayers.Pixel( - this.handlers.feature.evt.clientX - map.viewPortDiv.offsetLeft + jQuery(window).scrollLeft(), - this.handlers.feature.evt.clientY - map.viewPortDiv.offsetTop + jQuery(window).scrollTop() - ) - ); - - - - - - } - }, - onSelect: function(feature) { - var lonlat; - if (options.popupAtPosition == 'mouse') { - lonlat = map.getLonLatFromPixel( - this.handlers.feature.evt.xy - ); - } else { - lonlat = feature.geometry.getBounds().getCenterLonLat(); - } - - // Create FramedCloud popup. - popup = new OpenLayers.Popup.FramedCloud( - 'popup', - lonlat, - //feature.geometry.getBounds().getCenterLonLat(), - null, - Drupal.theme('openlayersPopup', feature), - null, - true, - function(evt) { - while( map.popups.length ) { - map.removePopup(map.popups[0]); - } - 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; - map.addPopup(popup, true); - Drupal.attachBehaviors(); - }, - onUnselect: function(feature) { - map.removePopup(feature.popup); - feature.popup.destroy(); - feature.popup = null; - this.unselectAll(); - Drupal.attachBehaviors(); - } - } - ); - popupSelect.handlers['feature'].stopDown = false; - popupSelect.handlers['feature'].stopUp = false; - - map.addControl(popupSelect); - popupSelect.activate(); - Drupal.openlayers.popup.popupSelect = popupSelect; -}); diff --git a/plugins/behaviors/openlayers_behavior_scaleline.inc b/plugins/behaviors/openlayers_behavior_scaleline.inc deleted file mode 100644 index 67d4caa0bf97c61826dcbc18c20ceb4e4ab6ae63..0000000000000000000000000000000000000000 --- a/plugins/behaviors/openlayers_behavior_scaleline.inc +++ /dev/null @@ -1,35 +0,0 @@ - '', - ); - } - - function js_dependency() { - return array('OpenLayers.Control.ScaleLine'); - } - - function options_form($defaults = array()) { - return array(); - } - - function attached() { - return array( - 'js' => array( - drupal_get_path('module', 'openlayers') . '/plugins/behaviors/openlayers_behavior_scaleline.js' - ) - ); - } -} diff --git a/plugins/behaviors/openlayers_behavior_scaleline.js b/plugins/behaviors/openlayers_behavior_scaleline.js deleted file mode 100644 index 579b3055cb9c2dd0318417180b9e2928f597d792..0000000000000000000000000000000000000000 --- a/plugins/behaviors/openlayers_behavior_scaleline.js +++ /dev/null @@ -1,11 +0,0 @@ -/** - * @file - * JS Implementation of OpenLayers behavior. - */ - -/** - * Scale Line Behavior - */ -Drupal.openlayers.addBehavior('openlayers_behavior_scaleline', function (data, options) { - Drupal.openlayers.addControl(data.openlayers, 'ScaleLine'); -}); diff --git a/plugins/behaviors/openlayers_behavior_tooltip.inc b/plugins/behaviors/openlayers_behavior_tooltip.inc deleted file mode 100644 index 1d490bec0b6d6949531452bb8f21a5c7244458d7..0000000000000000000000000000000000000000 --- a/plugins/behaviors/openlayers_behavior_tooltip.inc +++ /dev/null @@ -1,53 +0,0 @@ - '', - '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(), - ), - ); - } - - function attached() { - return array( - 'js' => array( - drupal_get_path('module', 'openlayers') . '/plugins/behaviors/openlayers_behavior_tooltip.js' - ) - ); - } -} diff --git a/plugins/behaviors/openlayers_behavior_tooltip.js b/plugins/behaviors/openlayers_behavior_tooltip.js deleted file mode 100644 index 0f0ed43670f53ab9e514668ccc55662a566c0380..0000000000000000000000000000000000000000 --- a/plugins/behaviors/openlayers_behavior_tooltip.js +++ /dev/null @@ -1,95 +0,0 @@ -/** - * @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 += '
' + feature.attributes.name + '
'; - } - if (feature.attributes.description) { - output += '
' + feature.attributes.description + '
'; - } - - 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; - } - } - } - ); - popupSelect.handlers['feature'].stopDown = false; - popupSelect.handlers['feature'].stopUp = false; - - // Actiate the popups - map.addControl(popupSelect); - popupSelect.activate(); -}); diff --git a/plugins/behaviors/openlayers_behavior_touch_navigation.inc b/plugins/behaviors/openlayers_behavior_touch_navigation.inc deleted file mode 100644 index a8065748b5a4d014ab0074b44417883f9d4e1dd1..0000000000000000000000000000000000000000 --- a/plugins/behaviors/openlayers_behavior_touch_navigation.inc +++ /dev/null @@ -1,42 +0,0 @@ - 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 - ), - ); - } - - function attached() { - return array( - 'js' => array( - drupal_get_path('module', 'openlayers') . '/plugins/behaviors/openlayers_behavior_touch_navigation.js' - ) - ); - } -} diff --git a/plugins/behaviors/openlayers_behavior_touch_navigation.js b/plugins/behaviors/openlayers_behavior_touch_navigation.js deleted file mode 100644 index 6ad4ccf30792862529ca3c53139c8db6e60cf65e..0000000000000000000000000000000000000000 --- a/plugins/behaviors/openlayers_behavior_touch_navigation.js +++ /dev/null @@ -1,12 +0,0 @@ -/** - * @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); -}); diff --git a/plugins/behaviors/openlayers_behavior_zoombox.inc b/plugins/behaviors/openlayers_behavior_zoombox.inc deleted file mode 100644 index e697048074458d2faa08916e2a5c8b4a28d54b96..0000000000000000000000000000000000000000 --- a/plugins/behaviors/openlayers_behavior_zoombox.inc +++ /dev/null @@ -1,27 +0,0 @@ - '', - ); - } - - function attached() { - return array( - 'js' => array( - drupal_get_path('module', 'openlayers') . '/plugins/behaviors/openlayers_behavior_zoombox.js' - ) - ); - } -} diff --git a/plugins/behaviors/openlayers_behavior_zoombox.js b/plugins/behaviors/openlayers_behavior_zoombox.js deleted file mode 100644 index bb468d601db81b605f74b720701c5c472759367a..0000000000000000000000000000000000000000 --- a/plugins/behaviors/openlayers_behavior_zoombox.js +++ /dev/null @@ -1,11 +0,0 @@ -/** - * @file - * JS Implementation of OpenLayers behavior. - */ - -/** - * Zoom Box Behavior - */ -Drupal.openlayers.addBehavior('openlayers_behavior_zoombox', function (data, options) { - Drupal.openlayers.addControl(data.openlayers, 'ZoomBox'); -}); diff --git a/plugins/behaviors/openlayers_behavior_zoompanel.inc b/plugins/behaviors/openlayers_behavior_zoompanel.inc deleted file mode 100644 index 0db5958b936029be130515d1515652d501236ccb..0000000000000000000000000000000000000000 --- a/plugins/behaviors/openlayers_behavior_zoompanel.inc +++ /dev/null @@ -1,27 +0,0 @@ - '', - ); - } - - function attached() { - return array( - 'js' => array( - drupal_get_path('module', 'openlayers') . '/plugins/behaviors/openlayers_behavior_zoompanel.js' - ) - ); - } -} diff --git a/plugins/behaviors/openlayers_behavior_zoompanel.js b/plugins/behaviors/openlayers_behavior_zoompanel.js deleted file mode 100644 index 2018cf701306f83d243138e9f411a5a9f4c19b50..0000000000000000000000000000000000000000 --- a/plugins/behaviors/openlayers_behavior_zoompanel.js +++ /dev/null @@ -1,11 +0,0 @@ -/** - * @file - * JS Implementation of OpenLayers behavior. - */ - -/** - * ZoomPanel Behavior - */ -Drupal.openlayers.addBehavior('openlayers_behavior_zoompanel', function (data, options) { - Drupal.openlayers.addControl(data.openlayers, 'ZoomPanel'); -}); diff --git a/plugins/behaviors/openlayers_behavior_zoomtolayer.inc b/plugins/behaviors/openlayers_behavior_zoomtolayer.inc deleted file mode 100644 index 73075a67ca8a21aaf8fafa2e132ee0e0982bfb57..0000000000000000000000000000000000000000 --- a/plugins/behaviors/openlayers_behavior_zoomtolayer.inc +++ /dev/null @@ -1,53 +0,0 @@ - '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 OpenLayers docs.'), - '#default_value' => isset($defaults['zoomtolayer_scale']) ? $defaults['zoomtolayer_scale'] : 1 - ), - ); - } - - function attached() { - return array( - 'js' => array( - drupal_get_path('module', 'openlayers') . '/plugins/behaviors/openlayers_behavior_zoomtolayer.js' - ) - ); - } -} diff --git a/plugins/behaviors/openlayers_behavior_zoomtolayer.js b/plugins/behaviors/openlayers_behavior_zoomtolayer.js deleted file mode 100644 index db8506b03435b4c1ecf73700aab9dd5109594dbf..0000000000000000000000000000000000000000 --- a/plugins/behaviors/openlayers_behavior_zoomtolayer.js +++ /dev/null @@ -1,91 +0,0 @@ -/** - * @file - * JS Implementation of OpenLayers behavior. - */ - -/** - * OpenLayers Zoom to Layer Behavior. - * - * Zooms to the data extent of the selected layers. - */ -Drupal.openlayers.addBehavior('openlayers_behavior_zoomtolayer', function (data, options) { - var map = data.openlayers; - var zoomtolayer_scale = parseInt(options.zoomtolayer_scale, 10); - var point_zoom_level = parseInt(options.point_zoom_level, 10); - - var layers = map.getLayersBy('drupalID', { - test: function(id) { - for (var i in options.zoomtolayer) { - if (options.zoomtolayer[i] == id) { - return true; - } - } - return false; - } - }); - - // Combined extent of all layers. - var fullExtent = undefined; - - // Go through selected layers to get full extent. - jQuery(layers).each(function(index, layer) { - accumulate_extent(layer); - - if (layer instanceof OpenLayers.Layer.Vector) { - // This should not register the handler in case no data is available. - if (layer.getDataExtent() === null) { - // Try again to determine the extent after layer has loaded. - layer.events.register('loadend', layer, handle_loadend_once); - } - } - }); - // Zoom if some data was sychronously loaded. - show_extent_if_determined(); - - /** - * Handler for loadend event of layer that is still loading. - */ - function handle_loadend_once(event) { - var layer = event.object; - layer.events.unregister('loadend', layer, handle_loadend_once); - - accumulate_extent(layer); - // Zoom if bound have been determined. - show_extent_if_determined(); - } - - /** - * Add data extent of layer to total data extent. - */ - function accumulate_extent(layer){ - var layerextent = layer.getDataExtent(); - if (fullExtent instanceof OpenLayers.Bounds) { - fullExtent.extend(layerextent); - } - else if (layerextent instanceof OpenLayers.Bounds) { - fullExtent = layerextent; - } - } - - /** - * Zooms map if bounds are at least partially known. - */ - function show_extent_if_determined(){ - if(fullExtent instanceof OpenLayers.Bounds){ - if (fullExtent.getWidth()===0 && fullExtent.getHeight()===0) { - // If extent is a single point, - // zoom in with point_zoom_level option. - map.setCenter(fullExtent.getCenterLonLat(), point_zoom_level) - } else { - var scaled = fullExtent.scale(zoomtolayer_scale); - map.zoomToExtent(scaled); - if(!map.getExtent().contains(scaled)){ - // OpenLayers silently ignores zoom in case the date line would need - // to be displayed more than once. Move map to where the data is at - // least. - map.setCenter(scaled.getCenterLonLat()); - } - } - } - } -}); diff --git a/plugins/behaviors/openlayers_behavior_zoomtomaxextent.inc b/plugins/behaviors/openlayers_behavior_zoomtomaxextent.inc deleted file mode 100644 index f0c050cae13ac995a28b002988ecc92cdf1cf350..0000000000000000000000000000000000000000 --- a/plugins/behaviors/openlayers_behavior_zoomtomaxextent.inc +++ /dev/null @@ -1,27 +0,0 @@ - '', - ); - } - - function attached() { - return array( - 'js' => array( - drupal_get_path('module', 'openlayers') . '/plugins/behaviors/openlayers_behavior_zoomtomaxextent.js' - ) - ); - } -} diff --git a/plugins/behaviors/openlayers_behavior_zoomtomaxextent.js b/plugins/behaviors/openlayers_behavior_zoomtomaxextent.js deleted file mode 100644 index 24f3e058fb45ed0423e8eec20df09b066a1313c7..0000000000000000000000000000000000000000 --- a/plugins/behaviors/openlayers_behavior_zoomtomaxextent.js +++ /dev/null @@ -1,15 +0,0 @@ -/** - * @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]); -}); diff --git a/plugins/boxes/openlayers_simple.inc b/plugins/boxes/openlayers_simple.inc deleted file mode 100644 index 5126f632eabfdd6454c62c066ffb8d4d18741210..0000000000000000000000000000000000000000 --- a/plugins/boxes/openlayers_simple.inc +++ /dev/null @@ -1,47 +0,0 @@ - '' - ); - } - - /** - * Implementation of boxes_content::options_form(). - */ - public function options_form(&$form_state) { - $form = array(); - // Map objects - $form['map'] = array( - '#type' => 'select', - '#title' => t('Map'), - '#description' => t('This is map that will be used to render the view.'), - '#options' => openlayers_map_options(), - '#default_value' => $this->options['map'] ? - $this->options['map'] : variable_get('openlayers_default_map', 'default'), - ); - return $form; - } - - /** - * Implementation of boxes_content::options_form(). - */ - public function render() { - $title = isset($this->title) ? check_plain($this->title) : NULL; - $map = openlayers_map_load($this->options['map']); - - return array( - 'delta' => $this->delta, // Crucial. - 'title' => $title, - 'subject' => $title, - 'content' => openlayers_render_map($map, $map->name) - ); - } -} diff --git a/plugins/content_types/icon_openlayers_map.png b/plugins/content_types/icon_openlayers_map.png deleted file mode 100644 index 21616fc244b733dc37afd008df1a9d283743f80f..0000000000000000000000000000000000000000 Binary files a/plugins/content_types/icon_openlayers_map.png and /dev/null differ diff --git a/plugins/content_types/openlayers_map.inc b/plugins/content_types/openlayers_map.inc deleted file mode 100644 index 068955ce34fbf0483e583b6e63064d391a4094c3..0000000000000000000000000000000000000000 --- a/plugins/content_types/openlayers_map.inc +++ /dev/null @@ -1,66 +0,0 @@ - t('OpenLayers Map'), - 'content type' => 'openlayers_openlayers_map_content_type_content_types', - 'render callback' => 'openlayers_map_content_type_render', - ); -} - -/** - * Return all content types available. - */ -function openlayers_openlayers_map_content_type_content_types($plugin) { - $types = array(); - $maps = openlayers_maps(); - - foreach ($maps as $map) { - $types[$map->name] = array( - 'map' => $map->name, - 'title' => $map->title, - 'description' => $map->description, - 'category' => t('OpenLayers Maps'), - 'icon' => 'icon_openlayers_map.png', - ); - } - - return $types; -} - -/** - * Run-time rendering of the body of the block. - * - * @param $subtype - * @param $conf - * Configuration as done at admin time. - * @param $args - * @param $context - * Context - in this case we don't have any. - * - * @return - * An object with at least title and content members. - */ -function openlayers_map_content_type_render($subtype, $conf, $args, $context) { - $map = openlayers_map_load($subtype); - - $block = new stdClass(); - $block->title = $map->title; - $block->content = openlayers_render_map($map); - - return $block; -} - -/** - * Empty form so we can have the default override title. - */ -function openlayers_openlayers_map_content_type_edit_form($form, &$form_state) { - // Does nothing! - return $form; -} diff --git a/plugins/layer_types/openlayers_layer_type_bing.inc b/plugins/layer_types/openlayers_layer_type_bing.inc deleted file mode 100644 index 3c542a2bdf49cdfa400160fd6cd3c96bcbba1b68..0000000000000000000000000000000000000000 --- a/plugins/layer_types/openlayers_layer_type_bing.inc +++ /dev/null @@ -1,104 +0,0 @@ -language; - $culture = variable_get('openlayers_layers_bing_language', ''); - - // Bing does not provide imagery for a language without a country code. - // Best guess is to double-up on the language code ('fr' becomes 'fr-FR'). - // This methods succeeds for all but Dutch (Belgium) 'nl-BE'. - // See http://msdn.microsoft.com/en-us/library/hh441729.aspx - $lang = $lang . '-' . strtoupper ($lang); - - return array( - 'layer_handler' => 'bing', - 'key' => variable_get('openlayers_layers_bing_api', ''), - 'type' => 'Road', - 'culture' => $culture == '' ? $lang : $culture, - ) + parent::options_init(); - } - - /** - * Options form which generates layers - */ - function options_form($defaults = array()) { - $warning = (!variable_get('openlayers_layers_bing_api', FALSE)) ? - array('#value' => t('WARNING: Your Bing API key is not set. - Map including Bing layers will break until it is set correctly.') - ) : NULL; - - $bing_layer_types = array( - 'Road' => 'Road', - 'AerialWithLabels' => 'Hybrid', - 'Aerial' => 'Aerial', - ); - - return array( - 'type' => array( - '#title' => t('Bing Layer Type'), - '#type' => 'select', - '#default_value' => isset($this->data['type']) ? - $this->data['type'] : 'Road', - '#options' => $bing_layer_types - ), - $warning - ); - } - - /** - * Layer-type-wide settings form - */ - function settings_form() { - return array( - 'openlayers_layers_bing_api' => array( - '#type' => 'textfield', - '#title' => t('Bing API Key'), - '#default_value' => variable_get('openlayers_layers_bing_api', ''), - '#description' => t('Get a MS Bing API Key', - array('@microsoft' => 'http://bingmapsportal.com')) - ), - 'openlayers_layers_bing_language' => array( - '#type' => 'textfield', - '#title' => t('Culture'), - '#description' => t(' The culture parameter provides the strings in - the language of the culture for geographic place names, map labels, - and route instructions. By default, Bing Maps REST Services will - determine the culture automatically. Only use this is you - want to force a specific language. Please see - this list of supported culture codes.', - array('!url' => 'http://msdn.microsoft.com/en-us/library/hh441729.aspx') - ), - '#default_value' => variable_get('openlayers_layers_bing_language', ''), - ), - ); - - } - - /** - * Render. - */ - function render(&$map) { - static $bing_maps_included; - - if (!isset($bing_maps_included)) { - drupal_add_js(drupal_get_path('module', 'openlayers') . - '/plugins/layer_types/openlayers_layer_type_bing.js'); - $bing_maps_included = TRUE; - } - } -} diff --git a/plugins/layer_types/openlayers_layer_type_bing.js b/plugins/layer_types/openlayers_layer_type_bing.js deleted file mode 100644 index 9bbc6d2e6a91c5bad8ee8118ec3975228e984205..0000000000000000000000000000000000000000 --- a/plugins/layer_types/openlayers_layer_type_bing.js +++ /dev/null @@ -1,15 +0,0 @@ - -/** - * Process MS Bing Layers - * - * @param layerOptions - * Object of options. - * @param mapid - * Map ID. - * @return - * Valid OpenLayers layer. - */ -Drupal.openlayers.layer.bing = function(title, map, options) { - options.projection = new OpenLayers.Projection(options.projection); - return new OpenLayers.Layer.Bing(options); -}; diff --git a/plugins/layer_types/openlayers_layer_type_cloudmade.inc b/plugins/layer_types/openlayers_layer_type_cloudmade.inc deleted file mode 100644 index 9c606d8c4c16d220fbe4842760be3177c500cdfb..0000000000000000000000000000000000000000 --- a/plugins/layer_types/openlayers_layer_type_cloudmade.inc +++ /dev/null @@ -1,90 +0,0 @@ - 'cloudmade', - 'key' => variable_get('openlayers_layers_cloudmade_api', ''), - ) + parent::options_init(); - } - - /** - * Options form which generates layers - */ - function options_form($defaults = array()) { - $warning = (!variable_get('openlayers_layers_cloudmade_js', FALSE) || - !variable_get('openlayers_layers_cloudmade_api', FALSE)) ? - array( - '#value' => t('WARNING: Your CloudMade API key or - Javascript location is not set. Map including CloudMade layers - will break until they are set correctly.') - ) - : NULL; - return array( - 'styleId' => array( - '#type' => 'textfield', - '#title' => t('Style ID'), - '#description' => t('Enter the numeric Style ID for a Map Style from CloudMade. You can usually find the Style ID in the lower right hand corner of each Map Style box.'), - '#default_value' => isset($this->data['styleId']) ? - $this->data['styleId'] : '' - ), - $warning - ); - } - - /** - * Layer-type-wide settings form - */ - function settings_form() { - return array( - 'openlayers_layers_cloudmade_api' => array( - '#type' => 'textfield', - '#title' => t('CloudMade API Key'), - '#default_value' => variable_get('openlayers_layers_cloudmade_api', ''), - '#description' => t('Get a CloudMade account and API Key', - array('@cloudmade' => 'http://cloudmade.com/user/show')) - ), - 'openlayers_layers_cloudmade_js' => array( - '#type' => 'textfield', - '#title' => t('CloudMade Javascript Location'), - '#default_value' => variable_get('openlayers_layers_cloudmade_js', ''), - '#description' => t('The Drupal path or full URL to the location of the ' . - 'Cloudmade OpenLayers Javascript library', - array('@url' => 'http://developers.cloudmade.com/projects/show/openlayers-api')), - ), - ); - } - - /** - * Render. - */ - function render(&$map) { - static $cloudmade_maps_included; - - if (!isset($cloudmade_maps_included)) { - drupal_add_js(drupal_get_path('module', 'openlayers') . - '/plugins/layer_types/openlayers_layer_type_cloudmade.js'); - $path = variable_get('openlayers_layers_cloudmade_js', ''); - if (valid_url($path, TRUE)) { - // TODO: could be collapsed, removing the if-else - drupal_add_js($path, 'external'); - } - else { - drupal_add_js($path); - } - $cloudmade_maps_included = TRUE; - } - } -} diff --git a/plugins/layer_types/openlayers_layer_type_cloudmade.js b/plugins/layer_types/openlayers_layer_type_cloudmade.js deleted file mode 100644 index 9a04b983f644291bb1dc09216627ad29c6fce131..0000000000000000000000000000000000000000 --- a/plugins/layer_types/openlayers_layer_type_cloudmade.js +++ /dev/null @@ -1,14 +0,0 @@ - -/** - * Process CloudMade Layers - * - * @param layerOptions - * Object of options. - * @param map - * Reference to OpenLayers object. - * @return - * Valid OpenLayers layer. - */ -Drupal.openlayers.layer.cloudmade = function(title, map, options) { - return new OpenLayers.Layer.CloudMade(title, options); -}; diff --git a/plugins/layer_types/openlayers_layer_type_dummy.inc b/plugins/layer_types/openlayers_layer_type_dummy.inc deleted file mode 100644 index 2283fc5f54a1bba2cd0ef013f67693706a06854a..0000000000000000000000000000000000000000 --- a/plugins/layer_types/openlayers_layer_type_dummy.inc +++ /dev/null @@ -1,37 +0,0 @@ - 'dummy', - 'vector' => TRUE, - ) + parent::options_init(); - } - - /** - * Options form which generates layers - */ - function options_form($defaults = array()) { - return array(); - } - - /** - * Render. - */ - function render(&$map) { - drupal_add_js(drupal_get_path('module', 'openlayers') . - '/plugins/layer_types/openlayers_layer_type_dummy.js'); - } -} - diff --git a/plugins/layer_types/openlayers_layer_type_dummy.js b/plugins/layer_types/openlayers_layer_type_dummy.js deleted file mode 100644 index f188c15c9f875f37a5b6a8a72fa802a75a871c46..0000000000000000000000000000000000000000 --- a/plugins/layer_types/openlayers_layer_type_dummy.js +++ /dev/null @@ -1,7 +0,0 @@ - -/** - * OpenLayers Dummy Layer Handler - */ -Drupal.openlayers.layer.dummy = function(title, map, options) { - return new OpenLayers.Layer(title, options); -}; diff --git a/plugins/layer_types/openlayers_layer_type_geojson.inc b/plugins/layer_types/openlayers_layer_type_geojson.inc deleted file mode 100644 index 070e18179854829037efe659682e7210603eab0e..0000000000000000000000000000000000000000 --- a/plugins/layer_types/openlayers_layer_type_geojson.inc +++ /dev/null @@ -1,116 +0,0 @@ - 'openlayers_layer_type_geojson', - 'layer_handler' => 'geojson', - 'projection' => array('EPSG:4326'), - 'serverResolutions' => openlayers_get_resolutions('EPSG:4326'), - 'isBaseLayer' => FALSE, - 'vector' => TRUE, - 'geojson_data' => '', - 'useBBOX' => FALSE, - ) + parent::options_init(); - } - - /** - * Options form which generates layers - */ - function options_form($defaults = array()) { - return array( - 'url' => array( - '#type' => 'textfield', - '#title' => t('URL'), - '#description' => t('The URL of the GeoJSON file. This can be a Drupal path as well, as it will get run through the Drupal url() function.', - array('!url' => 'http://api.drupal.org/api/drupal/includes--common.inc/function/url')), - '#maxlength' => 1024, - '#default_value' => isset($this->data['url']) ? $this->data['url'] : '', - ), - 'useBBOX' => array( - '#type' => 'checkbox', - '#title' => t('Use Bounding Box Strategy'), - '#description' => t('Bounding Box strategy will add a query string onto the GeoJSON URL, which means that only data in the viewport of the map will be loaded. This can be helpful if you have lots of data coming from the feed.'), - '#default_value' => isset($this->data['useBBOX']) ? $this->data['useBBOX'] : FALSE, - ), - //see http://dev.openlayers.org/docs/files/OpenLayers/Strategy/BBOX-js.html#OpenLayers.Strategy.BBOX.resFactor - 'resFactor' => array( - '#type' => 'textfield', - '#title' => t('Bounding Box resFactor'), - '#description' => t('Used to determine when previously requested features are invalid (set to 1 if unsure). - The resFactor will be compared to the resolution of the previous request to the current map resolution.
- If resFactor > (old / new) and 1/resFactor < (old / new). -
    -
  • If you set a resFactor of 1, data will be requested every time the resolution changes.
  • -
  • If you set a resFactor of 3, data will be requested if the old resolution is 3 times the new, or if the new is 3 times the old.
  • -
  • If the old bounds do not contain the new bounds new data will always be requested (with or without considering resFactor).
  • -
- '), - '#default_value' => isset($this->data['resFactor']) ? $this->data['resFactor'] : 1 - ), - //see http://dev.openlayers.org/docs/files/OpenLayers/Strategy/BBOX-js.html#OpenLayers.Strategy.BBOX.ratio - 'ratio' => array( - '#type' => 'textfield', - '#title' => t('Bounding Box ratio'), - '#description' => t('The ratio of the data bounds to the viewport bounds (in each dimension). Default is 3.'), - '#default_value' => isset($this->data['ratio']) ? $this->data['ratio'] : 3 - ), - 'preload' => array( - '#type' => 'checkbox', - '#title' => t('Preload layer'), - '#description' => t('Load data before layer is made visible. Useful when you want to avoid having to wait for an Ajax call to load the data'), - '#default_value' => isset($this->data['preload']) ? $this->data['preload'] : FALSE, - ), - 'useScript' => array( - '#type' => 'checkbox', - '#title' => t('Use Script Method'), - '#description' => t('Avoid 405 error and XSS issues load data from another server with ajax'), - '#default_value' => isset($this->data['useScript']) ? $this->data['useScript'] : FALSE, - ), - 'callbackKey' => array( - '#type' => 'textfield', - '#title' => t('Script Callback Key'), - '#description' => t('Key returned by callback along with geoJSON'), - '#default_value' => isset($this->data['callbackKey']) ? $this->data['callbackKey'] : NULL - ), - 'geojson_data' => array( - '#type' => 'textarea', - '#title' => t('GeoJSON Data'), - '#description' => t('Paste raw GeoJSON data here. It is better to use a URL. This is provided for very simple use cases like one or two features. If there is data here, it will override the URL above.'), - '#default_value' => isset($this->data['geojson_data']) ? $this->data['geojson_data'] : '', - ), - ); - } - - /** - * Render. - */ - function render(&$map) { - if (isset($map['views_arguments'])) { - foreach ((array) $map['views_arguments'] as $name => $value) { - $this->data['url'] = str_replace("[{$name}]", $value, $this->data['url']); - } - } - - if (module_exists('facetapi') && (isset($_GET['f']))) { - $this->data['url'] = !empty($this->data['url']) ? file_create_url($this->data['url'], array('query' => array('f' => $_GET['f']))) : ''; - } - else { - $this->data['url'] = !empty($this->data['url']) ? file_create_url($this->data['url']) : ''; - } - - drupal_add_js(drupal_get_path('module', 'openlayers') - . '/plugins/layer_types/openlayers_layer_type_geojson.js'); - } -} diff --git a/plugins/layer_types/openlayers_layer_type_geojson.js b/plugins/layer_types/openlayers_layer_type_geojson.js deleted file mode 100644 index 569de80d189c4827dba6ab096f4d90abad86b956..0000000000000000000000000000000000000000 --- a/plugins/layer_types/openlayers_layer_type_geojson.js +++ /dev/null @@ -1,108 +0,0 @@ -/** - * @file - * Layer handler for GeoJSON layers - */ - -/** - * Openlayer layer handler for KML layer - */ -Drupal.openlayers.layer.geojson = function(title, map, options) { - var features = null; - options.projection = new OpenLayers.Projection(options.projection); - options.styleMap = Drupal.openlayers.getStyleMap(map, options.drupalID); - - // GeoJSON Projection handling - var geojson_options = { - 'internalProjection': new OpenLayers.Projection(map.projection), - 'externalProjection': options.projection - }; - - // If GeoJSON data is provided with the layer, use that. Otherwise - // check if BBOX, then finally use AJAX method. - if (options.geojson_data) { - var layer = new OpenLayers.Layer.Vector(title, options); - - // Read data in. - features = new OpenLayers.Format.GeoJSON(geojson_options).read(options.geojson_data); - if (features) { - // If not array (ie only one feature) - if (features.constructor != Array) { - features = [features]; - } - } - - // Add features, if needed - if (features) { - layer.addFeatures(features); - layer.events.triggerEvent('loadend'); - } - } - else { - // @todo Add more strategies. Paging strategy would be really interesting - // to use with views_geojson. - // @see http://dev.openlayers.org/releases/OpenLayers-2.12/doc/apidocs/files/OpenLayers/Strategy/Paging-js.html - if (options.useBBOX) { - // BBOX strategy. - // @see http://dev.openlayers.org/releases/OpenLayers-2.12/doc/apidocs/files/OpenLayers/Strategy/BBOX-js.html - var strategy = new OpenLayers.Strategy.BBOX(options); - /* - * We override the triggerRead of the strategy so we can add a zoom=thecurrentzoomlevel in the URL - * This is used by the geocluster module http://drupal.org/project/geocluster - */ - strategy.triggerRead = - function(options) { - if (this.response && !(options && options.noAbort === true)) { - this.layer.protocol.abort(this.response); - this.layer.events.triggerEvent("loadend"); - } - this.layer.events.triggerEvent("loadstart"); - options.params = new Array(); - options.params['zoom'] = options.object.map.zoom; - this.response = this.layer.protocol.read( - OpenLayers.Util.applyDefaults({ - filter: this.createFilter(), - callback: this.merge, - scope: this - }, options)); - }; - options.strategies = [strategy]; - } - else { - // Fixed strategy. - // @see http://dev.openlayers.org/releases/OpenLayers-2.12/doc/apidocs/files/OpenLayers/Strategy/Fixed-js.html - if (options.preload) { - options.strategies = [new OpenLayers.Strategy.Fixed({preload: true})]; - } - else { - options.strategies = [new OpenLayers.Strategy.Fixed()]; - } - } - if(options.useScript){ - //use Script protocol to get around xss issues and 405 error - options.protocol = new OpenLayers.Protocol.Script({ - url: options.url, - callbackKey: options.callbackKey, - callbackPrefix: "callback:", - filterToParams: function(filter, params) { - // example to demonstrate BBOX serialization - if (filter.type === OpenLayers.Filter.Spatial.BBOX) { - params.bbox = filter.value.toArray(); - if (filter.projection) { - params.bbox.push(filter.projection.getCode()); - } - } - return params; - } - }); - } - else{ - options.protocol = new OpenLayers.Protocol.HTTP({ - url: options.url, - format: new OpenLayers.Format.GeoJSON() - }); - } - var layer = new OpenLayers.Layer.Vector(title, options); - } - - return layer; -}; diff --git a/plugins/layer_types/openlayers_layer_type_google.inc b/plugins/layer_types/openlayers_layer_type_google.inc deleted file mode 100644 index f4e962862eb5e5387c4bedcf8aff5d48196047af..0000000000000000000000000000000000000000 --- a/plugins/layer_types/openlayers_layer_type_google.inc +++ /dev/null @@ -1,161 +0,0 @@ - 'google', - 'animationEnabled' => TRUE, - 'sphericalMercator' => TRUE, - 'numZoomLevels' => 21 - ) + parent::options_init(); - } - - /** - * Options form which generates layers - */ - function options_form($defaults = array()) { - $google_layer_types = array( - 'hybrid' => 'Hybrid', - 'normal' => 'Normal', - 'satellite' => 'Satellite', - 'physical' => 'Physical', - ); - return array( - 'type' => array( - '#title' => t('Google Layer Type'), - '#type' => 'select', - '#default_value' => isset($this->data['type']) ? $this->data['type'] : 'normal', - '#options' => $google_layer_types - ), - 'numZoomLevels' => array( - '#type' => 'textfield', - '#title' => t('Number of Zoom Levels'), - '#description' => t('Satellite and hybrid maps are occasionally - unavailable at higher zoom levels.'), - '#default_value' => isset($this->data['numZoomLevels']) ? - $this->data['numZoomLevels'] : '21' - ), - 'animationEnabled' => array( - '#type' => 'checkbox', - '#title' => t('Animation Enabled'), - '#description' => t('This enables the Google Maps API zooming animation. - If you are having issues with your Google layer, it may be helpful - to turn this off.'), - '#default_value' => isset($this->data['animationEnabled']) ? - $this->data['animationEnabled'] : TRUE - ), - ); - } - - /** - * Layer-type-wide settings form - */ - function settings_form() { - return array( - 'openlayers_google_version' => array( - '#type' => 'select', - '#title' => t('Google Maps API version'), - '#description' => t('If you use Google Maps v3, an API key is not necessary.'), - '#options' => array( - '2' => t('v2'), - '3.5' => t('v3.5'), - ), - '#default_value' => variable_get('openlayers_google_version', '3.5'), - ), - 'openlayers_layers_google_mapdomain' => array( - '#type' => 'select', - '#options' => array( - 'maps.google.com' => 'maps.google.com', - 'maps.googleapis.com' => 'maps.googleapis.com', - ), - '#title' => t('Google map default domain'), - '#default_value' => variable_get('openlayers_layers_google_mapdomain', 'maps.google.com'), - '#description' => t('Select the Google Map default domain. maps.googleapis.com is cookie-free.') - ), - 'openlayers_layers_google_api' => array( - '#type' => 'textfield', - '#title' => t('Google API Key'), - '#default_value' => variable_get('openlayers_layers_google_api', ''), - '#description' => t('Obtain an API key from Google for your domain', - array('@google' => 'http://code.google.com/apis/maps/signup.html')) - ), - 'openlayers_layers_google_language' => array( - '#type' => 'textfield', - '#title' => t('Language'), - '#description' => t('This will set the language used - for the interface (like attribution) as well as tiles, - as supported by Google. By default, Google Map API will - determine the language automatically. Only use this is you - want to force a specific language. Please see - this list of languages.', - array('!url' => 'http://sites.google.com/site/tomihasa/google-language-codes') - ), - '#default_value' => variable_get('openlayers_layers_google_language', ''), - ), - 'openlayers_layers_google_libraries' => array( - '#type' => 'textfield', - '#title' => t('Google Maps Libraries'), - '#description' => t('Insert name of libraries delemited by comma without whitespaces. - This will determine which libraries will be included in Google Map API v3 js file.' - ), - '#default_value' => variable_get('openlayers_layers_google_libraries', ''), - '#states' => array( - // Show the settings if 'openlayers_google_version' has been selected for '3.5'. - 'visible' => array( - ':input[name="openlayers_layer_type_google[settings][openlayers_google_version]"]' => array('value' => '3.5'), - ), - ), - ), - ); - } - - /** - * Render. - */ - function render(&$map) { - global $language; - static $google_maps_included; - - if (!isset($google_maps_included)) { - // Include files. - drupal_add_js(drupal_get_path('module', 'openlayers') . - '/plugins/layer_types/openlayers_layer_type_google.js'); - - $mapdomain = variable_get('openlayers_layers_google_mapdomain', 'maps.google.com'); - $version = variable_get('openlayers_google_version', '3.5'); - - if ($version == '2') { - // Create URL for google include - $url = '//' . $mapdomain . '/maps?file=api&sensor=false&v=' . $version; - $key = variable_get('openlayers_layers_google_api', variable_get('googlemap_api_key', '')); - $url .= !empty($key) ? '&key=' . $key : ''; - } - else { - // Create URL for google include - $url = '//' . $mapdomain . '/maps/api/js?sensor=false&v=' . $version; - } - - $lang = variable_get('openlayers_layers_google_language', ''); - $lang == '' ? $language->language : $lang; - // Google v2 uses hl and v3 uses language - $url .= !empty($lang) ? '&hl=' . $lang : ''; - $url .= !empty($lang) ? '&language=' . $lang : ''; - - $libraries = variable_get('openlayers_layers_google_libraries', ''); - $url .= !empty($libraries) ? '&libraries=' . $libraries : ''; - - drupal_add_js($url, 'external'); - $google_maps_included = TRUE; - } - } -} diff --git a/plugins/layer_types/openlayers_layer_type_google.js b/plugins/layer_types/openlayers_layer_type_google.js deleted file mode 100644 index c681f04fb1505e0b93f42887d1fc67c4e016ab1b..0000000000000000000000000000000000000000 --- a/plugins/layer_types/openlayers_layer_type_google.js +++ /dev/null @@ -1,25 +0,0 @@ - -/** - * Process Google Layers - * - * @param layerOptions - * Object of options. - * @param map - * Reference to OpenLayers object. - * @return - * Valid OpenLayers layer. - */ -Drupal.openlayers.layer.google = function(title, map, options) { - // if G_ vars exists we're using gmap v2 - var google_type_map = { - 'normal': window['G_NORMAL_MAP'] || null, - 'satellite': window['G_SATELLITE_MAP'] || google.maps.MapTypeId.SATELLITE, - 'hybrid': window['G_HYBRID_MAP'] || google.maps.MapTypeId.HYBRID, - 'physical': window['G_PHYSICAL_MAP'] || google.maps.MapTypeId.TERRAIN - }; - - options.type = google_type_map[options.type]; - options.projection = new OpenLayers.Projection(options.projection); - - return new OpenLayers.Layer.Google(title, options); -}; diff --git a/plugins/layer_types/openlayers_layer_type_gpx.inc b/plugins/layer_types/openlayers_layer_type_gpx.inc deleted file mode 100644 index 8ed42a7ee70d275e42b1ced489c1eaeb1e182fd7..0000000000000000000000000000000000000000 --- a/plugins/layer_types/openlayers_layer_type_gpx.inc +++ /dev/null @@ -1,190 +0,0 @@ - 'gpx', - 'projection' => array('EPSG:4326'), - 'resolutions' => openlayers_get_resolutions('EPSG:4326'), - 'serverResolutions' => openlayers_get_resolutions('EPSG:4326'), - 'maxExtent' => openlayers_get_extent('EPSG', '4326'), - 'isBaseLayer' => FALSE, - 'vector' => TRUE, - 'formatOptions' => array( - 'extractWaypoints' => TRUE, - 'extractRoutes' => TRUE, - 'extractTracks' => TRUE, - 'extractAttributes' => TRUE, - ), - 'file' => '', - ) + parent::options_init(); - } - - /** - * Options form which generates layers - */ - function options_form($defaults = array()) { - return array( - 'method' => array( - '#type' => 'select', - '#options' => array( - '' => 'Choose the method', - 'url' => 'Provides an URL', - 'file' => 'Upload a file', - 'raw' => 'Write GPX' - ), - '#default_value' => isset($this->data['method']) ? - $this->data['method'] : '', - ), - 'url' => array( - '#type' => 'textfield', - '#title' => t('URL'), - '#description' => t('The URL of the GPX file.'), - '#maxlength' => 2083, - '#default_value' => isset($this->data['url']) ? - $this->data['url'] : '', - '#states' => array( - 'visible' => array( - ':input[name="openlayers_layer_type_gpx[method]"]' => array('value' => 'url'), - ) - ) - ), - 'file' => array( - '#name' => 'files[imagelayer]', - '#type' => 'managed_file', - '#title' => t('GPX file'), - '#default_value' => isset($this->data['file']) ? $this->data['file'] : '', - '#upload_location' => 'public://', - '#upload_validators' => array( - 'file_validate_extensions' => array('gpx') - ), - '#states' => array( - 'visible' => array( - ':input[name="openlayers_layer_type_gpx[method]"]' => array('value' => 'file'), - ) - ) - ), - 'raw' => array( - '#type' => 'textarea', - '#title' => t('Raw GPX'), - '#description' => t('Copy your GPX in this textarea. Don\'t forget that this is not intented to have a big length.'), - '#default_value' => isset($this->data['raw']) ? - $this->data['raw'] : '', - '#states' => array( - 'visible' => array( - ':input[name="openlayers_layer_type_gpx[method]"]' => array('value' => 'raw'), - ) - ) - ), - 'formatOptions' => array( - 'extractWaypoints' => array( - '#type' => 'checkbox', - '#title' => t('Extract Waypoints'), - '#description' => t('Extract waypoints from GPX.'), - '#default_value' => isset( - $this->data['formatOptions']['extractWaypoints']) ? - $this->data['formatOptions']['extractWaypoints'] : TRUE, - ), - 'extractTracks' => array( - '#type' => 'checkbox', - '#title' => t('Extract Tracks'), - '#description' => t('Extract tracks from GPX.'), - '#default_value' => isset( - $this->data['formatOptions']['extractTracks']) ? - $this->data['formatOptions']['extractTracks'] : TRUE, - ), - 'extractRoutes' => array( - '#type' => 'checkbox', - '#title' => t('Extract Routes'), - '#description' => t('Extract routes from GPX.'), - '#default_value' => isset( - $this->data['formatOptions']['extractRoutes']) ? - $this->data['formatOptions']['extractRoutes'] : TRUE, - ), - 'extractAttributes' => array( - '#type' => 'checkbox', - '#title' => t('Extract Attributes'), - '#description' => t('Extract attributes from GPX.'), - '#default_value' => isset( - $this->data['formatOptions']['extractAttributes']) ? - $this->data['formatOptions']['extractAttributes'] : TRUE, - ), - ), - ); - } - - /* - * The file is mandatory. - */ - function options_form_validate($form, &$form_state) { - $method = $form_state['data']['method']; - - if (empty($form_state['data'][$method])) { - form_set_error($form_state['data']['layer_type'] . '][' . $method, 'The field cannot be empty'); - } - - if ($method == 'file') { - if ($file = file_load($form_state['data']['file'])) { - // TODO Why nothing here? - } - else { - form_set_error($form_state['data']['layer_type'] . '][' . $method, 'Cannot access the file.'); - } - } - - $form_state['data']['formatOptions']['extractWaypoints'] = $form_state['data']['formatOptions']['extractWaypoints']!=0?TRUE:FALSE; - $form_state['data']['formatOptions']['extractRoutes'] = $form_state['data']['formatOptions']['extractRoutes']!=0?TRUE:FALSE; - $form_state['data']['formatOptions']['extractTracks'] = $form_state['data']['formatOptions']['extractTracks']!=0?TRUE:FALSE; - $form_state['data']['formatOptions']['extractAttributes'] = $form_state['data']['formatOptions']['extractAttributes']!=0?TRUE:FALSE; - } - - /** - * hook_submit() of the form. - */ - function options_form_submit($form, &$form_state) { - parent::options_form_submit($form, $form_state); - global $user; - - $item = $form_state['item']; - if (isset($item->data['file']) && $file = file_load($item->data['file'])) { - file_delete($file); - } - - if (isset($form_state['values']['data']['file']) && $file = file_load($form_state['values']['data']['file'])) { - $file->status = FILE_STATUS_PERMANENT; - file_save($file); - file_usage_add($file, 'openlayers', 'layer_type', $user->uid); - $form_state['values']['data']['url'] = file_create_url($file->uri); - } - } - - /* - * What to do when we delete the layer: delete the file. - */ - function delete($item) { - if (is_numeric($item->data['file']) && $item->data['file'] > 0) { - $file = file_load($item->data['file']); - file_delete($file); - } - } - - /** - * Render. - */ - function render(&$map) { - $this->data['url'] = !empty($this->data['url']) ? file_create_url($this->data['url']) : ''; - drupal_add_js(drupal_get_path('module', 'openlayers') - . '/plugins/layer_types/openlayers_layer_type_gpx.js'); - } -} diff --git a/plugins/layer_types/openlayers_layer_type_gpx.js b/plugins/layer_types/openlayers_layer_type_gpx.js deleted file mode 100644 index 576d3dc2f43c9cd63edf0511dc9f79ba4a52df92..0000000000000000000000000000000000000000 --- a/plugins/layer_types/openlayers_layer_type_gpx.js +++ /dev/null @@ -1,20 +0,0 @@ -/** - * @file - * Layer handler for KML layers - */ - -/** - * Openlayer layer handler for GPX layer - */ -Drupal.openlayers.layer.gpx = function(title, map, options) { - return new OpenLayers.Layer.Vector(title, { - drupalID: options.drupalID, - strategies: [new OpenLayers.Strategy.Fixed()], - protocol: new OpenLayers.Protocol.HTTP({ - url: options.url, - format: new OpenLayers.Format.GPX(options.formatOptions) - }), - styleMap: Drupal.openlayers.getStyleMap(map, options.drupalID), - projection: new OpenLayers.Projection("EPSG:4326") - }); -}; diff --git a/plugins/layer_types/openlayers_layer_type_image.inc b/plugins/layer_types/openlayers_layer_type_image.inc deleted file mode 100644 index d3e5c444866d7687f2749b5d2a65e3086d09a859..0000000000000000000000000000000000000000 --- a/plugins/layer_types/openlayers_layer_type_image.inc +++ /dev/null @@ -1,158 +0,0 @@ - 'image', - 'file' => NULL, - 'image_style' => NULL, - 'opacity' => 1, - 'factors' => array( - 'x' => 1, - 'y' => 1 - ), - 'numZoomLevels' => 1 - ) + parent::options_init(); - } - - /** - * Options form which generates layers - */ - function options_form($defaults = array()) { - return array( - 'file' => array( - '#name' => 'files[imagelayer]', - '#type' => 'managed_file', - '#title' => t('Image'), - '#default_value' => isset($this->data['file']) ? $this->data['file'] : '', - '#upload_location' => 'public://', - ), - 'image_style' => array( - '#type' => 'select', - '#options' => array(''=> 'None (original image)') + image_style_options(FALSE), - '#default_value' => isset($this->data['image_style']) ? $this->data['image_style'] : NULL, - '#description' => t('Apply an image style.'), - ), - 'factors' => array( - '#tree' => TRUE, - 'x' => array( - '#title' => 'Width divider', - '#type' => 'textfield', - '#default_value' => isset($this->data['factors']['x']) ? $this->data['factors']['x'] : 1, - '#description' => t('Width divider.'), - ), - 'y' => array( - '#title' => 'Height divider', - '#type' => 'textfield', - '#default_value' => isset($this->data['factors']['y']) ? $this->data['factors']['y'] : 1, - '#description' => t('Height divider.'), - ), - ), - 'maxExtent' => array( - '#type' => 'textfield', - '#title' => t('Max Extent'), - '#default_value' => isset($this->data['maxExtent']) ? implode(', ', $this->data['maxExtent']) : '', - '#description' => t('Should consist of four values (left, bottom, right, top). The maximum extent for the layer. Image is stretched to cover whole map if left empty.'), - ), - 'numZoomLevels' => array( - '#title' => 'Zoomlevels', - '#type' => 'textfield', - '#default_value' => isset($this->data['numZoomLevels']) ? $this->data['numZoomLevels'] : 1 - ), - ); - } - - /** - * hook_validate() of the form. - */ - function options_form_validate($form, &$form_state) { - parent::options_form_validate($form, $form_state); - $form_state['data']['numZoomLevels'] = intVal($form_state['data']['numZoomLevels']); - $form_state['data']['factors']['x'] = intVal($form_state['data']['factors']['x']); - $form_state['data']['factors']['y'] = intVal($form_state['data']['factors']['y']); - - if ($file = file_load($form_state['data']['file'])) { - // Do something with the file if needed. - } else { - form_set_error($form_state['data']['layer_type'].'][file', 'Cannot access the file.'); - } - } - - /** - * hook_submit() of the form. - */ - function options_form_submit($form, &$form_state) { - parent::options_form_submit($form, $form_state); - global $user; - - $item = $form_state['item']; - if (isset($item->data['file']) && $file = file_load($item->data['file'])) { - file_delete($file); - } - - if (isset($form_state['values']['data']['file']) && $file = file_load($form_state['values']['data']['file'])) { - $file->status = FILE_STATUS_PERMANENT; - file_save($file); - file_usage_add($file, 'openlayers', 'openlayers_layer_type', $user->uid); - } - - $style = $form_state['values']['data']['image_style']; - - if (!empty($style)) { - $uri = image_style_path($style, $file->uri); - image_style_create_derivative(image_style_load($style), $file->uri, $uri); - } else { - $uri = $file->uri; - } - - $infos = image_get_info($uri); - $form_state['values']['data']['size'] = array(); - $form_state['values']['data']['size']['w'] = $infos['width']; - $form_state['values']['data']['size']['h'] = $infos['height']; - $form_state['values']['data']['maxExtent'] = array_map('floatval', explode(",", $form_state['values']['data']['maxExtent'])); - if(count($form_state['values']['data']['maxExtent'])!==4){ - // Ignore invalid input. - $form_state['values']['data']['maxExtent'] = NULL; - } - } - - /* - * What to do when we delete the layer: delete the file. - */ - function delete($item) { - $file = file_load($item->data['file']); - file_delete($file); - } - - /** - * Render. - */ - function render(&$map) { - if (isset($this->data['file'])) { - if ($file = file_load($this->data['file'])) { - $this->data['file'] = array(); - if (!empty($this->data['image_style'])) { - $this->data['file'] = image_style_url($this->data['image_style'] ,$file->uri); - } else { - $this->data['file'] = file_create_url($file->uri); - } - unset($this->data['image_style']); - - drupal_add_js(drupal_get_path('module', 'openlayers') . - '/plugins/layer_types/openlayers_layer_type_image.js'); - } - } - } -} diff --git a/plugins/layer_types/openlayers_layer_type_image.js b/plugins/layer_types/openlayers_layer_type_image.js deleted file mode 100644 index 88b2fd94ca26d4aa8eadb9a470e363e43a9f0b2b..0000000000000000000000000000000000000000 --- a/plugins/layer_types/openlayers_layer_type_image.js +++ /dev/null @@ -1,28 +0,0 @@ -/** - * OpenLayers Image Layer Handler - */ -Drupal.openlayers.layer.image = function(title, map, options) { - var maxExtent; - if (options.maxExtent === null) { - // Stretch image to cover whole map if not specified. - maxExtent = map.maxExtent; - } else { - maxExtent = options.maxExtent; - } - - return new OpenLayers.Layer.Image( - title, - options.file, - OpenLayers.Bounds.fromArray(maxExtent), - new OpenLayers.Size(options.size.w/options.factors.x, options.size.h/options.factors.y), - { - drupalID: options.drupalID, - numZoomLevels: options.numZoomLevels, - opacity: options.opacity, - projection: new OpenLayers.Projection(options.projection), - transitionEffect: options.transitionEffect, - isBaseLayer: options.isBaseLayer, - attribution: options.attribution - } - ); -}; diff --git a/plugins/layer_types/openlayers_layer_type_kml.inc b/plugins/layer_types/openlayers_layer_type_kml.inc deleted file mode 100644 index ce854bea480cf18962227a9650ce51f7151a462f..0000000000000000000000000000000000000000 --- a/plugins/layer_types/openlayers_layer_type_kml.inc +++ /dev/null @@ -1,189 +0,0 @@ - 'kml', - 'projection' => array('EPSG:4326'), - 'resolutions' => openlayers_get_resolutions('EPSG:4326'), - 'serverResolutions' => openlayers_get_resolutions('EPSG:4326'), - 'maxExtent' => openlayers_get_extent('EPSG', '4326'), - 'isBaseLayer' => FALSE, - 'vector' => TRUE, - 'formatOptions' => array( - 'extractStyles' => TRUE, - 'extractAttributes' => TRUE, - 'extractTracks' => FALSE, - ), - 'file' => '', - 'attribution' => '', - ) + parent::options_init(); - } - - /** - * Options form which generates layers - */ - function options_form($defaults = array()) { - return array( - 'method' => array( - '#type' => 'select', - '#options' => array( - '' => 'Choose the method', - 'url' => 'Provides an URL', - 'file' => 'Upload a file', - 'raw' => 'Write KML' - ), - '#default_value' => isset($this->data['method']) ? - $this->data['method'] : '', - ), - 'url' => array( - '#type' => 'textfield', - '#title' => t('URL'), - '#description' => t('The URL of the KML file.'), - '#maxlength' => 2083, - '#default_value' => isset($this->data['url']) ? - $this->data['url'] : '', - '#states' => array( - 'visible' => array( - ':input[name="openlayers_layer_type_kml[method]"]' => array('value' => 'url'), - ) - ) - ), - 'file' => array( - '#name' => 'files[imagelayer]', - '#type' => 'managed_file', - '#title' => t('KML file'), - '#default_value' => isset($this->data['file']) ? $this->data['file'] : '', - '#upload_location' => 'public://', - '#upload_validators' => array( - 'file_validate_extensions' => array('kml') - ), - '#states' => array( - 'visible' => array( - ':input[name="openlayers_layer_type_kml[method]"]' => array('value' => 'file'), - ) - ) - ), - 'raw' => array( - '#type' => 'textarea', - '#title' => t('Raw KML'), - '#description' => t('Copy your KML in this textarea. Don\'t forget that this is not intented to have a big length.'), - '#default_value' => isset($this->data['raw']) ? - $this->data['raw'] : '', - '#states' => array( - 'visible' => array( - ':input[name="openlayers_layer_type_kml[method]"]' => array('value' => 'raw'), - ) - ) - ), - 'formatOptions' => array( - 'extractStyles' => array( - '#type' => 'checkbox', - '#title' => t('Extract Styles'), - '#description' => t('Extract styles from KML.'), - '#default_value' => isset( - $this->data['formatOptions']['extractStyles']) ? - $this->data['formatOptions']['extractStyles'] : TRUE, - ), - 'extractTracks' => array( - '#type' => 'checkbox', - '#title' => t('Extract Tracks'), - '#description' => t('Extract tracks from KML.'), - '#default_value' => isset( - $this->data['formatOptions']['extractTracks']) ? - $this->data['formatOptions']['extractTracks'] : TRUE, - ), - 'extractAttributes' => array( - '#type' => 'checkbox', - '#title' => t('Extract Attributes'), - '#description' => t('Extract attributes from KML.'), - '#default_value' => isset( - $this->data['formatOptions']['extractAttributes']) ? - $this->data['formatOptions']['extractAttributes'] : TRUE, - ), - ), - 'attribution' => array( - '#type' => 'textfield', - '#title' => t('Attribution'), - '#default_value' => isset($this->data['attribution']) ? - $this->data['attribution'] : '', - ), - ); - } - - /* - * The file is mandatory. - */ - function options_form_validate($form, &$form_state) { - $method = $form_state['data']['method']; - - if (empty($form_state['data'][$method])) { - form_set_error($form_state['data']['layer_type'] . '][' . $method, 'The field cannot be empty'); - } - - if ($method == 'file') { - if ($file = file_load($form_state['data']['file'])) { - // TODO Why nothing here? - } - else { - form_set_error($form_state['data']['layer_type'] . '][' . $method, 'Cannot access the file.'); - } - } - - $form_state['data']['formatOptions']['extractStyles'] = $form_state['data']['formatOptions']['extractStyles']!=0?TRUE:FALSE; - $form_state['data']['formatOptions']['extractAttributes'] = $form_state['data']['formatOptions']['extractAttributes']!=0?TRUE:FALSE; - $form_state['data']['formatOptions']['extractTracks'] = $form_state['data']['formatOptions']['extractTracks']!=0?TRUE:FALSE; - - $form_state['data']['attribution'] = isset($form_state['data']['attribution']) ? filter_xss($form_state['data']['attribution']) : ''; - } - - /** - * hook_submit() of the form. - */ - function options_form_submit($form, &$form_state) { - parent::options_form_submit($form, $form_state); - global $user; - - $item = $form_state['item']; - if (isset($item->data['file']) && $file = file_load($item->data['file'])) { - file_delete($file); - } - - if (isset($form_state['values']['data']['file']) && $file = file_load($form_state['values']['data']['file'])) { - $file->status = FILE_STATUS_PERMANENT; - file_save($file); - file_usage_add($file, 'openlayers', 'layer_type', $user->uid); - $form_state['values']['data']['url'] = file_create_url($file->uri); - } - } - - /* - * What to do when we delete the layer: delete the file. - */ - function delete($item) { - if (is_numeric($item->data['file']) && $item->data['file'] > 0) { - $file = file_load($item->data['file']); - file_delete($file); - } - } - - /** - * Render. - */ - function render(&$map) { - $this->data['url'] = !empty($this->data['url']) ? file_create_url($this->data['url']) : ''; - drupal_add_js(drupal_get_path('module', 'openlayers') - . '/plugins/layer_types/openlayers_layer_type_kml.js'); - } -} diff --git a/plugins/layer_types/openlayers_layer_type_kml.js b/plugins/layer_types/openlayers_layer_type_kml.js deleted file mode 100644 index 5d59de5469218c29c956175f8088eb86d890ec42..0000000000000000000000000000000000000000 --- a/plugins/layer_types/openlayers_layer_type_kml.js +++ /dev/null @@ -1,57 +0,0 @@ -/** - * @file - * Layer handler for KML layers - */ - -/** - * Openlayer layer handler for KML layer - */ -Drupal.openlayers.layer.kml = function(title, map, options) { - - var layer = new OpenLayers.Layer.Vector(title, { - name: options.name, - drupalID: options.drupalID, - layer_handler: options.layer_handler, - styleMap: Drupal.openlayers.getStyleMap(map, options.drupalID), - attribution: options.attribution - }); - - // KML Projection handling and formating options - var kml_options = options.formatOptions; - kml_options.internalProjection = new OpenLayers.Projection(map.projection); - kml_options.externalProjection = new OpenLayers.Projection(options.projection); - - if (options.method == 'file' || options.method == 'url') { - var uri = options.url; - // Use an AJAX like call to get data from URL - OpenLayers.Request.GET({ - url: uri, - success: function (response) { - if(response.status===0 && response.responseXML===null){ - Drupal.openlayers.console.error("Failed to load KML layer (probably due to same origin policy)", uri); - } else { - addFeatures(response.responseText, kml_options); - } - }, - failure: function (response) { - Drupal.openlayers.console.error("Failed to load KML layer", uri, reponse); - } - }); - } - - if (options.method == 'raw') { - addFeatures(options.raw, kml_options); - } - - function addFeatures(kml, options) { - var format = new OpenLayers.Format.KML(options); - var features = format.read(kml); - // Add features, if needed - if (features) { - layer.addFeatures(features); - layer.events.triggerEvent('loadend'); - } - } - - return layer; -}; diff --git a/plugins/layer_types/openlayers_layer_type_maptiler.inc b/plugins/layer_types/openlayers_layer_type_maptiler.inc deleted file mode 100644 index 4c2d403db75344df7007245c61faa040efe7d5b4..0000000000000000000000000000000000000000 --- a/plugins/layer_types/openlayers_layer_type_maptiler.inc +++ /dev/null @@ -1,79 +0,0 @@ - 'png', - 'layer_handler' => 'maptiler', - 'zoomOffset' => 0, - ) + parent::options_init(); - } - - /** - * Options form which generates layers - */ - function options_form($defaults = array()) { - return array( - 'base_url' => array( - '#type' => 'textfield', - '#title' => t('Base URL'), - '#default_value' => isset($this->data['base_url']) ? - $this->data['base_url'] : '' - ), - 'type' => array( - '#type' => 'select', - '#options' => array( - 'jpg' => 'JPG', - 'png' => 'PNG' - ), - '#default_value' => isset($this->data['type']) ? - $this->data['type'] : 'png' - ), - 'resolutions' => array( - '#type' => 'select', - '#multiple' => TRUE, - '#options' => array_combine( - array_map('strval', openlayers_get_resolutions('EPSG:900913')), - range(0, 21) - ), - '#title' => t('Zoom Level Range'), - '#default_value' => isset($this->data['resolutions']) ? - $this->data['resolutions'] : - array_map('strval', openlayers_get_resolutions('EPSG:900913')) - ), - 'zoomOffset' => array( - '#type' => 'textfield', - '#title' => t('Zoom offset'), - '#default_value' => isset($this->data['zoomOffset']) ? - $this->data['zoomOffset'] : 0, - '#description' => t('If your cache has more zoom levels than you want to provide access to with this layer, supply a zoomOffset. This zoom offset is added to the current map zoom level to determine the level for a requested tile. For example, if you supply a zoomOffset of 3, when the map is at the zoom 0, tiles will be requested from level 3 of your cache. Default is 0 (assumes cache level and map zoom are equivalent). Using zoomOffset is an alternative to setting serverResolutions if you only want to expose a subset of the server resolutions.'), - ), - ); - } - - function options_form_submit($form, &$form_state) { - parent::options_form_submit($form, $form_state); - $form_state['values']['data']['base_url'] = explode("\n", $form_state['values']['data']['base_url']); - $form_state['values']['data']['resolutions'] = array_map('floatval', array_values($form_state['values']['data']['resolutions'])); - $form_state['values']['data']['zoomOffset'] = intval($form_state['values']['data']['zoomOffset'], 10); - } - - /** - * Render. - */ - function render(&$map) { - drupal_add_js(drupal_get_path('module', 'openlayers') . - '/plugins/layer_types/openlayers_layer_type_maptiler.js'); - } -} diff --git a/plugins/layer_types/openlayers_layer_type_maptiler.js b/plugins/layer_types/openlayers_layer_type_maptiler.js deleted file mode 100644 index 1526ae2002cc5128a24d97ff27b67075752c6652..0000000000000000000000000000000000000000 --- a/plugins/layer_types/openlayers_layer_type_maptiler.js +++ /dev/null @@ -1,29 +0,0 @@ - -/** - * @file - * Layer handler for TMS layers - */ - -/** - * Openlayer layer handler for TMS layer - */ -Drupal.openlayers.layer.maptiler = function(title, map, options) { - if (OpenLayers.Util.isArray(options.maxExtent)) { - options.maxExtent = OpenLayers.Bounds.fromArray(options.maxExtent); - } - - options.getURL = function(bounds) { - var res = this.map.getResolution(); - var x = Math.round((bounds.left - this.maxExtent.left) / (res * this.tileSize.w)); - var y = Math.round((bounds.bottom - this.tileOrigin.lat) / (res * this.tileSize.h)); - var z = this.map.getZoom(); - if (x >= 0 && y >= 0) { - return this.url + z + "/" + x + "/" + y + "." + this.type; - } else { - return "http://www.maptiler.org/img/none.png"; - } - } - - options.projection = new OpenLayers.Projection(options.projection); - return new OpenLayers.Layer.TMS(title, options.base_url, options); -}; diff --git a/plugins/layer_types/openlayers_layer_type_osm.inc b/plugins/layer_types/openlayers_layer_type_osm.inc deleted file mode 100644 index ee20816f8be5d8259560f045311cd26e3eebd42f..0000000000000000000000000000000000000000 --- a/plugins/layer_types/openlayers_layer_type_osm.inc +++ /dev/null @@ -1,73 +0,0 @@ - 'osm', - 'type' => 'png', - ) + parent::options_init(); - } - - /** - * Options form which generates layers - */ - function options_form($defaults = array()) { - return array( - 'serverResolutions' => array( - '#type' => 'select', - '#multiple' => TRUE, - '#description' => t('Only set this if you need a very specific resolution.'), - '#options' => array_combine( - array_map('strval', openlayers_get_resolutions('EPSG:900913')), - range(0, 21)), - '#title' => t('Zoom Level Range'), - '#default_value' => isset($this->data['serverResolutions']) ? - array_map('strval', $this->data['serverResolutions']) : NULL, - ), - 'resolutions' => array( - '#type' => 'select', - '#multiple' => TRUE, - '#description' => t('Only set this if you need a very specific resolution.'), - '#options' => array_combine( - array_map('strval', openlayers_get_resolutions('EPSG:900913')), - range(0, 21)), - '#title' => t('Zoom Level Range'), - '#default_value' => isset($this->data['resolutions']) ? - array_map('strval', $this->data['resolutions']) : array(), - ), - 'url' => array( - '#type' => 'textarea', - '#title' => t('Base URL (template)'), - '#default_value' => !empty($this->data['url']) ? implode("\n", (array) $this->data['url']) : '', - '#maxlength' => 2083, - '#description' => t('This is the base URL template for the XYZ layer. It should be something similar to http://example.com/tiles/1.0.0/layer_name/${z}/${x}/${y}.png.'), - ), - ); - } - - function options_form_validate($form, &$form_state) { - $form_state['data']['url'] = explode("\n", $form_state['data']['url']); - $form_state['data']['serverResolutions'] = array_map('floatval', array_values($form_state['data']['serverResolutions'])); - $form_state['data']['resolutions'] = array_map('floatval', array_values($form_state['data']['resolutions'])); - } - - - /** - * Render. - */ - function render(&$map) { - drupal_add_js(drupal_get_path('module', 'openlayers') . - '/plugins/layer_types/openlayers_layer_type_osm.js'); - } -} diff --git a/plugins/layer_types/openlayers_layer_type_osm.js b/plugins/layer_types/openlayers_layer_type_osm.js deleted file mode 100644 index 6f9b029617d08b7d8ff6430b69373d2ba9088644..0000000000000000000000000000000000000000 --- a/plugins/layer_types/openlayers_layer_type_osm.js +++ /dev/null @@ -1,12 +0,0 @@ - -/** - * @file - * Layer handler for OSM layers - */ - -/** - * Openlayer layer handler for OSM layer - */ -Drupal.openlayers.layer.osm = function(title, map, options) { - return new OpenLayers.Layer.OSM(title, options.url, options); -}; diff --git a/plugins/layer_types/openlayers_layer_type_pointgrid.inc b/plugins/layer_types/openlayers_layer_type_pointgrid.inc deleted file mode 100644 index 1f658bde9eef817400f0fe52a53d927ac4660e39..0000000000000000000000000000000000000000 --- a/plugins/layer_types/openlayers_layer_type_pointgrid.inc +++ /dev/null @@ -1,86 +0,0 @@ - 'pointgrid', - 'vector' => TRUE, - 'dx' => 100, - 'dy' => 100, - 'ratio' => 1.5, - 'maxFeatures' => 250, - 'rotation' => 0 - ) + parent::options_init(); - } - - /** - * Options form which generates layers - */ - function options_form($defaults = array()) { - return array( - 'dx' => array( - '#type' => 'textfield', - '#title' => t('X-axis point grid spacing'), - '#default_value' => !empty($this->data['dx']) ? $this->data['dx'] : 100, - '#maxlength' => 10, - '#description' => t('Point grid spacing in the x-axis direction (map units).'), - ), - 'dy' => array( - '#type' => 'textfield', - '#title' => t('Y-axis point grid spacing'), - '#default_value' => !empty($this->data['dy']) ? $this->data['dy'] : 100, - '#maxlength' => 10, - '#description' => t('Point grid spacing in the y-axis direction (map units).'), - ), - 'ratio' => array( - '#type' => 'textfield', - '#title' => t('Ratio of the desired grid size to the map viewport size.'), - '#default_value' => !empty($this->data['ratio']) ? $this->data['ratio'] : 1.5, - '#maxlength' => 10, - '#description' => t('Ratio of the desired grid size to the map viewport size. Default is 1.5. Larger ratios mean the grid is recalculated less often while panning. The maxFeatures setting has precedence when determining grid size.'), - ), - 'maxFeatures' => array( - '#type' => 'textfield', - '#title' => t('The maximum number of points to generate in the grid.'), - '#default_value' => !empty($this->data['maxFeatures']) ? $this->data['maxFeatures'] : 250, - '#maxlength' => 10, - '#description' => t('The maximum number of points to generate in the grid. Default is 250.'), - ), - 'rotation' => array( - '#type' => 'textfield', - '#title' => t('Grid rotation (in degrees clockwise from the positive x-axis).'), - '#default_value' => !empty($this->data['rotation']) ? $this->data['rotation'] : 0, - '#maxlength' => 10, - '#description' => t('Grid rotation (in degrees clockwise from the positive x-axis). Default is 0.'), - ), - ); - } - - function options_form_validate($form, &$form_state) { - $form_state['data']['dx'] = (int) $form_state['data']['dx']; - $form_state['data']['dy'] = (int) $form_state['data']['dy']; - $form_state['data']['ratio'] = (float) $form_state['data']['ratio']; - $form_state['data']['maxFeatures'] = (int) $form_state['data']['maxFeatures']; - $form_state['data']['rotation'] = (int) $form_state['data']['rotation']; - } - - /** - * Render. - */ - function render(&$map) { - drupal_add_js(drupal_get_path('module', 'openlayers') . - '/plugins/layer_types/openlayers_layer_type_pointgrid.js'); - } -} - diff --git a/plugins/layer_types/openlayers_layer_type_pointgrid.js b/plugins/layer_types/openlayers_layer_type_pointgrid.js deleted file mode 100644 index 4519c18f31e9426e0cc54fac69762aaf0a3efa29..0000000000000000000000000000000000000000 --- a/plugins/layer_types/openlayers_layer_type_pointgrid.js +++ /dev/null @@ -1,19 +0,0 @@ - -/** - * OpenLayers PointGrid Layer Handler - */ -Drupal.openlayers.layer.pointgrid = function(title, map, options) { - - return new OpenLayers.Layer.PointGrid({ - name: options.name, - drupalID: options.drupalID, - layer_handler: options.layer_handler, - styleMap: Drupal.openlayers.getStyleMap(map, options.drupalID), - dx: options.dx, - dy: options.dy, - ratio: options.ratio, - maxFeatures: options.maxFeatures, - rotation: options.rotation - }); - -}; diff --git a/plugins/layer_types/openlayers_layer_type_raw.inc b/plugins/layer_types/openlayers_layer_type_raw.inc deleted file mode 100644 index 93a6a5798cb52c7802cfb82d0bbe4127ede4539a..0000000000000000000000000000000000000000 --- a/plugins/layer_types/openlayers_layer_type_raw.inc +++ /dev/null @@ -1,40 +0,0 @@ - 'openlayers_raw', - 'vector' => TRUE, - 'isBaseLayer' => FALSE, - ) + parent::options_init(); - } - - /** - * Options form which generates layers - */ - function options_form($defaults = array()) { - return array(); - } - - /** - * Render. - */ - function render(&$map) { - drupal_add_js(drupal_get_path('module', 'openlayers') . - '/plugins/layer_types/openlayers_layer_type_raw.js'); - // $features = ; - // $this->data['features'] = $features; - } -} - diff --git a/plugins/layer_types/openlayers_layer_type_raw.js b/plugins/layer_types/openlayers_layer_type_raw.js deleted file mode 100644 index 2e226c8685e8b96b8a683e40c5330f86fc738278..0000000000000000000000000000000000000000 --- a/plugins/layer_types/openlayers_layer_type_raw.js +++ /dev/null @@ -1,20 +0,0 @@ - -/** - * OpenLayers Raw Layer Handler - */ -Drupal.openlayers.layer.openlayers_raw = function(title, map, options) { - options.options = options.options || {}; - - // Note, so that we do not pass all the features along to the Layer - // options, we use the options.options to give to Layer - options.options.drupalID = options.drupalID; - options.options.styleMap = Drupal.openlayers.getStyleMap(map, options.drupalID); - - var layer = new OpenLayers.Layer.Vector(title, options.options); - - if (options.features) { - Drupal.openlayers.addFeatures(map, layer, options.features); - } - - return layer; -}; diff --git a/plugins/layer_types/openlayers_layer_type_tms.inc b/plugins/layer_types/openlayers_layer_type_tms.inc deleted file mode 100644 index 211cdfa79ac1e9660dbfc160dfa007d036550c6b..0000000000000000000000000000000000000000 --- a/plugins/layer_types/openlayers_layer_type_tms.inc +++ /dev/null @@ -1,118 +0,0 @@ - 'tms', - 'type' => 'png', - 'maptiler' => FALSE, - 'serviceVersion' => '1.0.0', - 'wrapDateLine' => FALSE, - 'zoomOffset' => 0, - 'url' => '' - ) + parent::options_init(); - } - - /** - * Options form which generates layers - */ - function options_form($defaults = array()) { - return array( - 'url' => array( - '#type' => 'textarea', - '#title' => t('Base URL'), - '#default_value' => !empty($this->data['url']) ? implode("\n", $this->data['url']) : '', - '#description' => t('This is the base URL of the TMS service. For example, if this was your tile scheme URL: http://example.com/tms/1.0.0/layer_name/{z}/{y}/{x}.png, then http://example.com/tms/ would be the Base URL.'), - ), - 'layername' => array( - '#type' => 'textfield', - '#title' => t('Layer Name'), - '#default_value' => isset($this->data['layername']) ? - $this->data['layername'] : '', - '#description' => t('This is the base URL of the TMS service. For example, if this was your tile scheme URL: http://example.com/tms/1.0.0/layer_name/{z}/{y}/{x}.png, then layer_name would be the Layer Name.'), - ), - 'type' => array( - '#type' => 'select', - '#title' => t('File Format'), - '#options' => array( - 'png' => 'png', - 'jpg' => 'jpg', - 'jpeg' => 'jpeg'), - '#default_value' => isset($this->data['type']) ? - $this->data['type'] : 'png' - ), - 'resolutions' => array( - '#type' => 'select', - '#multiple' => TRUE, - '#options' => array_combine( - array_map('strval', openlayers_get_resolutions('EPSG:900913')), - range(0, 21) - ), - '#title' => t('Zoom Level Range'), - '#default_value' => isset($this->data['resolutions']) ? - $this->data['resolutions'] : - array_map('strval', openlayers_get_resolutions('EPSG:900913')), - '#description' => t('The available zoom levels for the tiles.'), - ), - 'wrapDateLine' => array( - '#type' => 'checkbox', - '#title' => t('Wrap Dateline'), - '#default_value' => isset($this->data['wrapDateLine']) ? - $this->data['wrapDateLine'] : FALSE, - '#description' => t('Wrapping the dateline will cause the map to appear to repeat itself when going east or west. This may not be supported by all tilesets.'), - ), - 'serviceVersion' => array( - '#type' => 'textfield', - '#title' => t('Service version for tile requests'), - '#default_value' => isset($this->data['serviceVersion']) ? - $this->data['serviceVersion'] : '', - '#description' => t('Service version for tile requests. Default is “1.0.0”.'), - ), - 'zoomOffset' => array( - '#type' => 'textfield', - '#title' => t('Zoom offset'), - '#default_value' => isset($this->data['zoomOffset']) ? - $this->data['zoomOffset'] : 0, - '#description' => t('If your cache has more zoom levels than you want to provide access to with this layer, supply a zoomOffset. This zoom offset is added to the current map zoom level to determine the level for a requested tile. For example, if you supply a zoomOffset of 3, when the map is at the zoom 0, tiles will be requested from level 3 of your cache. Default is 0 (assumes cache level and map zoom are equivalent). Using zoomOffset is an alternative to setting serverResolutions if you only want to expose a subset of the server resolutions.'), - ), - 'maptiler' => array( - '#type' => 'checkbox', - '#title' => t('Rewrite the getUrl method for MapTiler ?'), - '#default_value' => isset($this->data['maptiler']) ? - $this->data['maptiler'] : FALSE, - '#description' => t('MapTiler is using a custom getUrl method to get it\'s tiles'), - ), - ); - } - - function options_form_validate($form, &$form_state) { - } - - function options_form_submit($form, &$form_state) { - parent::options_form_submit($form, $form_state); - $form_state['values']['data']['url'] = explode("\n", $form_state['values']['data']['url']); - $form_state['values']['data']['resolutions'] = array_map('floatval', array_values($form_state['values']['data']['resolutions'])); - $form_state['values']['data']['wrapDateLine'] = (bool) $form_state['values']['data']['wrapDateLine']; - $form_state['values']['data']['zoomOffset'] = intval($form_state['values']['data']['zoomOffset'], 10); - $form_state['values']['data']['maptiler'] = (bool) $form_state['values']['data']['maptiler']; - } - - /** - * Render. - */ - function render(&$map) { - drupal_add_js(drupal_get_path('module', 'openlayers') . - '/plugins/layer_types/openlayers_layer_type_tms.js'); - } -} diff --git a/plugins/layer_types/openlayers_layer_type_tms.js b/plugins/layer_types/openlayers_layer_type_tms.js deleted file mode 100644 index 09de056d8a5cfcf2aa214fd2077a26b5d27c20ba..0000000000000000000000000000000000000000 --- a/plugins/layer_types/openlayers_layer_type_tms.js +++ /dev/null @@ -1,31 +0,0 @@ - -/** - * @file - * Layer handler for TMS layers - */ - -/** - * Openlayer layer handler for TMS layer - */ -Drupal.openlayers.layer.tms = function(title, map, options) { - if (OpenLayers.Util.isArray(options.maxExtent)) { - options.maxExtent = OpenLayers.Bounds.fromArray(options.maxExtent); - } - - if (options.maptiler == true) { - options.getURL = function(bounds) { - var res = this.map.getResolution(); - var x = Math.round((bounds.left - this.maxExtent.left) / (res * this.tileSize.w)); - var y = Math.round((bounds.bottom - this.tileOrigin.lat) / (res * this.tileSize.h)); - var z = this.map.getZoom(); - if (x >= 0 && y >= 0) { - return this.url + z + "/" + x + "/" + y + "." + this.type; - } else { - return "http://www.maptiler.org/img/none.png"; - } - } - } - - options.projection = new OpenLayers.Projection(options.projection); - return new OpenLayers.Layer.TMS(title, options.url, options); -}; diff --git a/plugins/layer_types/openlayers_layer_type_wms.inc b/plugins/layer_types/openlayers_layer_type_wms.inc deleted file mode 100644 index d556d906f811f16c49ef5f715931ee627a1ca7ac..0000000000000000000000000000000000000000 --- a/plugins/layer_types/openlayers_layer_type_wms.inc +++ /dev/null @@ -1,129 +0,0 @@ - 'wms', - ) + parent::options_init(); - - // Discard hard-codes resolution because the client can calculate them usually - unset($options['serverResolutions']); - unset($options['maxExtent']); - unset($options['resolutions']); - - return $options; - } - - /** - * Options form which generates layers - */ - function options_form($defaults = array()) { - return array( - 'base_url' => array( - '#type' => 'textfield', - '#title' => t('Base URL'), - '#maxlength' => 2083, - '#default_value' => isset($this->data['base_url']) ? - $this->data['base_url'] : '' - ), - - // TODO: swap terms - 'params' => array( - // TODO: validate the field, only positive integers shall be allowed - 'buffer' => array( - '#type' => 'textfield', - '#default_value' => isset($this->data['params']['buffer']) ? - $this->data['params']['buffer'] : 2, - '#title' => t('Buffer'), - '#description' => t('Used only when not in single-tile mode, this specifies umber of extra rows and colums of tiles on each side which will surround the minimum grid tiles to cover the map') - ), - // TODO: validate the field, only positive numbers shall be allowed - // numbers below 1 might also not make much sense - 'ratio' => array( - '#type' => 'textfield', - '#default_value' => isset($this->data['params']['ratio']) ? - $this->data['params']['ratio'] : 1.5, - '#title' => t('Ratio'), - '#description' => t('Used only when in single-tile mode, this specifies the ratio of the size of the single tile to the size of the map') - ), - 'singleTile' => array( - '#type' => 'checkbox', - '#default_value' => isset($this->data['params']['singleTile']) ? - $this->data['params']['singleTile'] : FALSE, - '#title' => t('Single tile'), - '#description' => t('Check to make this layer untiled') - ) - ), - 'options' => array( - 'TRANSPARENT' => array( - '#type' => 'checkbox', - '#default_value' => isset($this->data['options']['TRANSPARENT']) ? - $this->data['options']['TRANSPARENT'] : FALSE, - '#return_value' => 'true', - '#title' => t('Transparent'), - '#description' => t('When a PNG, make the background color transparent') - ), - 'exceptions' => array( - '#type' => 'select', - '#title' => t('Exceptions'), - '#options' => array( - 'application/vnd.ogc.se_xml' => 'application/vnd.ogc.se_xml', - 'application/vnd.ogc.se_inimage' => 'application/vnd.ogc.se_inimage'), - '#default_value' => isset($this->data['options']['exceptions']) ? - $this->data['options']['exceptions'] : 'application/vnd.ogc.se_inimage', - '#description' => t('Select the exception handler') - ), - 'format' => array( - '#type' => 'select', - '#title' => t('File Format'), - '#options' => array( - 'image/png' => 'image/png', - 'image/gif' => 'image/gif', - 'image/jpeg' => 'image/jpeg'), - '#default_value' => isset($this->data['options']['format']) ? - $this->data['options']['format'] : 'image/png' - ), - 'layers' => array( - '#type' => 'textarea', - '#title' => t('Layers'), - // TODO: Should be required to be non-empty as not having a layer leads to invalid requests - '#default_value' => !empty($this->data['options']['layers']) ? - implode("\r\n", $this->data['options']['layers']) : '', - '#description' => t('Specifies which layers to show. One per line.') - ), - 'styles' => array( - '#type' => 'textfield', - '#title' => t('Styles'), - '#default_value' => isset($this->data['options']['styles']) ? - $this->data['options']['styles'] : '' - ), - ), - ); - } - - /** - * hook_validate() - */ - function options_form_validate($form, &$form_state) { - $form_state['data']['options']['layers'] = explode("\r\n", $form_state['data']['options']['layers']); - } - - /** - * Render. - */ - function render(&$map) { - drupal_add_js(drupal_get_path('module', 'openlayers') . - '/plugins/layer_types/openlayers_layer_type_wms.js'); - } -} diff --git a/plugins/layer_types/openlayers_layer_type_wms.js b/plugins/layer_types/openlayers_layer_type_wms.js deleted file mode 100644 index 0ebc31b9de383e8019ef17637a5c681e7c6e1fa2..0000000000000000000000000000000000000000 --- a/plugins/layer_types/openlayers_layer_type_wms.js +++ /dev/null @@ -1,38 +0,0 @@ - -/** - * @file - * Layer handler for WMS layers - */ - -/** - * Openlayer layer handler for WMS layer - */ -Drupal.openlayers.layer.wms = function(title, map, options) { - /* TODO: have PHP take care of the casts here, not JS! */ - if (options.params.buffer) { - options.params.buffer = parseInt(options.params.buffer, 10); - } - if (options.params.ratio) { - options.params.ratio = parseFloat(options.params.ratio); - } - - options.params.drupalID = options.drupalID; - - // Set isBaseLayer explicitly so that OpenLayers does not guess from transparency - options.params.isBaseLayer = Boolean(options.isBaseLayer); - - // Convert to representation that match with WMS specification - var optionsClone = jQuery.extend(true, {}, options.options); - if(optionsClone.hasOwnProperty("TRANSPARENT") && optionsClone.TRANSPARENT===0){ - optionsClone.TRANSPARENT = "FALSE"; - } - if(optionsClone.hasOwnProperty("TRANSPARENT") && optionsClone.TRANSPARENT===1){ - optionsClone.TRANSPARENT = "FALSE"; - } - - var paramsClone = jQuery.extend(true, {}, options.params); - // OpenLayers can calculate the resolutions usually if provided with the number of zoom levels and tile sizes - paramsClone.numZoomLevels=18; - - return new OpenLayers.Layer.WMS(title, options.base_url, optionsClone, paramsClone); -}; diff --git a/plugins/layer_types/openlayers_layer_type_wmts.inc b/plugins/layer_types/openlayers_layer_type_wmts.inc deleted file mode 100644 index 64b03b06493279f88bdae2fab2776a48c3f52422..0000000000000000000000000000000000000000 --- a/plugins/layer_types/openlayers_layer_type_wmts.inc +++ /dev/null @@ -1,148 +0,0 @@ - 'wmts', - ) + parent::options_init(); - } - - /** - * Options form which generates layers - */ - function options_form($defaults = array()) { - return array( - 'url' => array( - '#type' => 'textarea', - '#title' => t('Base URL (template)'), - '#default_value' => !empty($this->data['url']) ? implode("\n", (array) $this->data['url']) : '', - '#maxlength' => 2083, - '#description' => t('The base URL or request URL template for the WMTS service. Must be provided.'), - ), - 'layer' => array( - '#type' => 'textfield', - '#title' => t('Layer Name'), - '#default_value' => isset($this->data['layer']) ? $this->data['layer'] : '', - '#description' => t('The layer identifier advertised by the WMTS service. Must be provided.'), - ), - 'style' => array( - '#type' => 'textfield', - '#title' => t('Style'), - '#default_value' => isset($this->data['style']) ? $this->data['style'] : '', - '#description' => t('One of the advertised layer styles.'), - ), - 'attribution' => array( - '#type' => 'textfield', - '#title' => t('Attribution'), - '#default_value' => isset($this->data['attribution']) ? $this->data['attribution'] : '', - '#description' => t('Attribution text, displayed when the attribution behavior has been added to the map.'), - ), - 'matrixSet' => array( - '#type' => 'textfield', - '#title' => t('Matrix Set'), - '#default_value' => isset($this->data['matrixSet']) ? $this->data['matrixSet'] : '', - '#description' => t('One of the advertised matrix set identifiers. Must be provided.'), - ), - 'matrixIdsAuto' => array( - '#type' => 'checkbox', - '#default_value' => isset($this->data['matrixIdsAuto']) ? - $this->data['matrixIdsAuto'] : TRUE, - '#title' => t('Auto-generate matrix identifiers.'), - '#description' => t('Generate identifiers in the format [matrixSet]:[zoomLevel]. Use this options for Geoserver WMTS tiles. Overwrites explicit matrix IDs specified above.'), - ), - 'matrixIds' => array( - '#type' => 'textfield', - '#title' => t('Matrix IDs'), - '#default_value' => isset($this->data['matrixIds']) ? implode(',', $this->data['matrixIds']) : '', - '#description' => t('Matrix identifiers per zoom level. Comma separated. Leave empty to use zoom level as identifier.'), - '#states' => array( - 'invisible' => array( - ':input[name*="matrixIdsAuto"]' => array('checked' => TRUE), - ), - ), - ), - 'format' => array( - '#type' => 'select', - '#title' => t('Tile format'), - '#options' => array( - 'image/png' => 'image/png', - 'image/gif' => 'image/gif', - 'image/jpeg' => 'image/jpeg' - ), - '#default_value' => isset($this->data['format']) ? $this->data['format'] : 'image/jpeg', - '#description' => t('The image MIME type. Default is "image/jpeg".'), - ), - 'formatSuffix' => array( - '#type' => 'textfield', - '#title' => t('Format Suffix'), - '#default_value' => isset($this->data['formatSuffix']) ? $this->data['formatSuffix'] : '', - '#description' => t('For REST request encoding, an image format suffix must be included in the request. If not provided, the suffix will be derived from the format property.'), - ), - 'maxExtent' => array( - '#type' => 'textfield', - '#title' => t('Max Extent'), - '#default_value' => isset($this->data['maxExtent']) ? implode(', ', $this->data['maxExtent']) : '', - '#description' => t('Should consist of four values (left, bottom, right, top). The maximum extent for the layer.'), - ), - 'resolutions' => array( - '#type' => 'textfield', - '#title' => t('Resolutions'), - '#default_value' => isset($this->data['resolutions']) ? $this->data['resolutions'] : '', - '#description' => t('A list of map resolutions (map units per pixel) in descending order.'), - '#maxlength' => 400 - ), - 'serverResolutions' => array( - '#type' => 'textfield', - '#title' => t('Server Resoultions'), - '#default_value' => isset($this->data['serverResolutions']) ? $this->data['serverResolutions'] : '', - '#description' => t('A list of all resolutions available on the server. Only set this property if the map resolutions differ from the server.'), - '#maxlength' => 400 - ), - 'requestEncoding' => array( - '#type' => 'select', - '#title' => t('Request encoding'), - '#options' => array('KVP' => 'KVP', 'REST' => 'REST'), - '#default_value' => isset($this->data['requestEncoding']) ? $this->data['requestEncoding'] : '', - ), - ); - } - - function options_form_validate($form, &$form_state) { - //parent::options_form_validate($form, $form_state); - $form_state['data']['resolutions'] = array_map('floatval', explode(' ', $form_state['data']['resolutions'])); - $form_state['data']['serverResolutions'] = array_map('floatval', explode(' ', $form_state['data']['serverResolutions'])); - if (empty($form_state['data']['matrixIds'])) { - $form_state['data']['matrixIds'] = NULL; - } else { - $form_state['data']['matrixIds'] = array_map('trim', explode(',', $form_state['data']['matrixIds'])); - } - $form_state['data']['url'] = explode("\n", $form_state['data']['url']); - $form_state['data']['maxExtent'] = array_map('floatval', explode(",", $form_state['data']['maxExtent'])); - if (empty($form_state['data']['formatSuffix'])) { - $form_state['data']['formatSuffix'] = NULL; - } - } - - function options_form_submit($form, &$form_state) { - //parent::options_form_submit($form, $form_state); - } - - /** - * Render. - */ - function render(&$map) { - drupal_add_js(drupal_get_path('module', 'openlayers') . - '/plugins/layer_types/openlayers_layer_type_wmts.js'); - } -} diff --git a/plugins/layer_types/openlayers_layer_type_wmts.js b/plugins/layer_types/openlayers_layer_type_wmts.js deleted file mode 100644 index 687f26940f71c03da9a1ddaeac9cb1f856a99860..0000000000000000000000000000000000000000 --- a/plugins/layer_types/openlayers_layer_type_wmts.js +++ /dev/null @@ -1,48 +0,0 @@ - -/** - * @file - * Layer handler for WMTS layers - */ - -/** - * Openlayer layer handler for WMTS layer - */ -Drupal.openlayers.layer.wmts = function(title, map, options) { - - var layer_options = { - drupalID: options.drupalID, - name: title, - attribution: options.attribution, - layer: options.layer, - requestEncoding: options.requestEncoding, - url: options.url, - style: options.style, - matrixSet: options.matrixSet, - format: options.format, - formatSuffix: options.formatSuffix, - isBaseLayer: options.isBaseLayer - }; - - if (options.matrixIdsAuto) { - layer_options.matrixIds = new Array(26); - for (var i=0; i<26; ++i) { - layer_options.matrixIds[i] = options.matrixSet + ":" + i; - } - } else if (options.matrixIds) { - layer_options.matrixIds = options.matrixIds; - } - - if (OpenLayers.Util.isArray(options.maxExtent)) { - layer_options.maxExtent = OpenLayers.Bounds.fromArray(options.maxExtent); - } - - if (options.resolutions) { - layer_options.resolutions = jQuery.parseJSON('['+options.resolutions+']'); - } - - if (options.serverResolutions) { - layer_options.serverResolutions = jQuery.parseJSON('['+options.serverResolutions+']'); - } - - return new OpenLayers.Layer.WMTS(layer_options); -}; diff --git a/plugins/layer_types/openlayers_layer_type_xyz.inc b/plugins/layer_types/openlayers_layer_type_xyz.inc deleted file mode 100644 index d084ee86c970a62f117295724f9e9b17a483524c..0000000000000000000000000000000000000000 --- a/plugins/layer_types/openlayers_layer_type_xyz.inc +++ /dev/null @@ -1,93 +0,0 @@ - 'xyz', - 'sphericalMercator' => TRUE, - 'wrapDateLine' => FALSE, - 'zoomOffset' => 0, - 'resolutions' => array_slice(openlayers_get_resolutions('EPSG:900913'), 0, 18) - ) + parent::options_init(); - } - - /** - * Options form which generates layers - */ - function options_form($defaults = array()) { - return array( - 'url' => array( - '#type' => 'textarea', - '#title' => t('Base URL (template)'), - '#default_value' => !empty($this->data['url']) ? implode("\n", (array) $this->data['url']) : '', - '#maxlength' => 2083, - '#description' => t('This is the base URL template for the XYZ layer. It should be something similar to http://example.com/tiles/1.0.0/layer_name/${z}/${x}/${y}.png.'), - ), - 'serverResolutions' => array( - '#type' => 'select', - '#multiple' => TRUE, - '#description' => t('Only set this if you need to request very specific resolutions from the server.'), - '#options' => array_combine( - array_map('strval', openlayers_get_resolutions('EPSG:900913')), - range(0, 21)), - '#title' => t('Server Zoom Level Range'), - '#default_value' => isset($this->data['serverResolutions']) ? - array_map('strval', $this->data['serverResolutions']) : array(), - ), - 'resolutions' => array( - '#type' => 'select', - '#multiple' => TRUE, - '#description' => t('Only set this if you need a very specific resolution.'), - '#options' => array_combine( - array_map('strval', openlayers_get_resolutions('EPSG:900913')), - range(0, 21)), - '#title' => t('Zoom Level Range'), - '#default_value' => isset($this->data['resolutions']) ? - array_map('strval', $this->data['resolutions']) : array(), - ), - 'zoomOffset' => array( - '#type' => 'select', - '#description' => t('Zoom offset.'), - '#options' => array_combine( - range(0, 21), - range(0, 21)), - '#title' => t('Zoom offset'), - '#default_value' => isset($this->data['zoomOffset']) ? - $this->data['zoomOffset'] : array(), - ), - 'wrapDateLine' => array( - '#type' => 'checkbox', - '#title' => t('Wrap Date Line'), - '#default_value' => isset($this->data['wrapDateLine']) ? $this->data['wrapDateLine'] : FALSE, - '#description' => t('This allows the user to continually pan left and right as the tiles will repeat themselves. Note that this option is known to not work well with the 2.10 OL library.'), - ), - ); - } - - function options_form_validate($form, &$form_state) { - $form_state['data']['url'] = explode("\n", $form_state['data']['url']); - $form_state['data']['serverResolutions'] = array_map('floatval', array_values($form_state['data']['serverResolutions'])); - $form_state['data']['resolutions'] = array_map('floatval', array_values($form_state['data']['resolutions'])); - $form_state['data']['zoomOffset'] = (int) $form_state['data']['zoomOffset']; - } - - function attached() { - return array( - 'js' => array( - drupal_get_path('module', 'openlayers') . '/plugins/layer_types/openlayers_layer_type_xyz.js' - ) - ); - } -} diff --git a/plugins/layer_types/openlayers_layer_type_xyz.js b/plugins/layer_types/openlayers_layer_type_xyz.js deleted file mode 100644 index 5b430ff14e55f92b21ff692d9df4c1f220a3c104..0000000000000000000000000000000000000000 --- a/plugins/layer_types/openlayers_layer_type_xyz.js +++ /dev/null @@ -1,35 +0,0 @@ - -/** - * @file - * Layer handler for XYZ layers - */ - -/** - * Openlayer layer handler for XYZ layer - */ -Drupal.openlayers.layer.xyz = function(title, map, options) { - if (OpenLayers.Util.isArray(options.maxExtent)) { - options.maxExtent = OpenLayers.Bounds.fromArray(options.maxExtent); - } - - // Legacy goodnes - if (typeof options.base_url == 'string' && typeof options.url == 'undefined') { - options.url = options.base_url; - } - - // Server resolutions are very particular in OL 2.11 - var r = options.serverResolutions; - if (r == null || typeof r == 'undefined' || r.length == 0) { - options.serverResolutions = null; - } - - // Wrap Date Line does not seem to work for 2.10. This may - // have something to do with our extent definitions. - if (OpenLayers.VERSION_NUMBER.indexOf('2.10') >= 0) { - options.wrapDateLine = null; - } - - options.projection = new OpenLayers.Projection(options.projection); - - return new OpenLayers.Layer.XYZ(title, options.url, options); -}; diff --git a/plugins/openlayers/control/openlayers_control_attribution.inc b/plugins/openlayers/control/openlayers_control_attribution.inc new file mode 100644 index 0000000000000000000000000000000000000000..4c3d29ddf5e022979b3a5aec6bd60def5ca46464 --- /dev/null +++ b/plugins/openlayers/control/openlayers_control_attribution.inc @@ -0,0 +1,24 @@ + array( + 'class' => 'openlayers_control_attribution', + ) + ); +} + +class openlayers_control_attribution extends openlayers_control { + + function options_form() { + return array( + 'collapsible' => array( + '#type' => 'checkbox', + '#title' => t('Collapsible'), + '#default_value' => $this->getOption('collapsible'), + '#description' => t(''), + ), + ); + } + +} diff --git a/plugins/openlayers/control/openlayers_control_attribution.js b/plugins/openlayers/control/openlayers_control_attribution.js new file mode 100644 index 0000000000000000000000000000000000000000..cab0e7d92d5eab5308d75b67190c11bc107ab3fa --- /dev/null +++ b/plugins/openlayers/control/openlayers_control_attribution.js @@ -0,0 +1,3 @@ +Drupal.openlayers.openlayers_control_attribution = function(options) { + return new ol.control.Attribution(options); +} diff --git a/plugins/openlayers/control/openlayers_control_defaults.inc b/plugins/openlayers/control/openlayers_control_defaults.inc new file mode 100644 index 0000000000000000000000000000000000000000..3453886c1854aee125acddced3e3f89e40b35c12 --- /dev/null +++ b/plugins/openlayers/control/openlayers_control_defaults.inc @@ -0,0 +1,14 @@ + array( + 'class' => 'openlayers_control_defaults', + ) + ); +} + +class openlayers_control_defaults extends openlayers_control { + + +} diff --git a/plugins/openlayers/control/openlayers_control_defaults.js b/plugins/openlayers/control/openlayers_control_defaults.js new file mode 100644 index 0000000000000000000000000000000000000000..7fb88c0b144f0aecf90425a77f1cfc1ad36335a9 --- /dev/null +++ b/plugins/openlayers/control/openlayers_control_defaults.js @@ -0,0 +1,3 @@ +Drupal.openlayers.openlayers_control_defaults = function(options) { + return new ol.control.defaults(); +} diff --git a/plugins/openlayers/control/openlayers_control_fullscreen.inc b/plugins/openlayers/control/openlayers_control_fullscreen.inc new file mode 100644 index 0000000000000000000000000000000000000000..1d24aaf46f0c29eeef42bf09f6e67adc9dcdfcac --- /dev/null +++ b/plugins/openlayers/control/openlayers_control_fullscreen.inc @@ -0,0 +1,14 @@ + array( + 'class' => 'openlayers_control_fullscreen', + ) + ); +} + +class openlayers_control_fullscreen extends openlayers_control { + + +} diff --git a/plugins/openlayers/control/openlayers_control_fullscreen.js b/plugins/openlayers/control/openlayers_control_fullscreen.js new file mode 100644 index 0000000000000000000000000000000000000000..2b1e38ea0972f6b19ed60055c0c85b0bab4acc05 --- /dev/null +++ b/plugins/openlayers/control/openlayers_control_fullscreen.js @@ -0,0 +1,3 @@ +Drupal.openlayers.openlayers_control_fullscreen = function(options) { + return new ol.control.FullScreen(options); +} diff --git a/plugins/openlayers/control/openlayers_control_mouseposition.inc b/plugins/openlayers/control/openlayers_control_mouseposition.inc new file mode 100644 index 0000000000000000000000000000000000000000..1e142a95ee8d464d077dab8ae24542feb54ada30 --- /dev/null +++ b/plugins/openlayers/control/openlayers_control_mouseposition.inc @@ -0,0 +1,30 @@ + array( + 'class' => 'openlayers_control_mouseposition', + ) + ); +} + +class openlayers_control_mouseposition extends openlayers_control { + + function options_form() { + return array( + 'target' => array( + '#type' => 'textfield', + '#title' => t('ID of the element.'), + '#default_value' => $this->getOption('target'), + '#description' => t(''), + ), + 'undefinedHTML' => array( + '#type' => 'textfield', + '#title' => t('undefinedHTML'), + '#default_value' => $this->getOption('undefinedHTML'), + '#description' => t('Markup for undefined coordinates. Default is an empty string.'), + ), + ); + } + +} diff --git a/plugins/openlayers/control/openlayers_control_mouseposition.js b/plugins/openlayers/control/openlayers_control_mouseposition.js new file mode 100644 index 0000000000000000000000000000000000000000..1f97b6c1ea75b598eb850359f1e0052158564afc --- /dev/null +++ b/plugins/openlayers/control/openlayers_control_mouseposition.js @@ -0,0 +1,5 @@ +Drupal.openlayers.openlayers_control_mouseposition = function(options) { + options.coordinateFormat = ol.coordinate.createStringXY(4); + //options.projection = 'EPSG:4326'; + return new ol.control.MousePosition(options); +} diff --git a/plugins/openlayers/control/openlayers_control_rotate.inc b/plugins/openlayers/control/openlayers_control_rotate.inc new file mode 100644 index 0000000000000000000000000000000000000000..4b52c25254535c9b23bc8d4aba22b192c6f2d67e --- /dev/null +++ b/plugins/openlayers/control/openlayers_control_rotate.inc @@ -0,0 +1,14 @@ + array( + 'class' => 'openlayers_control_rotate', + ) + ); +} + +class openlayers_control_rotate extends openlayers_control { + + +} diff --git a/plugins/openlayers/control/openlayers_control_rotate.js b/plugins/openlayers/control/openlayers_control_rotate.js new file mode 100644 index 0000000000000000000000000000000000000000..3036d1c170debfe3d415f6e95a4e2b1053a32e67 --- /dev/null +++ b/plugins/openlayers/control/openlayers_control_rotate.js @@ -0,0 +1,3 @@ +Drupal.openlayers.openlayers_control_rotate = function(map, options) { + return new ol.control.Rotate(options); +} diff --git a/plugins/openlayers/control/openlayers_control_scaleline.inc b/plugins/openlayers/control/openlayers_control_scaleline.inc new file mode 100644 index 0000000000000000000000000000000000000000..9e8880a45feaaf2f99b7aad0c9ed831210fc725a --- /dev/null +++ b/plugins/openlayers/control/openlayers_control_scaleline.inc @@ -0,0 +1,14 @@ + array( + 'class' => 'openlayers_control_scaleline', + ) + ); +} + +class openlayers_control_scaleline extends openlayers_control { + + +} diff --git a/plugins/openlayers/control/openlayers_control_scaleline.js b/plugins/openlayers/control/openlayers_control_scaleline.js new file mode 100644 index 0000000000000000000000000000000000000000..3d7f2f782050ee4cf330fd51a981c16f1917d9c3 --- /dev/null +++ b/plugins/openlayers/control/openlayers_control_scaleline.js @@ -0,0 +1,3 @@ +Drupal.openlayers.openlayers_control_scaleline = function(map, options) { + return new ol.control.ScaleLine(options); +} diff --git a/plugins/openlayers/control/openlayers_control_zoom.inc b/plugins/openlayers/control/openlayers_control_zoom.inc new file mode 100644 index 0000000000000000000000000000000000000000..dd903108f47160307ca74c77e03638b977c36bbe --- /dev/null +++ b/plugins/openlayers/control/openlayers_control_zoom.inc @@ -0,0 +1,14 @@ + array( + 'class' => 'openlayers_control_zoom', + ) + ); +} + +class openlayers_control_zoom extends openlayers_control { + + +} diff --git a/plugins/openlayers/control/openlayers_control_zoom.js b/plugins/openlayers/control/openlayers_control_zoom.js new file mode 100644 index 0000000000000000000000000000000000000000..f56b5f9872fe296a5f98034a9b40a22375ed8e72 --- /dev/null +++ b/plugins/openlayers/control/openlayers_control_zoom.js @@ -0,0 +1,3 @@ +Drupal.openlayers.openlayers_control_zoom = function(map, options) { + return new ol.control.Zoom(options); +} diff --git a/plugins/openlayers/control/openlayers_control_zoomslider.inc b/plugins/openlayers/control/openlayers_control_zoomslider.inc new file mode 100644 index 0000000000000000000000000000000000000000..605b10da04de235572fc42ccb6662d3901cc5405 --- /dev/null +++ b/plugins/openlayers/control/openlayers_control_zoomslider.inc @@ -0,0 +1,14 @@ + array( + 'class' => 'openlayers_control_zoomslider', + ) + ); +} + +class openlayers_control_zoomslider extends openlayers_control { + + +} diff --git a/plugins/openlayers/control/openlayers_control_zoomslider.js b/plugins/openlayers/control/openlayers_control_zoomslider.js new file mode 100644 index 0000000000000000000000000000000000000000..12f39dff529c745e8d5a91e396c88edbf26dc331 --- /dev/null +++ b/plugins/openlayers/control/openlayers_control_zoomslider.js @@ -0,0 +1,3 @@ +Drupal.openlayers.openlayers_control_zoomslider = function(options) { + return new ol.control.ZoomSlider(options); +} diff --git a/plugins/openlayers/control/openlayers_control_zoomtoextent.inc b/plugins/openlayers/control/openlayers_control_zoomtoextent.inc new file mode 100644 index 0000000000000000000000000000000000000000..641ad11185f11ad5eb0425bbd28e2c2dbdc9e0e8 --- /dev/null +++ b/plugins/openlayers/control/openlayers_control_zoomtoextent.inc @@ -0,0 +1,14 @@ + array( + 'class' => 'openlayers_control_zoomtoextent', + ) + ); +} + +class openlayers_control_zoomtoextent extends openlayers_control { + + +} diff --git a/plugins/openlayers/control/openlayers_control_zoomtoextent.js b/plugins/openlayers/control/openlayers_control_zoomtoextent.js new file mode 100644 index 0000000000000000000000000000000000000000..3c801dc3b26a06c7cbb23cb0223e30443223cdd6 --- /dev/null +++ b/plugins/openlayers/control/openlayers_control_zoomtoextent.js @@ -0,0 +1,3 @@ +Drupal.openlayers.openlayers_control_zoomtoextent = function(options) { + return new ol.control.ZoomToExtent(options); +} diff --git a/plugins/openlayers/interaction/openlayers_interaction_doubleclickzoom.inc b/plugins/openlayers/interaction/openlayers_interaction_doubleclickzoom.inc new file mode 100644 index 0000000000000000000000000000000000000000..0c4a538aaca73720a6713a3b4a11e4b915578d0b --- /dev/null +++ b/plugins/openlayers/interaction/openlayers_interaction_doubleclickzoom.inc @@ -0,0 +1,13 @@ + array( + 'class' => 'openlayers_interaction_doubleclickzoom', + ) + ); +} + +class openlayers_interaction_doubleclickzoom extends openlayers_interaction { + +} diff --git a/plugins/openlayers/interaction/openlayers_interaction_doubleclickzoom.js b/plugins/openlayers/interaction/openlayers_interaction_doubleclickzoom.js new file mode 100644 index 0000000000000000000000000000000000000000..977e4f0c9848134b0c7c095840fbb2f308e55cea --- /dev/null +++ b/plugins/openlayers/interaction/openlayers_interaction_doubleclickzoom.js @@ -0,0 +1,3 @@ +Drupal.openlayers.openlayers_interaction_doubleclickzoom = function(options) { + return new ol.interaction.DoubleClickZoom(options); +}; diff --git a/plugins/openlayers/interaction/openlayers_interaction_draganddrop.inc b/plugins/openlayers/interaction/openlayers_interaction_draganddrop.inc new file mode 100644 index 0000000000000000000000000000000000000000..6737c95c11d3eb983ef7d136b97e1352aa7467fb --- /dev/null +++ b/plugins/openlayers/interaction/openlayers_interaction_draganddrop.inc @@ -0,0 +1,13 @@ + array( + 'class' => 'openlayers_interaction_draganddrop', + ) + ); +} + +class openlayers_interaction_draganddrop extends openlayers_interaction { + +} diff --git a/plugins/openlayers/interaction/openlayers_interaction_draganddrop.js b/plugins/openlayers/interaction/openlayers_interaction_draganddrop.js new file mode 100644 index 0000000000000000000000000000000000000000..f9daad762f4f7f6f850cf35a5ec668f0f054048b --- /dev/null +++ b/plugins/openlayers/interaction/openlayers_interaction_draganddrop.js @@ -0,0 +1,3 @@ +Drupal.openlayers.openlayers_interaction_draganddrop = function(options) { + return new ol.interaction.DragAndDrop(options); +}; diff --git a/plugins/openlayers/interaction/openlayers_interaction_dragbox.inc b/plugins/openlayers/interaction/openlayers_interaction_dragbox.inc new file mode 100644 index 0000000000000000000000000000000000000000..162fb9cf472fc0c48f2e598d9beb7f4668b982c7 --- /dev/null +++ b/plugins/openlayers/interaction/openlayers_interaction_dragbox.inc @@ -0,0 +1,13 @@ + array( + 'class' => 'openlayers_interaction_dragbox', + ) + ); +} + +class openlayers_interaction_dragbox extends openlayers_interaction { + +} diff --git a/plugins/openlayers/interaction/openlayers_interaction_dragbox.js b/plugins/openlayers/interaction/openlayers_interaction_dragbox.js new file mode 100644 index 0000000000000000000000000000000000000000..8909f630c47f960105b856cf490f265c89b52fb7 --- /dev/null +++ b/plugins/openlayers/interaction/openlayers_interaction_dragbox.js @@ -0,0 +1,3 @@ +Drupal.openlayers.openlayers_interaction_dragbox = function(options) { + return new ol.interaction.DragBox(options); +}; diff --git a/plugins/openlayers/interaction/openlayers_interaction_dragpan.inc b/plugins/openlayers/interaction/openlayers_interaction_dragpan.inc new file mode 100644 index 0000000000000000000000000000000000000000..329ff22bdaded4e920187e6f142f501a32fbaa9c --- /dev/null +++ b/plugins/openlayers/interaction/openlayers_interaction_dragpan.inc @@ -0,0 +1,13 @@ + array( + 'class' => 'openlayers_interaction_dragpan', + ) + ); +} + +class openlayers_interaction_dragpan extends openlayers_interaction { + +} diff --git a/plugins/openlayers/interaction/openlayers_interaction_dragpan.js b/plugins/openlayers/interaction/openlayers_interaction_dragpan.js new file mode 100644 index 0000000000000000000000000000000000000000..2f87265e2ca4c57c38e199e3bbe71fb44d19d91d --- /dev/null +++ b/plugins/openlayers/interaction/openlayers_interaction_dragpan.js @@ -0,0 +1,3 @@ +Drupal.openlayers.openlayers_interaction_dragpan = function(options) { + return new ol.interaction.DragPan({kinetic: new ol.Kinetic(-0.005, 0.05, 100)}); +}; diff --git a/plugins/openlayers/interaction/openlayers_interaction_dragrotate.inc b/plugins/openlayers/interaction/openlayers_interaction_dragrotate.inc new file mode 100644 index 0000000000000000000000000000000000000000..44ac33b76d77829f7339fd07b6da4e939777ddd1 --- /dev/null +++ b/plugins/openlayers/interaction/openlayers_interaction_dragrotate.inc @@ -0,0 +1,13 @@ + array( + 'class' => 'openlayers_interaction_dragrotate', + ) + ); +} + +class openlayers_interaction_dragrotate extends openlayers_interaction { + +} diff --git a/plugins/openlayers/interaction/openlayers_interaction_dragrotate.js b/plugins/openlayers/interaction/openlayers_interaction_dragrotate.js new file mode 100644 index 0000000000000000000000000000000000000000..520a658ae542f05c5d6e943e9509d89f2d565638 --- /dev/null +++ b/plugins/openlayers/interaction/openlayers_interaction_dragrotate.js @@ -0,0 +1,3 @@ +Drupal.openlayers.openlayers_interaction_dragrotate = function(options) { + return new ol.interaction.DragRotate(options); +}; diff --git a/plugins/openlayers/interaction/openlayers_interaction_dragrotateandzoom.inc b/plugins/openlayers/interaction/openlayers_interaction_dragrotateandzoom.inc new file mode 100644 index 0000000000000000000000000000000000000000..13f26e0de2f58e5884bed3ed394fc0044d531195 --- /dev/null +++ b/plugins/openlayers/interaction/openlayers_interaction_dragrotateandzoom.inc @@ -0,0 +1,13 @@ + array( + 'class' => 'openlayers_interaction_dragrotateandzoom', + ) + ); +} + +class openlayers_interaction_dragrotateandzoom extends openlayers_interaction { + +} diff --git a/plugins/openlayers/interaction/openlayers_interaction_dragrotateandzoom.js b/plugins/openlayers/interaction/openlayers_interaction_dragrotateandzoom.js new file mode 100644 index 0000000000000000000000000000000000000000..cb66df723a495b1c06dd228f31950251c300cfb0 --- /dev/null +++ b/plugins/openlayers/interaction/openlayers_interaction_dragrotateandzoom.js @@ -0,0 +1,3 @@ +Drupal.openlayers.openlayers_interaction_dragrotateandzoom = function(options) { + return new ol.interaction.DragRotateAndZoom(options); +}; diff --git a/plugins/openlayers/interaction/openlayers_interaction_dragzoom.inc b/plugins/openlayers/interaction/openlayers_interaction_dragzoom.inc new file mode 100644 index 0000000000000000000000000000000000000000..38b8e5bdcf135af073bd2498c67a607df56b97f5 --- /dev/null +++ b/plugins/openlayers/interaction/openlayers_interaction_dragzoom.inc @@ -0,0 +1,13 @@ + array( + 'class' => 'openlayers_interaction_dragzoom', + ) + ); +} + +class openlayers_interaction_dragzoom extends openlayers_interaction { + +} diff --git a/plugins/openlayers/interaction/openlayers_interaction_dragzoom.js b/plugins/openlayers/interaction/openlayers_interaction_dragzoom.js new file mode 100644 index 0000000000000000000000000000000000000000..8dfda6a7a3d82a7c886d959dab2904dafe42012b --- /dev/null +++ b/plugins/openlayers/interaction/openlayers_interaction_dragzoom.js @@ -0,0 +1,3 @@ +Drupal.openlayers.openlayers_interaction_dragzoom = function(options) { + return new ol.interaction.DragZoom(options); +}; diff --git a/plugins/openlayers/interaction/openlayers_interaction_draw.inc b/plugins/openlayers/interaction/openlayers_interaction_draw.inc new file mode 100644 index 0000000000000000000000000000000000000000..2a49fc951b013ad72165ca220b621c53d343d47f --- /dev/null +++ b/plugins/openlayers/interaction/openlayers_interaction_draw.inc @@ -0,0 +1,13 @@ + array( + 'class' => 'openlayers_interaction_draw', + ) + ); +} + +class openlayers_interaction_draw extends openlayers_interaction { + +} diff --git a/plugins/openlayers/interaction/openlayers_interaction_draw.js b/plugins/openlayers/interaction/openlayers_interaction_draw.js new file mode 100644 index 0000000000000000000000000000000000000000..2e2820c733b47606b24e9429fd7c712f388f62f8 --- /dev/null +++ b/plugins/openlayers/interaction/openlayers_interaction_draw.js @@ -0,0 +1,31 @@ +Drupal.openlayers.openlayers_interaction_draw = function(options, map) { + + var featureOverlay = new ol.FeatureOverlay({ + style: new ol.style.Style({ + fill: new ol.style.Fill({ + color: 'rgba(255, 255, 255, 0.2)' + }), + stroke: new ol.style.Stroke({ + color: '#ffcc33', + width: 2 + }), + image: new ol.style.Circle({ + radius: 7, + fill: new ol.style.Fill({ + color: '#ffcc33' + }) + }) + }) + }); + featureOverlay.setMap(map); + + options.features = featureOverlay.getFeatures(); + options.type = 'Point'; + + map.on('moveend', function(evt){ + var WKT = new ol.format.WKT(); + console.log(WKT.writeFeatures(featureOverlay.getFeatures())); + }); + + return new ol.interaction.Draw(options); +}; diff --git a/plugins/openlayers/interaction/openlayers_interaction_keyboardpan.inc b/plugins/openlayers/interaction/openlayers_interaction_keyboardpan.inc new file mode 100644 index 0000000000000000000000000000000000000000..e0a8a8ece021ba1034f20ed5b537c1df3a1878ce --- /dev/null +++ b/plugins/openlayers/interaction/openlayers_interaction_keyboardpan.inc @@ -0,0 +1,13 @@ + array( + 'class' => 'openlayers_interaction_keyboardpan', + ) + ); +} + +class openlayers_interaction_keyboardpan extends openlayers_interaction { + +} diff --git a/plugins/openlayers/interaction/openlayers_interaction_keyboardpan.js b/plugins/openlayers/interaction/openlayers_interaction_keyboardpan.js new file mode 100644 index 0000000000000000000000000000000000000000..e248dd79cc1ae25234aa5782a17ef9db4f026871 --- /dev/null +++ b/plugins/openlayers/interaction/openlayers_interaction_keyboardpan.js @@ -0,0 +1,3 @@ +Drupal.openlayers.openlayers_interaction_keyboardpan = function(options) { + return new ol.interaction.KeyboardPan(options); +}; diff --git a/plugins/openlayers/interaction/openlayers_interaction_keyboardzoom.inc b/plugins/openlayers/interaction/openlayers_interaction_keyboardzoom.inc new file mode 100644 index 0000000000000000000000000000000000000000..2d6bd40134e879f8e99edfdb79d3721c9cdef288 --- /dev/null +++ b/plugins/openlayers/interaction/openlayers_interaction_keyboardzoom.inc @@ -0,0 +1,13 @@ + array( + 'class' => 'openlayers_interaction_keyboardzoom', + ) + ); +} + +class openlayers_interaction_keyboardzoom extends openlayers_interaction { + +} diff --git a/plugins/openlayers/interaction/openlayers_interaction_keyboardzoom.js b/plugins/openlayers/interaction/openlayers_interaction_keyboardzoom.js new file mode 100644 index 0000000000000000000000000000000000000000..e9bbf735f5f888b0e099e43963a991a53141b549 --- /dev/null +++ b/plugins/openlayers/interaction/openlayers_interaction_keyboardzoom.js @@ -0,0 +1,3 @@ +Drupal.openlayers.openlayers_interaction_keyboardzoom = function(options) { + return new ol.interaction.KeyboardZoom(options); +}; diff --git a/plugins/openlayers/interaction/openlayers_interaction_modify.inc b/plugins/openlayers/interaction/openlayers_interaction_modify.inc new file mode 100644 index 0000000000000000000000000000000000000000..3b467d5ddd386163b13a81622129430ba1d792e7 --- /dev/null +++ b/plugins/openlayers/interaction/openlayers_interaction_modify.inc @@ -0,0 +1,13 @@ + array( + 'class' => 'openlayers_interaction_modify', + ) + ); +} + +class openlayers_interaction_modify extends openlayers_interaction { + +} diff --git a/plugins/openlayers/interaction/openlayers_interaction_modify.js b/plugins/openlayers/interaction/openlayers_interaction_modify.js new file mode 100644 index 0000000000000000000000000000000000000000..97459da60cd3322ab735da28c01856b529b2ef44 --- /dev/null +++ b/plugins/openlayers/interaction/openlayers_interaction_modify.js @@ -0,0 +1,3 @@ +Drupal.openlayers.openlayers_interaction_modify = function(options) { + return new ol.interaction.Modify(options); +}; diff --git a/plugins/openlayers/interaction/openlayers_interaction_mousewheelzoom.inc b/plugins/openlayers/interaction/openlayers_interaction_mousewheelzoom.inc new file mode 100644 index 0000000000000000000000000000000000000000..afdd90b35da6a9aa6a061f841691aac17da357a8 --- /dev/null +++ b/plugins/openlayers/interaction/openlayers_interaction_mousewheelzoom.inc @@ -0,0 +1,13 @@ + array( + 'class' => 'openlayers_interaction_mousewheelzoom', + ) + ); +} + +class openlayers_interaction_mousewheelzoom extends openlayers_interaction { + +} diff --git a/plugins/openlayers/interaction/openlayers_interaction_mousewheelzoom.js b/plugins/openlayers/interaction/openlayers_interaction_mousewheelzoom.js new file mode 100644 index 0000000000000000000000000000000000000000..002655a8d6e35cbe8c80a7f35e50856bf2b2493a --- /dev/null +++ b/plugins/openlayers/interaction/openlayers_interaction_mousewheelzoom.js @@ -0,0 +1,3 @@ +Drupal.openlayers.openlayers_interaction_mousewheelzoom = function(options) { + return new ol.interaction.MouseWheelZoom(options); +}; diff --git a/plugins/openlayers/interaction/openlayers_interaction_pinchrotate.inc b/plugins/openlayers/interaction/openlayers_interaction_pinchrotate.inc new file mode 100644 index 0000000000000000000000000000000000000000..75cb8a5fdc59093b0045c5c6fdd2888b070c4428 --- /dev/null +++ b/plugins/openlayers/interaction/openlayers_interaction_pinchrotate.inc @@ -0,0 +1,13 @@ + array( + 'class' => 'openlayers_interaction_pinchrotate', + ) + ); +} + +class openlayers_interaction_pinchrotate extends openlayers_interaction { + +} diff --git a/plugins/openlayers/interaction/openlayers_interaction_pinchrotate.js b/plugins/openlayers/interaction/openlayers_interaction_pinchrotate.js new file mode 100644 index 0000000000000000000000000000000000000000..eba0be151ab270c55d70f4fa1a00b5156d647dce --- /dev/null +++ b/plugins/openlayers/interaction/openlayers_interaction_pinchrotate.js @@ -0,0 +1,3 @@ +Drupal.openlayers.openlayers_interaction_pinchrotate = function(options) { + return new ol.interaction.PinchRotate(options); +}; diff --git a/plugins/openlayers/interaction/openlayers_interaction_pinchzoom.inc b/plugins/openlayers/interaction/openlayers_interaction_pinchzoom.inc new file mode 100644 index 0000000000000000000000000000000000000000..9d45b56f0aaae416835bed1817c3b3b3f5d1f90e --- /dev/null +++ b/plugins/openlayers/interaction/openlayers_interaction_pinchzoom.inc @@ -0,0 +1,13 @@ + array( + 'class' => 'openlayers_interaction_pinchzoom', + ) + ); +} + +class openlayers_interaction_pinchzoom extends openlayers_interaction { + +} diff --git a/plugins/openlayers/interaction/openlayers_interaction_pinchzoom.js b/plugins/openlayers/interaction/openlayers_interaction_pinchzoom.js new file mode 100644 index 0000000000000000000000000000000000000000..2ef4f174ac479af876b262fbc90501bc4c3dffe3 --- /dev/null +++ b/plugins/openlayers/interaction/openlayers_interaction_pinchzoom.js @@ -0,0 +1,3 @@ +Drupal.openlayers.openlayers_interaction_pinchzoom = function(options) { + return new ol.interaction.PinchZoom(options); +}; diff --git a/plugins/openlayers/interaction/openlayers_interaction_pointer.inc b/plugins/openlayers/interaction/openlayers_interaction_pointer.inc new file mode 100644 index 0000000000000000000000000000000000000000..b60dd8896eacd787c0fa4385179fc24179d5fe1c --- /dev/null +++ b/plugins/openlayers/interaction/openlayers_interaction_pointer.inc @@ -0,0 +1,13 @@ + array( + 'class' => 'openlayers_interaction_pointer', + ) + ); +} + +class openlayers_interaction_pointer extends openlayers_interaction { + +} diff --git a/plugins/openlayers/interaction/openlayers_interaction_pointer.js b/plugins/openlayers/interaction/openlayers_interaction_pointer.js new file mode 100644 index 0000000000000000000000000000000000000000..1551836da5d2236a94ae5a83a7b9ff3ec59fee87 --- /dev/null +++ b/plugins/openlayers/interaction/openlayers_interaction_pointer.js @@ -0,0 +1,3 @@ +Drupal.openlayers.openlayers_interaction_pointer = function(options) { + return new ol.interaction.Pointer(options); +}; diff --git a/plugins/openlayers/interaction/openlayers_interaction_select.inc b/plugins/openlayers/interaction/openlayers_interaction_select.inc new file mode 100644 index 0000000000000000000000000000000000000000..2938f62d119ae791dadc53cc7f16d88e8d929a27 --- /dev/null +++ b/plugins/openlayers/interaction/openlayers_interaction_select.inc @@ -0,0 +1,13 @@ + array( + 'class' => 'openlayers_interaction_select', + ) + ); +} + +class openlayers_interaction_select extends openlayers_interaction { + +} diff --git a/plugins/openlayers/interaction/openlayers_interaction_select.js b/plugins/openlayers/interaction/openlayers_interaction_select.js new file mode 100644 index 0000000000000000000000000000000000000000..1c214e24174c15757ab9f469b26d3b54805418e8 --- /dev/null +++ b/plugins/openlayers/interaction/openlayers_interaction_select.js @@ -0,0 +1,3 @@ +Drupal.openlayers.openlayers_interaction_select = function(options) { + return new ol.interaction.Select(options); +}; diff --git a/plugins/openlayers/interaction/openlayers_interaction_setvalues.inc b/plugins/openlayers/interaction/openlayers_interaction_setvalues.inc new file mode 100644 index 0000000000000000000000000000000000000000..1f1b0a84d1517d5d4ba2bde5e78975fcf760dc2d --- /dev/null +++ b/plugins/openlayers/interaction/openlayers_interaction_setvalues.inc @@ -0,0 +1,42 @@ + array( + 'class' => 'openlayers_interaction_setvalues', + ) + ); +} + +class openlayers_interaction_setvalues extends openlayers_interaction { + + function options_form() { + return array( + 'latitude' => array( + '#type' => 'textfield', + '#title' => t('Latitude'), + '#default_value' => $this->getOption('latitude'), + '#description' => t(''), + ), + 'longitude' => array( + '#type' => 'textfield', + '#title' => t('Longitude'), + '#default_value' => $this->getOption('longitude'), + '#description' => t(''), + ), + 'rotation' => array( + '#type' => 'textfield', + '#title' => t('Rotation'), + '#default_value' => $this->getOption('rotation', 0), + '#description' => t(''), + ), + 'zoom' => array( + '#type' => 'textfield', + '#title' => t('Zoom'), + '#default_value' => $this->getOption('zoom', 0), + '#description' => t(''), + ), + ); + } + +} diff --git a/plugins/openlayers/interaction/openlayers_interaction_setvalues.js b/plugins/openlayers/interaction/openlayers_interaction_setvalues.js new file mode 100644 index 0000000000000000000000000000000000000000..45c5768b7678f6e7f881a6b21541e846e34252ff --- /dev/null +++ b/plugins/openlayers/interaction/openlayers_interaction_setvalues.js @@ -0,0 +1,25 @@ +Drupal.openlayers.openlayers_interaction_setvalues = function(options, map) { + + map.on('moveend', function(evt){ + var selector = '#' + options.latitude; + jQuery(selector).val(map.getView().getCenter()[0]); + var selector = '#' + options.longitude; + jQuery(selector).val(map.getView().getCenter()[1]); + var selector = '#' + options.rotation; + jQuery(selector).val(map.getView().getRotation()); + var selector = '#' + options.zoom; + jQuery(selector).val(map.getView().getZoom()); + }); + + map.on('click', function(evt){ + var coordinate = evt.coordinate; + var pan = ol.animation.pan({ + duration: 2000, + source: (map.getView().getCenter()) + }); + map.beforeRender(pan); + map.getView().setCenter(coordinate); + }); + + return new ol.interaction.Select(options); +}; diff --git a/plugins/openlayers/layer/openlayers_layer_heatmap.inc b/plugins/openlayers/layer/openlayers_layer_heatmap.inc new file mode 100644 index 0000000000000000000000000000000000000000..43f1cff86482c903591fc180b2bf2fbf1015054c --- /dev/null +++ b/plugins/openlayers/layer/openlayers_layer_heatmap.inc @@ -0,0 +1,28 @@ + array( + 'class' => 'openlayers_layer_heatmap', + ) + ); +} + +class openlayers_layer_heatmap extends openlayers_layer { + + function options_form($defaults = array()) { + return array( + 'opacity' => array( + '#type' => 'textfield', + '#description' => 'Opacity (0, 1). Default is 1.', + '#default_value' => $this->getOption('opacity', 1), + ), + 'preload' => array( + '#type' => 'textfield', + '#description' => 'Preload. Load low-resolution tiles up to preload levels. By default preload is 0, which means no preloading.', + '#default_value' => $this->getOption('preload', 1), + ) + ); + } + +} diff --git a/plugins/openlayers/layer/openlayers_layer_heatmap.js b/plugins/openlayers/layer/openlayers_layer_heatmap.js new file mode 100644 index 0000000000000000000000000000000000000000..8d92b97c065b08991457eb41616f8a3d31e70bf0 --- /dev/null +++ b/plugins/openlayers/layer/openlayers_layer_heatmap.js @@ -0,0 +1,3 @@ +Drupal.openlayers.layer.heatmap = function(options) { + return new ol.layer.Heatmap(options); +}; diff --git a/plugins/openlayers/layer/openlayers_layer_image.inc b/plugins/openlayers/layer/openlayers_layer_image.inc new file mode 100644 index 0000000000000000000000000000000000000000..c76fc3180963ce52c61385719228ca6cbbab6f20 --- /dev/null +++ b/plugins/openlayers/layer/openlayers_layer_image.inc @@ -0,0 +1,93 @@ + array( + 'class' => 'openlayers_layer_image', + ) + ); +} + +class openlayers_layer_image extends openlayers_layer { + + function options_form() { + return array( + 'file' => array( + '#type' => 'managed_file', + '#title' => t('Image'), + '#default_value' => $this->getOption('file'), + '#upload_location' => 'public://', + ), + 'image_style' => array( + '#type' => 'select', + '#options' => array(''=> 'None (original image)') + image_style_options(FALSE), + '#default_value' => $this->getOption('image_style'), + '#description' => t('Apply an image style.'), + ), + 'factors' => array( + '#tree' => TRUE, + 'x' => array( + '#title' => 'Width divider', + '#type' => 'textfield', + // Todo: Find a way to replace this properly with getOption() method. + '#default_value' => isset($this->options['factors']['x']) ? $this->options['factors']['x'] : 1, + '#description' => t('Width divider.'), + ), + 'y' => array( + '#title' => 'Height divider', + '#type' => 'textfield', + '#default_value' => isset($this->options['factors']['y']) ? $this->options['factors']['y'] : 1, + '#description' => t('Height divider.'), + ), + ), + ); + } + + function options_form_validate($form, &$form_state) { + dpm($form_state); + if ($file = file_load($form_state['options']['file'])) { + // Do something with the file if needed. + } else { + + //form_set_error($form_state['item']['options'], 'Cannot access the file.'); + } + } + + /** + * hook_submit() of the form. + */ + function options_form_submit($form, &$form_state) { + global $user; + + $item = $form_state['item']; + if ($item->getOption('file') && $file = file_load($item->getOption('file'))) { + file_delete($file); + } + + if (isset($form_state['values']['options']['file']) && $file = file_load($form_state['values']['options']['file'])) { + $file->status = FILE_STATUS_PERMANENT; + file_save($file); + file_usage_add($file, 'openlayers', 'openlayers_layer_type', $user->uid); + } + + $style = $form_state['values']['options']['image_style']; + + if (!empty($style)) { + $uri = image_style_path($style, $file->uri); + image_style_create_derivative(image_style_load($style), $file->uri, $uri); + } else { + $uri = $file->uri; + } + } + + /* + * What to do when we delete the layer: delete the file. + */ + function delete($item) { + // todo + } + +} + + + diff --git a/plugins/openlayers/layer/openlayers_layer_image.js b/plugins/openlayers/layer/openlayers_layer_image.js new file mode 100644 index 0000000000000000000000000000000000000000..e5f82f1f3588893c48c58a52216437f501b18ecb --- /dev/null +++ b/plugins/openlayers/layer/openlayers_layer_image.js @@ -0,0 +1,3 @@ +Drupal.openlayers.openlayers_layer_image = function(options, map) { + return new ol.layer.Image(options); +}; diff --git a/plugins/openlayers/layer/openlayers_layer_tile.inc b/plugins/openlayers/layer/openlayers_layer_tile.inc new file mode 100644 index 0000000000000000000000000000000000000000..aebc3f53b4b950da840faa8b65517b68cfd2515c --- /dev/null +++ b/plugins/openlayers/layer/openlayers_layer_tile.inc @@ -0,0 +1,40 @@ + array( + 'class' => 'openlayers_layer_tile', + ) + ); +} + +class openlayers_layer_tile extends openlayers_layer { + + function options_form($defaults = array()) { + return array( + 'url' => array( + '#type' => 'textarea', + '#title' => t('Base URL (template)'), + '#default_value' => $this->getOption('url') ? implode("\n", (array) $this->getOption('url')) : '', + '#maxlength' => 2083, + '#description' => t('This is the base URL template for the XYZ layer. It should be something similar to http://example.com/tiles/1.0.0/layer_name/${z}/${x}/${y}.png.'), + ), + 'zoomOffset' => array( + '#type' => 'select', + '#description' => t('Zoom offset.'), + '#options' => array_combine( + range(0, 21), + range(0, 21)), + '#title' => t('Zoom offset'), + '#default_value' => $this->getOption('zoomOffset') + ), + 'wrapDateLine' => array( + '#type' => 'checkbox', + '#title' => t('Wrap Date Line'), + '#default_value' => $this->getOption('wrapDateLine'), + '#description' => t('This allows the user to continually pan left and right as the tiles will repeat themselves. Note that this option is known to not work well with the 2.10 OL library.'), + ), + ); + } + +} diff --git a/plugins/openlayers/layer/openlayers_layer_tile.js b/plugins/openlayers/layer/openlayers_layer_tile.js new file mode 100644 index 0000000000000000000000000000000000000000..2168ed8d2e1dcba8993cb57b91e3451ecab743d6 --- /dev/null +++ b/plugins/openlayers/layer/openlayers_layer_tile.js @@ -0,0 +1,3 @@ +Drupal.openlayers.openlayers_layer_tile = function(options) { + return new ol.layer.Tile(options); +}; diff --git a/plugins/openlayers/layer/openlayers_layer_vector.inc b/plugins/openlayers/layer/openlayers_layer_vector.inc new file mode 100644 index 0000000000000000000000000000000000000000..e7c3a9bcd1dc66ec126b6019f6dc2593699fd2c5 --- /dev/null +++ b/plugins/openlayers/layer/openlayers_layer_vector.inc @@ -0,0 +1,13 @@ + array( + 'class' => 'openlayers_layer_vector', + ) + ); +} + +class openlayers_layer_vector extends openlayers_layer { + +} diff --git a/plugins/openlayers/layer/openlayers_layer_vector.js b/plugins/openlayers/layer/openlayers_layer_vector.js new file mode 100644 index 0000000000000000000000000000000000000000..4fbafcd9013343c76d0e385a25ab31e231ddd9f7 --- /dev/null +++ b/plugins/openlayers/layer/openlayers_layer_vector.js @@ -0,0 +1,3 @@ +Drupal.openlayers.openlayers_layer_vector = function(options) { + return new ol.layer.Vector(options); +}; diff --git a/plugins/openlayers/map/openlayers_map_map.inc b/plugins/openlayers/map/openlayers_map_map.inc new file mode 100644 index 0000000000000000000000000000000000000000..d48f094dff41b599285a403dfe04185f03f420e1 --- /dev/null +++ b/plugins/openlayers/map/openlayers_map_map.inc @@ -0,0 +1,98 @@ + array( + 'class' => 'openlayers_map_map', + ) + ); +} + +class openlayers_map_map extends openlayers_map { + + function options_form() { + $form['options']['ui'] = array( + '#type' => 'fieldset', + '#title' => t('Size of the map'), + '#tree' => TRUE, + 'width' => array( + '#type' => 'textfield', + '#title' => 'Width', + '#default_value' => $this->getOption('width', 'auto'), + '#parents' => array('options', 'width'), + ), + 'height' => array( + '#type' => 'textfield', + '#title' => 'height', + '#default_value' => $this->getOption('height', '300px'), + '#parents' => array('options', 'height'), + ), + 'contextualLinks' => array( + '#type' => 'checkbox', + '#title' => 'Contextual links', + '#description' => t('Enable contextual links on the map.'), + '#default_value' => $this->getOption('contextualLinks', TRUE), + '#parents' => array('options', 'contextualLinks'), + ), + 'provideBlock' => array( + '#type' => 'checkbox', + '#title' => 'Provide Drupal block', + '#description' => t('Enable this to enable a block to display the map.'), + '#default_value' => $this->getOption('provideBlock', TRUE), + '#parents' => array('options', 'provideBlock'), + ), + ); + + $form['options']['view'] = array( + '#type' => 'fieldset', + '#title' => t('View: center and rotation'), + '#tree' => TRUE, + ); + + if ($this->machine_name != 'map_view_edit_form') { + $map = openlayers_object_load('map', 'map_view_edit_form'); + if ($view = $this->getOption('view')) { + $map->options['view'] = $view; + } + + $form['options']['view']['map'] = array( + '#title' => 'Map', + '#markup' => openlayers_render_map($map), + ); + } + + $form['options']['view']['center'] = array( + 'lat' => array( + '#type' => 'textfield', + '#title' => 'Latitude', + // Todo: Replace with getOption() method. + '#default_value' => isset($this->options['view']['center']['lat']) ? $this->options['view']['center']['lat']:0, + '#parents' => array('options', 'view', 'center', 'lat'), + ), + 'lon' => array( + '#type' => 'textfield', + '#title' => 'Longitude', + '#default_value' => isset($this->options['view']['center']['lon']) ? $this->options['view']['center']['lon']:0, + '#parents' => array('options', 'view', 'center', 'lon'), + ) + ); + $form['options']['view']['rotation'] = array( + 'rotation' => array( + '#type' => 'textfield', + '#title' => 'Rotation', + '#default_value' => isset($this->options['view']['rotation']) ? $this->options['view']['rotation']:0, + '#parents' => array('options', 'view', 'rotation'), + ), + ); + $form['options']['view']['zoom'] = array( + 'zoom' => array( + '#type' => 'textfield', + '#title' => 'Zoom', + '#default_value' => isset($this->options['view']['zoom']) ? $this->options['view']['zoom']:0, + '#parents' => array('options', 'view', 'zoom'), + ), + ); + + return $form; + } +} diff --git a/plugins/openlayers/map/openlayers_map_map.js b/plugins/openlayers/map/openlayers_map_map.js new file mode 100644 index 0000000000000000000000000000000000000000..39d84868d05b93af640ef6cad7bde4fece852ca8 --- /dev/null +++ b/plugins/openlayers/map/openlayers_map_map.js @@ -0,0 +1,13 @@ +Drupal.openlayers.openlayers_map_map = function(options) { + var projection = ol.proj.get('EPSG:3857'); + + options.view = new ol.View({ + center: [options.view.center.lat, options.view.center.lon], + rotation: options.view.rotation, + zoom: options.view.zoom, + projection: projection, + extent: projection.getExtent() + }); + + return new ol.Map(options); +}; diff --git a/plugins/openlayers/source/openlayers_source_bingmaps.inc b/plugins/openlayers/source/openlayers_source_bingmaps.inc new file mode 100644 index 0000000000000000000000000000000000000000..aa38ced45b765f87c58c03813c1c7830e6bceaab --- /dev/null +++ b/plugins/openlayers/source/openlayers_source_bingmaps.inc @@ -0,0 +1,30 @@ + array( + 'class' => 'openlayers_source_bingmaps', + ) + ); +} + +class openlayers_source_bingmaps extends openlayers_source { + + function options_form($defaults = array()) { + $layer_types = array( + 'Road' => 'Road', + 'AerialWithLabels' => 'Hybrid', + 'Aerial' => 'Aerial', + ); + + return array( + 'type' => array( + '#title' => t('Source type'), + '#type' => 'select', + '#default_value' => isset($this->data['type']) ? $this->data['type'] : 'Road', + '#options' => $layer_types + ) + ); + } + +} diff --git a/plugins/openlayers/source/openlayers_source_bingmaps.js b/plugins/openlayers/source/openlayers_source_bingmaps.js new file mode 100644 index 0000000000000000000000000000000000000000..7726a7ab141dd6ad76fe1e425b2e9e8a9fe12580 --- /dev/null +++ b/plugins/openlayers/source/openlayers_source_bingmaps.js @@ -0,0 +1,3 @@ +Drupal.openlayers.source.bingmaps = function(map, options) { + return new ol.source.BingMaps(options); +}; diff --git a/plugins/openlayers/source/openlayers_source_geojson.inc b/plugins/openlayers/source/openlayers_source_geojson.inc new file mode 100644 index 0000000000000000000000000000000000000000..bcbc0056ed1a7bae009e24f7bd98e1395f21166c --- /dev/null +++ b/plugins/openlayers/source/openlayers_source_geojson.inc @@ -0,0 +1,49 @@ + array( + 'class' => 'openlayers_source_geojson', + ) + ); +} + +class openlayers_source_geojson extends openlayers_source { + + function options_init() { + return array( + 'data' => array() + ); + } + + function options_form($defaults = array()) { + $layer_types = array( + 'Road' => 'Road', + 'AerialWithLabels' => 'Hybrid', + 'Aerial' => 'Aerial', + ); + + return array( + 'type' => array( + '#title' => t('Source type'), + '#type' => 'select', + '#default_value' => isset($this->data['type']) ? $this->data['type'] : 'Road', + '#options' => $layer_types + ) + ); + } + + function settings_form() { + return array(); + } + + function attached() { + return array( + 'js' => array( + drupal_get_path('module', 'openlayers') . '/plugins/source/openlayers_source_geojson.js' + ) + ); + } + + function render(&$map) {} +} diff --git a/plugins/openlayers/source/openlayers_source_geojson.js b/plugins/openlayers/source/openlayers_source_geojson.js new file mode 100644 index 0000000000000000000000000000000000000000..48b7bef6f82a40488fdba4627be56824f806aa29 --- /dev/null +++ b/plugins/openlayers/source/openlayers_source_geojson.js @@ -0,0 +1,3 @@ +Drupal.openlayers.source.geojson = function(map, options) { + return new ol.source.GeoJSON(options); +}; diff --git a/plugins/openlayers/source/openlayers_source_imagestatic.inc b/plugins/openlayers/source/openlayers_source_imagestatic.inc new file mode 100644 index 0000000000000000000000000000000000000000..ea1fc44b12507de03d72209b4b2fc8d013c35e65 --- /dev/null +++ b/plugins/openlayers/source/openlayers_source_imagestatic.inc @@ -0,0 +1,13 @@ + array( + 'class' => 'openlayers_source_imagestatic', + ) + ); +} + +class openlayers_source_imagestatic extends openlayers_source { + +} diff --git a/plugins/openlayers/source/openlayers_source_imagestatic.js b/plugins/openlayers/source/openlayers_source_imagestatic.js new file mode 100644 index 0000000000000000000000000000000000000000..c59e94300ba7de4a20a92ff76ea3dcf92ff8ab4e --- /dev/null +++ b/plugins/openlayers/source/openlayers_source_imagestatic.js @@ -0,0 +1,20 @@ +Drupal.openlayers.openlayers_source_imagestatic = function(options, map) { + + var pixelProjection = new ol.proj.Projection({ + code: 'pixel', + units: 'pixels', + extent: [0, 0, 1024, 968] + }); + + options.imageSize = [1024, 1024]; + options.projection = pixelProjection; + options.imageExtent = pixelProjection.getExtent(); + + map.setView(new ol.View({ + projection: pixelProjection, + center: ol.extent.getCenter(pixelProjection.getExtent()), + zoom: map.getView().getZoom() + })); + + return new ol.source.ImageStatic(options); +}; diff --git a/plugins/openlayers/source/openlayers_source_mapquest.inc b/plugins/openlayers/source/openlayers_source_mapquest.inc new file mode 100644 index 0000000000000000000000000000000000000000..06a706a8bc3125411db51a6f3eabaf0081733380 --- /dev/null +++ b/plugins/openlayers/source/openlayers_source_mapquest.inc @@ -0,0 +1,30 @@ + array( + 'class' => 'openlayers_source_mapquest', + ) + ); +} + +class openlayers_source_mapquest extends openlayers_source { + + function options_form() { + $layer_types = array( + 'osm' => 'OpenStreetMap', + 'sat' => 'Satellite', + 'hyb' => 'Hybrid', + ); + + return array( + 'layer' => array( + '#title' => t('Source type'), + '#type' => 'select', + '#default_value' => $this->getOption('layer', 'osm'), + '#options' => $layer_types + ) + ); + } + +} diff --git a/plugins/openlayers/source/openlayers_source_mapquest.js b/plugins/openlayers/source/openlayers_source_mapquest.js new file mode 100644 index 0000000000000000000000000000000000000000..c202e02d0fa37cc7460c47f0bd2a1fa255cd1bdc --- /dev/null +++ b/plugins/openlayers/source/openlayers_source_mapquest.js @@ -0,0 +1,3 @@ +Drupal.openlayers.openlayers_source_mapquest = function(options) { + return new ol.source.MapQuest(options); +}; diff --git a/plugins/openlayers/source/openlayers_source_osm.inc b/plugins/openlayers/source/openlayers_source_osm.inc new file mode 100644 index 0000000000000000000000000000000000000000..9fc2d0d2957923ec50d9c396ae034a7e31c0d717 --- /dev/null +++ b/plugins/openlayers/source/openlayers_source_osm.inc @@ -0,0 +1,13 @@ + array( + 'class' => 'openlayers_source_osm', + ) + ); +} + +class openlayers_source_osm extends openlayers_source { + +} diff --git a/plugins/openlayers/source/openlayers_source_osm.js b/plugins/openlayers/source/openlayers_source_osm.js new file mode 100644 index 0000000000000000000000000000000000000000..675a48a8bc37dfc1b14ead9c8150c336da96b10d --- /dev/null +++ b/plugins/openlayers/source/openlayers_source_osm.js @@ -0,0 +1,3 @@ +Drupal.openlayers.openlayers_source_osm = function(options) { + return new ol.source.OSM(options); +}; diff --git a/plugins/openlayers/source/openlayers_source_tilejson.inc b/plugins/openlayers/source/openlayers_source_tilejson.inc new file mode 100644 index 0000000000000000000000000000000000000000..b0a475c8667ff6a75ce75175d0d508493e4cf66a --- /dev/null +++ b/plugins/openlayers/source/openlayers_source_tilejson.inc @@ -0,0 +1,23 @@ + array( + 'class' => 'openlayers_source_tilejson', + ) + ); +} + +class openlayers_source_tilejson extends openlayers_source { + + function options_form() { + return array( + 'url' => array( + '#title' => t('URL'), + '#type' => 'textfield', + '#default_value' => $this->getOption('url'), + ) + ); + } + +} diff --git a/plugins/openlayers/source/openlayers_source_tilejson.js b/plugins/openlayers/source/openlayers_source_tilejson.js new file mode 100644 index 0000000000000000000000000000000000000000..22b8de646e98703166fe470a6943a80a2fca0d8f --- /dev/null +++ b/plugins/openlayers/source/openlayers_source_tilejson.js @@ -0,0 +1,3 @@ +Drupal.openlayers.openlayers_source_tilejson = function(options) { + return new ol.source.TileJSON(options); +}; diff --git a/plugins/openlayers/source/openlayers_source_xyz.inc b/plugins/openlayers/source/openlayers_source_xyz.inc new file mode 100644 index 0000000000000000000000000000000000000000..449b9e2e418c15ca77619c8c14e7abd49bdaa3e0 --- /dev/null +++ b/plugins/openlayers/source/openlayers_source_xyz.inc @@ -0,0 +1,49 @@ + array( + 'class' => 'openlayers_source_xyz', + ) + ); +} + +class openlayers_source_xyz extends openlayers_source { + + function options_init() { + return array( + 'data' => array() + ); + } + + function options_form($defaults = array()) { + $layer_types = array( + 'Road' => 'Road', + 'AerialWithLabels' => 'Hybrid', + 'Aerial' => 'Aerial', + ); + + return array( + 'type' => array( + '#title' => t('Source type'), + '#type' => 'select', + '#default_value' => isset($this->data['type']) ? $this->data['type'] : 'Road', + '#options' => $layer_types + ) + ); + } + + function settings_form() { + return array(); + } + + function attached() { + return array( + 'js' => array( + drupal_get_path('module', 'openlayers') . '/plugins/source/openlayers_source_xyz.js' + ) + ); + } + + function render(&$map) {} +} diff --git a/plugins/openlayers/source/openlayers_source_xyz.js b/plugins/openlayers/source/openlayers_source_xyz.js new file mode 100644 index 0000000000000000000000000000000000000000..ec4c0626a532267c9bed3912e51c15a3314c062a --- /dev/null +++ b/plugins/openlayers/source/openlayers_source_xyz.js @@ -0,0 +1,3 @@ +Drupal.openlayers.source.xyz = function(map, options) { + return new ol.source.XYZ(options); +}; diff --git a/plugins/quicktabs/QuickMap.inc b/plugins/quicktabs/QuickMap.inc deleted file mode 100644 index 34e0b3da3e04ad04bced3d13a3feb2f24f1d6def..0000000000000000000000000000000000000000 --- a/plugins/quicktabs/QuickMap.inc +++ /dev/null @@ -1,48 +0,0 @@ -settings; - $form = array(); - $form['map']['map'] = array( - '#type' => 'select', - '#title' => t('OpenLayers Map'), - '#options' => openlayers_map_options(), - '#default_value' => isset($tab['map']) ? $tab['map'] : '', - ); - return $form; - } - - public function render($hide_empty = FALSE, $args = array()) { - if ($this->rendered_content) { - return $this->rendered_content; - } - $output = array(); - $item = $this->settings; - - // We should add a JS file here to automatically resize the map when - // the map is not the default tab. - - $map = openlayers_map_load($item['map']); - $render = openlayers_render_map($map); - - $output['#markup'] = $render; - $this->rendered_content = $output; - return $output; - } - - public function getAjaxKeys() { - return array('map'); - } - -} - diff --git a/tests/data/openlayers_test.json b/tests/data/openlayers_test.json deleted file mode 100644 index 0dcdf1b8a0a3ad97de22a409e83feffb78a70b67..0000000000000000000000000000000000000000 --- a/tests/data/openlayers_test.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "type": "FeatureCollection", - "features": [ - { - "type": "Feature", - "properties": { - "name": "Feature 01", - "description": "Just testing things..." - }, - "geometry": { - "type": "Point", - "coordinates": [ - 86.8359375, - 50.80078125 - ] - }, - "crs": { - "type": "name", - "properties": { - "name": "urn:ogc:def:crs:OGC:1.3:CRS84" - } - } - }, - { - "type": "Feature", - "properties": { - "name": "Feature 02", - "description": "Just testing things..." - }, - "geometry": { - "type": "Point", - "coordinates": [ - 101.6015625, - 51.85546875 - ] - }, - "crs": { - "type": "name", - "properties": { - "name": "urn:ogc:def:crs:OGC:1.3:CRS84" - } - } - }, - { - "type": "Feature", - "properties": { - "name": "Feature 03", - "description": "Just testing things..." - }, - "geometry": { - "type": "Point", - "coordinates": [ - 110.7421875, - 39.55078125 - ] - }, - "crs": { - "type": "name", - "properties": { - "name": "urn:ogc:def:crs:OGC:1.3:CRS84" - } - } - } - ] -} \ No newline at end of file diff --git a/tests/data/openlayers_test.kml b/tests/data/openlayers_test.kml deleted file mode 100644 index 60b5692ee1a0972c6b712a06f39f06549e51d151..0000000000000000000000000000000000000000 --- a/tests/data/openlayers_test.kml +++ /dev/null @@ -1,915 +0,0 @@ - - - - KML Samples - 1 - Unleash your creativity with the help of these examples! - - - - - - - - - - - - - - Placemarks - These are just some of the different kinds of placemarks with - which you can mark your favorite places - - -122.0839597145766 - 37.42222904525232 - 0 - -148.4122922628044 - 40.5575073395506 - 500.6566641072245 - - - Simple placemark - Attached to the ground. Intelligently places itself at the - height of the underlying terrain. - - -122.0822035425683,37.42228990140251,0 - - - - Floating placemark - 0 - Floats a defined distance above the ground. - - -122.0839597145766 - 37.42222904525232 - 0 - -148.4122922628044 - 40.5575073395506 - 500.6566641072245 - - #downArrowIcon - - relativeToGround - -122.084075,37.4220033612141,50 - - - - Extruded placemark - 0 - Tethered to the ground by a customizable - "tail" - - -122.0845787421525 - 37.42215078737763 - 0 - -148.4126684946234 - 40.55750733918048 - 365.2646606980322 - - #globeIcon - - 1 - relativeToGround - -122.0857667006183,37.42156927867553,50 - - - - - Styles and Markup - 0 - With KML it is easy to create rich, descriptive markup to - annotate and enrich your placemarks - - -122.0845787422371 - 37.42215078726837 - 0 - -148.4126777488172 - 40.55750733930874 - 365.2646826292919 - - #noDrivingDirections - - Highlighted Icon - 0 - Place your mouse over the icon to see it display the new - icon - - -122.0856552124024 - 37.4224281311035 - 0 - 0 - 0 - 265.8520424250024 - - - - - - normal - #normalPlacemark - - - highlight - #highlightPlacemark - - - - Roll over this icon - 0 - #exampleStyleMap - - -122.0856545755255,37.42243077405461,0 - - - - - Descriptive HTML - 0 -
-Placemark descriptions can be enriched by using many standard HTML tags.
-For example: -
-Styles:
-Italics, -Bold, -Underlined, -Strike Out, -subscriptsubscript, -superscriptsuperscript, -Big, -Small, -Typewriter, -Emphasized, -Strong, -Code -
-Fonts:
-red by name, -leaf green by hexadecimal RGB -
-size 1, -size 2, -size 3, -size 4, -size 5, -size 6, -size 7 -
-Times, -Verdana, -Arial
-
-Links: -
-Google Earth! -
- or: Check out our website at www.google.com -
-Alignment:
-

left

-

center

-

right

-
-Ordered Lists:
-
  1. First
  2. Second
  3. Third
-
  1. First
  2. Second
  3. Third
-
  1. First
  2. Second
  3. Third
-
-Unordered Lists:
-
  • A
  • B
  • C
-
  • A
  • B
  • C
-
  • A
  • B
  • C
-
-Definitions:
-
-
Google:
The best thing since sliced bread
-
-
-Centered:
-Time present and time past
-Are both perhaps present in time future,
-And time future contained in time past.
-If all time is eternally present
-All time is unredeemable.
-
-
-Block Quote: -
-
-We shall not cease from exploration
-And the end of all our exploring
-Will be to arrive where we started
-And know the place for the first time.
--- T.S. Eliot -
-
-
-Headings:
-

Header 1

-

Header 2

-

Header 3

-

Header 4

-

Header 5

-
-Images:
-Remote image
-
-Scaled image
-
-
-Simple Tables:
- - - -
12345
abcde
-
-[Did you notice that double-clicking on the placemark doesn't cause the viewer to take you anywhere? This is because it is possible to directly author a "placeless placemark". If you look at the code for this example, you will see that it has neither a point coordinate nor a LookAt element.]]]>
-
-
- - Ground Overlays - 0 - Examples of ground overlays - - Large-scale overlay on terrain - 0 - Overlay shows Mount Etna erupting on July 13th, 2001. - - 15.02468937557116 - 37.67395167941667 - 0 - -16.5581842842829 - 58.31228652890705 - 30350.36838438907 - - - http://code.google.com/apis/kml/documentation/etna.jpg - - - 37.91904192681665 - 37.46543388598137 - 15.35832653742206 - 14.60128369746704 - -0.1556640799496235 - - - - - Screen Overlays - 0 - Screen overlays have to be authored directly in KML. These - examples illustrate absolute and dynamic positioning in screen space. - - Simple crosshairs - 0 - This screen overlay uses fractional positioning to put the - image in the exact center of the screen - - http://code.google.com/apis/kml/documentation/crosshairs.png - - - - - - - - Absolute Positioning: Top left - 0 - - http://code.google.com/apis/kml/documentation/top_left.jpg - - - - - - - - Absolute Positioning: Top right - 0 - - http://code.google.com/apis/kml/documentation/top_right.jpg - - - - - - - - Absolute Positioning: Bottom left - 0 - - http://code.google.com/apis/kml/documentation/bottom_left.jpg - - - - - - - - Absolute Positioning: Bottom right - 0 - - http://code.google.com/apis/kml/documentation/bottom_right.jpg - - - - - - - - Dynamic Positioning: Top of screen - 0 - - http://code.google.com/apis/kml/documentation/dynamic_screenoverlay.jpg - - - - - - - - Dynamic Positioning: Right of screen - 0 - - http://code.google.com/apis/kml/documentation/dynamic_right.jpg - - - - - - - - - Paths - 0 - Examples of paths. Note that the tessellate tag is by default - set to 0. If you want to create tessellated lines, they must be authored - (or edited) directly in KML. - - Tessellated - 0 - tag has a value of 1, the line will contour to the underlying terrain]]> - - -112.0822680013139 - 36.09825589333556 - 0 - 103.8120432044965 - 62.04855796276328 - 2889.145007690472 - - - 1 - -112.0814237830345,36.10677870477137,0 - -112.0870267752693,36.0905099328766,0 - - - - Untessellated - 0 - tag has a value of 0, the line follow a simple straight-line path from point to point]]> - - -112.0822680013139 - 36.09825589333556 - 0 - 103.8120432044965 - 62.04855796276328 - 2889.145007690472 - - - 0 - -112.080622229595,36.10673460007995,0 - -112.085242575315,36.09049598612422,0 - - - - Absolute - 0 - Transparent purple line - - -112.2719329043177 - 36.08890633450894 - 0 - -106.8161545998597 - 44.60763714063257 - 2569.386744398339 - - #transPurpleLineGreenPoly - - 1 - absolute - -112.265654928602,36.09447672602546,2357 - -112.2660384528238,36.09342608838671,2357 - -112.2668139013453,36.09251058776881,2357 - -112.2677826834445,36.09189827357996,2357 - -112.2688557510952,36.0913137941187,2357 - -112.2694810717219,36.0903677207521,2357 - -112.2695268555611,36.08932171487285,2357 - -112.2690144567276,36.08850916060472,2357 - -112.2681528815339,36.08753813597956,2357 - -112.2670588176031,36.08682685262568,2357 - -112.2657374587321,36.08646312301303,2357 - - - - Absolute Extruded - 0 - Transparent green wall with yellow outlines - - -112.2643334742529 - 36.08563154742419 - 0 - -125.7518698668815 - 44.61038665812578 - 4451.842204068102 - - #yellowLineGreenPoly - - 1 - 1 - absolute - -112.2550785337791,36.07954952145647,2357 - -112.2549277039738,36.08117083492122,2357 - -112.2552505069063,36.08260761307279,2357 - -112.2564540158376,36.08395660588506,2357 - -112.2580238976449,36.08511401044813,2357 - -112.2595218489022,36.08584355239394,2357 - -112.2608216347552,36.08612634548589,2357 - -112.262073428656,36.08626019085147,2357 - -112.2633204928495,36.08621519860091,2357 - -112.2644963846444,36.08627897945274,2357 - -112.2656969554589,36.08649599090644,2357 - - - - Relative - 0 - Black line (10 pixels wide), height tracks terrain - - -112.2580438551384 - 36.1072674824385 - 0 - 4.947421249553717 - 44.61324882043339 - 2927.61105910266 - - #thickBlackLine - - 1 - relativeToGround - -112.2532845153347,36.09886943729116,645 - -112.2540466121145,36.09919570465255,645 - -112.254734666947,36.09984998366178,645 - -112.255493345654,36.10051310621746,645 - -112.2563157098468,36.10108441943419,645 - -112.2568033076439,36.10159722088088,645 - -112.257494011321,36.10204323542867,645 - -112.2584106072308,36.10229131995655,645 - -112.2596588987972,36.10240001286358,645 - -112.2610581199487,36.10213176873407,645 - -112.2626285262793,36.10157011437219,645 - - - - Relative Extruded - 0 - Opaque blue walls with red outline, height tracks terrain - - -112.2683594333433 - 36.09884362144909 - 0 - -72.24271551768405 - 44.60855445139561 - 2184.193522571467 - - #redLineBluePoly - - 1 - 1 - relativeToGround - -112.2656634181359,36.09445214722695,630 - -112.2652238941097,36.09520916122063,630 - -112.2645079986395,36.09580763864907,630 - -112.2638827428817,36.09628572284063,630 - -112.2635746835406,36.09679275951239,630 - -112.2635711822407,36.09740038871899,630 - -112.2640296531825,36.09804913435539,630 - -112.264327720538,36.09880337400301,630 - -112.2642436562271,36.09963644790288,630 - -112.2639148687042,36.10055381117246,630 - -112.2626894973474,36.10149062823369,630 - - - - - Polygons - 0 - Examples of polygon shapes - - Google Campus - 0 - A collection showing how easy it is to create 3-dimensional - buildings - - -122.084120030116 - 37.42174011925477 - 0 - -34.82469740081282 - 53.454348562403 - 276.7870053764046 - - - Building 40 - 0 - #transRedPoly - - 1 - relativeToGround - - - -122.0848938459612,37.42257124044786,17 - -122.0849580979198,37.42211922626856,17 - -122.0847469573047,37.42207183952619,17 - -122.0845725380962,37.42209006729676,17 - -122.0845954886723,37.42215932700895,17 - -122.0838521118269,37.42227278564371,17 - -122.083792243335,37.42203539112084,17 - -122.0835076656616,37.42209006957106,17 - -122.0834709464152,37.42200987395161,17 - -122.0831221085748,37.4221046494946,17 - -122.0829247374572,37.42226503990386,17 - -122.0829339169385,37.42231242843094,17 - -122.0833837359737,37.42225046087618,17 - -122.0833607854248,37.42234159228745,17 - -122.0834204551642,37.42237075460644,17 - -122.083659133885,37.42251292011001,17 - -122.0839758438952,37.42265873093781,17 - -122.0842374743331,37.42265143972521,17 - -122.0845036949503,37.4226514386435,17 - -122.0848020460801,37.42261133916315,17 - -122.0847882750515,37.42256395055121,17 - -122.0848938459612,37.42257124044786,17 - - - - - - Building 41 - 0 - #transBluePoly - - 1 - relativeToGround - - - -122.0857412771483,37.42227033155257,17 - -122.0858169768481,37.42231408832346,17 - -122.085852582875,37.42230337469744,17 - -122.0858799945639,37.42225686138789,17 - -122.0858860101409,37.4222311076138,17 - -122.0858069157288,37.42220250173855,17 - -122.0858379542653,37.42214027058678,17 - -122.0856732640519,37.42208690214408,17 - -122.0856022926407,37.42214885429042,17 - -122.0855902778436,37.422128290487,17 - -122.0855841672237,37.42208171967246,17 - -122.0854852065741,37.42210455874995,17 - -122.0855067264352,37.42214267949824,17 - -122.0854430712915,37.42212783846172,17 - -122.0850990714904,37.42251282407603,17 - -122.0856769818632,37.42281815323651,17 - -122.0860162273783,37.42244918858722,17 - -122.0857260327004,37.42229239604253,17 - -122.0857412771483,37.42227033155257,17 - - - - - - Building 42 - 0 - #transGreenPoly - - 1 - relativeToGround - - - -122.0857862287242,37.42136208886969,25 - -122.0857312990603,37.42136935989481,25 - -122.0857312992918,37.42140934910903,25 - -122.0856077073679,37.42138390166565,25 - -122.0855802426516,37.42137299550869,25 - -122.0852186221971,37.42137299504316,25 - -122.0852277765639,37.42161656508265,25 - -122.0852598189347,37.42160565894403,25 - -122.0852598185499,37.42168200156,25 - -122.0852369311478,37.42170017860346,25 - -122.0852643957828,37.42176197982575,25 - -122.0853239032746,37.42176198013907,25 - -122.0853559454324,37.421852864452,25 - -122.0854108752463,37.42188921823734,25 - -122.0854795379357,37.42189285337048,25 - -122.0855436229819,37.42188921797546,25 - -122.0856260178042,37.42186013499926,25 - -122.085937287963,37.42186013453605,25 - -122.0859428718666,37.42160898590042,25 - -122.0859655469861,37.42157992759144,25 - -122.0858640462341,37.42147115002957,25 - -122.0858548911215,37.42140571326184,25 - -122.0858091162768,37.4214057134039,25 - -122.0857862287242,37.42136208886969,25 - - - - - - Building 43 - 0 - #transYellowPoly - - 1 - relativeToGround - - - -122.0844371128284,37.42177253003091,19 - -122.0845118855746,37.42191111542896,19 - -122.0850470999805,37.42178755121535,19 - -122.0850719913391,37.42143663023161,19 - -122.084916406232,37.42137237822116,19 - -122.0842193868167,37.42137237801626,19 - -122.08421938659,37.42147617161496,19 - -122.0838086419991,37.4214613409357,19 - -122.0837899728564,37.42131306410796,19 - -122.0832796534698,37.42129328840593,19 - -122.0832609819207,37.42139213944298,19 - -122.0829373621737,37.42137236399876,19 - -122.0829062425667,37.42151569778871,19 - -122.0828502269665,37.42176282576465,19 - -122.0829435788635,37.42176776969635,19 - -122.083217411188,37.42179248552686,19 - -122.0835970430103,37.4217480074456,19 - -122.0839455556771,37.42169364237603,19 - -122.0840077894637,37.42176283815853,19 - -122.084113587521,37.42174801104392,19 - -122.0840762473784,37.42171341292375,19 - -122.0841447047739,37.42167881534569,19 - -122.084144704223,37.42181720660197,19 - -122.0842503333074,37.4218170700446,19 - -122.0844371128284,37.42177253003091,19 - - - - - - - Extruded Polygon - A simple way to model a building - - The Pentagon - - -77.05580139178142 - 38.870832443487 - 59.88865561738225 - 48.09646074797388 - 742.0552506670548 - - - 1 - relativeToGround - - - -77.05788457660967,38.87253259892824,100 - -77.05465973756702,38.87291016281703,100 - -77.05315536854791,38.87053267794386,100 - -77.05552622493516,38.868757801256,100 - -77.05844056290393,38.86996206506943,100 - -77.05788457660967,38.87253259892824,100 - - - - - -77.05668055019126,38.87154239798456,100 - -77.05542625960818,38.87167890344077,100 - -77.05485125901024,38.87076535397792,100 - -77.05577677433152,38.87008686581446,100 - -77.05691162017543,38.87054446963351,100 - -77.05668055019126,38.87154239798456,100 - - - - - - - Absolute and Relative - 0 - Four structures whose roofs meet exactly. Turn on/off - terrain to see the difference between relative and absolute - positioning. - - -112.3348969157552 - 36.14845533214919 - 0 - -86.91235037566909 - 49.30695423894192 - 990.6761201087104 - - - Absolute - 0 - #transBluePoly - - 1 - absolute - - - -112.3372510731295,36.14888505105317,1784 - -112.3356128688403,36.14781540589019,1784 - -112.3368169371048,36.14658677734382,1784 - -112.3384408457543,36.14762778914076,1784 - -112.3372510731295,36.14888505105317,1784 - - - - - - Absolute Extruded - 0 - #transRedPoly - - 1 - 1 - absolute - - - -112.3396586818843,36.14637618647505,1784 - -112.3380597654315,36.14531751871353,1784 - -112.3368254237788,36.14659596244607,1784 - -112.3384555043203,36.14762621763982,1784 - -112.3396586818843,36.14637618647505,1784 - - - - - - Relative - 0 - - -112.3350152490417 - 36.14943123077423 - 0 - -118.9214100848499 - 37.92486261093203 - 345.5169113679813 - - #transGreenPoly - - 1 - relativeToGround - - - -112.3349463145932,36.14988705767721,100 - -112.3354019540677,36.14941108398372,100 - -112.3344428289146,36.14878490381308,100 - -112.3331289492913,36.14780840132443,100 - -112.3317019516947,36.14680755678357,100 - -112.331131440106,36.1474173426228,100 - -112.332616324338,36.14845453364654,100 - -112.3339876620524,36.14926570522069,100 - -112.3349463145932,36.14988705767721,100 - - - - - - Relative Extruded - 0 - - -112.3351587892382 - 36.14979247129029 - 0 - -55.42811560891606 - 56.10280503739589 - 401.0997279712519 - - #transYellowPoly - - 1 - 1 - relativeToGround - - - -112.3348783983763,36.1514008468736,100 - -112.3372535345629,36.14888517553886,100 - -112.3356068927954,36.14781612679284,100 - -112.3350034807972,36.14846469024177,100 - -112.3358353861232,36.1489624162954,100 - -112.3345888301373,36.15026229372507,100 - -112.3337937856278,36.14978096026463,100 - -112.3331798208424,36.1504472788618,100 - -112.3348783983763,36.1514008468736,100 - - - - - - -
-
diff --git a/tests/features/openlayers_test_example_feature/openlayers_test_example_feature.features.field.inc b/tests/features/openlayers_test_example_feature/openlayers_test_example_feature.features.field.inc deleted file mode 100644 index 1390b3423547d80015d723d9f05ec2292a8f25c0..0000000000000000000000000000000000000000 --- a/tests/features/openlayers_test_example_feature/openlayers_test_example_feature.features.field.inc +++ /dev/null @@ -1,153 +0,0 @@ - array( - 'active' => '1', - 'cardinality' => '1', - 'deleted' => '0', - 'entity_types' => array( - 0 => 'node', - ), - 'field_name' => 'body', - 'foreign keys' => array( - 'format' => array( - 'columns' => array( - 'format' => 'format', - ), - 'table' => 'filter_format', - ), - ), - 'indexes' => array( - 'format' => array( - 0 => 'format', - ), - ), - 'module' => 'text', - 'settings' => array(), - 'translatable' => '0', - 'type' => 'text_with_summary', - ), - 'field_instance' => array( - 'bundle' => 'openlayers_example_content', - 'default_value' => NULL, - 'deleted' => '0', - 'description' => '', - 'display' => array( - 'default' => array( - 'label' => 'hidden', - 'module' => 'text', - 'settings' => array(), - 'type' => 'text_default', - 'weight' => '0', - ), - 'teaser' => array( - 'label' => 'hidden', - 'module' => 'text', - 'settings' => array( - 'trim_length' => 600, - ), - 'type' => 'text_summary_or_trimmed', - 'weight' => 0, - ), - ), - 'entity_type' => 'node', - 'field_name' => 'body', - 'label' => 'Body', - 'required' => FALSE, - 'settings' => array( - 'display_summary' => TRUE, - 'text_processing' => 1, - 'user_register_form' => FALSE, - ), - 'widget' => array( - 'module' => 'text', - 'settings' => array( - 'rows' => 20, - 'summary_rows' => 5, - ), - 'type' => 'text_textarea_with_summary', - 'weight' => '2', - ), - ), - ); - - // Exported field: 'node-openlayers_example_content-field_openlayers_example_input' - $fields['node-openlayers_example_content-field_openlayers_example_input'] = array( - 'field_config' => array( - 'active' => '1', - 'cardinality' => '1', - 'deleted' => '0', - 'entity_types' => array(), - 'field_name' => 'field_openlayers_example_input', - 'foreign keys' => array(), - 'indexes' => array(), - 'module' => 'geofield', - 'settings' => array(), - 'translatable' => '0', - 'type' => 'geofield', - ), - 'field_instance' => array( - 'bundle' => 'openlayers_example_content', - 'default_value' => NULL, - 'deleted' => '0', - 'description' => '', - 'display' => array( - 'default' => array( - 'label' => 'above', - 'module' => 'geofield', - 'settings' => array( - 'data' => 'full', - ), - 'type' => 'geofield_wkt', - 'weight' => '1', - ), - 'teaser' => array( - 'label' => 'above', - 'settings' => array(), - 'type' => 'hidden', - 'weight' => 0, - ), - ), - 'entity_type' => 'node', - 'field_name' => 'field_openlayers_example_input', - 'label' => 'OpenLayers Example Geofield Input', - 'required' => 0, - 'settings' => array( - 'local_solr' => array( - 'enabled' => FALSE, - 'lat_field' => 'lat', - 'lng_field' => 'lng', - ), - 'user_register_form' => FALSE, - ), - 'widget' => array( - 'active' => 1, - 'module' => 'geofield', - 'settings' => array( - 'data_storage' => 'collection', - 'openlayers_map' => 'geofield_widget_map', - ), - 'type' => 'geofield_openlayers', - 'weight' => '1', - ), - ), - ); - - // Translatables - // Included for use with string extractors like potx. - t('Body'); - t('OpenLayers Example Geofield Input'); - - return $fields; -} diff --git a/tests/features/openlayers_test_example_feature/openlayers_test_example_feature.features.inc b/tests/features/openlayers_test_example_feature/openlayers_test_example_feature.features.inc deleted file mode 100644 index a9fe2d39fe4c90a5ac55b4e0e98b39d352feb479..0000000000000000000000000000000000000000 --- a/tests/features/openlayers_test_example_feature/openlayers_test_example_feature.features.inc +++ /dev/null @@ -1,36 +0,0 @@ - "1"); -} - -/** - * Implements hook_views_api(). - */ -function openlayers_test_example_feature_views_api() { - return array("version" => "3.0"); -} - -/** - * Implements hook_node_info(). - */ -function openlayers_test_example_feature_node_info() { - $items = array( - 'openlayers_example_content' => array( - 'name' => t('OpenLayers Example Content'), - 'base' => 'node_content', - 'description' => t('This is an example content type for the OpenLayers module.'), - 'has_title' => '1', - 'title_label' => t('Title'), - 'help' => '', - ), - ); - return $items; -} diff --git a/tests/features/openlayers_test_example_feature/openlayers_test_example_feature.info b/tests/features/openlayers_test_example_feature/openlayers_test_example_feature.info deleted file mode 100644 index add2fae08c5d5d119238f6776f35142e0e97530c..0000000000000000000000000000000000000000 --- a/tests/features/openlayers_test_example_feature/openlayers_test_example_feature.info +++ /dev/null @@ -1,24 +0,0 @@ -name = "OpenLayers Test Example Feature" -description = "Feature to hold OpenLayers configuration example." -core = "7.x" -package = "OpenLayers" -php = "5.2.4" -version = "7.x-2.0" -project = "openlayers_test_example_feature" -dependencies[] = "ctools" -dependencies[] = "features" -dependencies[] = "field_sql_storage" -dependencies[] = "geofield" -dependencies[] = "node" -dependencies[] = "openlayers" -dependencies[] = "text" -dependencies[] = "views" -features[ctools][] = "openlayers:openlayers_maps:1" -features[ctools][] = "views:views_default:3.0" -features[field][] = "node-openlayers_example_content-body" -features[field][] = "node-openlayers_example_content-field_openlayers_example_input" -features[node][] = "openlayers_example_content" -features[openlayers_maps][] = "openlayers_test_openlayers_example_map" -features[views_view][] = "openlayers_example_data_overlay" -features[views_view][] = "openlayers_example_map_display_view" -project status url = "http://drupal.org/project/openlayers" diff --git a/tests/features/openlayers_test_example_feature/openlayers_test_example_feature.module b/tests/features/openlayers_test_example_feature/openlayers_test_example_feature.module deleted file mode 100644 index 643c0613b74b09c6754fe89c284681883b9903cb..0000000000000000000000000000000000000000 --- a/tests/features/openlayers_test_example_feature/openlayers_test_example_feature.module +++ /dev/null @@ -1,7 +0,0 @@ -disabled = FALSE; /* Edit this to true to make a default openlayers_maps disabled initially */ - $openlayers_maps->api_version = 1; - $openlayers_maps->name = 'openlayers_test_openlayers_example_map'; - $openlayers_maps->title = 'Example Map of Example Content'; - $openlayers_maps->description = 'Example map of OpenLayers Example Content.'; - $openlayers_maps->data = array( - 'width' => 'auto', - 'height' => '400px', - 'image_path' => 'sites/all/modules/openlayers/themes/default_dark/img/', - 'css_path' => 'sites/all/modules/openlayers/themes/default_dark/style.css', - 'proxy_host' => 'proxy?request=', - 'hide_empty_map' => 0, - 'center' => array( - 'initial' => array( - 'centerpoint' => '0,0', - 'zoom' => '2', - ), - 'restrict' => array( - 'restrictextent' => 0, - 'restrictedExtent' => '', - ), - ), - 'behaviors' => array( - 'openlayers_behavior_keyboarddefaults' => array(), - 'openlayers_behavior_attribution' => array( - 'separator' => '', - ), - 'openlayers_behavior_layerswitcher' => array( - 'ascending' => 1, - 'roundedCorner' => 1, - 'roundedCornerColor' => '#222222', - 'maximizeDefault' => 0, - ), - 'openlayers_behavior_navigation' => array( - 'zoomWheelEnabled' => 1, - 'zoomBoxEnabled' => 1, - 'documentDrag' => 0, - ), - 'openlayers_behavior_panzoom' => array(), - 'openlayers_behavior_popup' => array( - 'layers' => array( - 'openlayers_example_data_overlay_openlayers_1' => 'openlayers_example_data_overlay_openlayers_1', - ), - ), - 'openlayers_behavior_zoomtolayer' => array( - 'zoomtolayer' => 'openlayers_example_data_overlay_openlayers_1', - 'point_zoom_level' => '5', - 'zoomtolayer_scale' => '1', - ), - ), - 'default_layer' => 'mapquest_osm', - 'layers' => array( - 'mapquest_osm' => 'mapquest_osm', - 'mapquest_openaerial' => 'mapquest_openaerial', - 'openlayers_example_data_overlay_openlayers_1' => 'openlayers_example_data_overlay_openlayers_1', - ), - 'layer_weight' => array( - 'geo_nodes_data_overlay_openlayers_1' => '0', - 'views_geojson_example_page_1' => '0', - 'openlayers_example_data_overlay_openlayers_1' => '0', - 'test_geojson_direct_data' => '0', - 'test_geojson_url' => '0', - 'openlayers_geojson_picture_this' => '0', - 'test_kml_url' => '0', - 'geofield_formatter' => '0', - ), - 'layer_styles' => array( - 'geofield_formatter' => '0', - 'openlayers_geojson_picture_this' => '0', - 'test_kml_url' => '0', - 'test_geojson_url' => '0', - 'test_geojson_direct_data' => '0', - 'geo_nodes_data_overlay_openlayers_1' => '0', - 'views_geojson_example_page_1' => '0', - 'openlayers_example_data_overlay_openlayers_1' => 'default_marker_green', - ), - 'layer_styles_select' => array( - 'geofield_formatter' => '0', - 'openlayers_geojson_picture_this' => '0', - 'test_kml_url' => '0', - 'test_geojson_url' => '0', - 'test_geojson_direct_data' => '0', - 'geo_nodes_data_overlay_openlayers_1' => '0', - 'views_geojson_example_page_1' => '0', - 'openlayers_example_data_overlay_openlayers_1' => 'default_marker_gold', - ), - 'layer_activated' => array( - 'openlayers_example_data_overlay_openlayers_1' => 'openlayers_example_data_overlay_openlayers_1', - 'geofield_formatter' => 0, - 'openlayers_geojson_picture_this' => 0, - 'test_kml_url' => 0, - 'test_geojson_url' => 0, - 'test_geojson_direct_data' => 0, - 'geo_nodes_data_overlay_openlayers_1' => 0, - 'views_geojson_example_page_1' => 0, - ), - 'layer_switcher' => array( - 'openlayers_example_data_overlay_openlayers_1' => 'openlayers_example_data_overlay_openlayers_1', - 'geofield_formatter' => 0, - 'openlayers_geojson_picture_this' => 0, - 'test_kml_url' => 0, - 'test_geojson_url' => 0, - 'test_geojson_direct_data' => 0, - 'geo_nodes_data_overlay_openlayers_1' => 0, - 'views_geojson_example_page_1' => 0, - ), - 'projection' => 'EPSG:900913', - 'displayProjection' => 'EPSG:4326', - 'styles' => array( - 'default' => 'default', - 'select' => 'default_select', - 'temporary' => 'default', - ), - ); - $export['openlayers_test_openlayers_example_map'] = $openlayers_maps; - - return $export; -} diff --git a/tests/features/openlayers_test_example_feature/openlayers_test_example_feature.views_default.inc b/tests/features/openlayers_test_example_feature/openlayers_test_example_feature.views_default.inc deleted file mode 100644 index c2a3c8fff0f670c1be085ed90803c4981ebb5a98..0000000000000000000000000000000000000000 --- a/tests/features/openlayers_test_example_feature/openlayers_test_example_feature.views_default.inc +++ /dev/null @@ -1,202 +0,0 @@ -name = 'openlayers_example_data_overlay'; - $view->description = 'This is an example OpenLayers Data Overlay using the OpenLayers Example Content'; - $view->tag = 'default'; - $view->base_table = 'node'; - $view->human_name = 'OpenLayers Example Data Overlay'; - $view->core = 7; - $view->api_version = '3.0'; - $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */ - - /* Display: Master */ - $handler = $view->new_display('default', 'Master', 'default'); - $handler->display->display_options['title'] = 'OpenLayers Example Content'; - $handler->display->display_options['access']['type'] = 'perm'; - $handler->display->display_options['cache']['type'] = 'none'; - $handler->display->display_options['query']['type'] = 'views_query'; - $handler->display->display_options['query']['options']['query_comment'] = FALSE; - $handler->display->display_options['exposed_form']['type'] = 'basic'; - $handler->display->display_options['pager']['type'] = 'full'; - $handler->display->display_options['pager']['options']['items_per_page'] = '100'; - $handler->display->display_options['pager']['options']['offset'] = '0'; - $handler->display->display_options['pager']['options']['id'] = '0'; - $handler->display->display_options['pager']['options']['expose']['items_per_page_options_all'] = 0; - $handler->display->display_options['style_plugin'] = 'openlayers_data'; - $handler->display->display_options['style_options']['data_source'] = array( - 'value' => 'wkt', - 'other_lat' => 'title', - 'other_lon' => 'title', - 'wkt' => 'field_openlayers_example_input', - 'other_top' => 'title', - 'other_right' => 'title', - 'other_bottom' => 'title', - 'other_left' => 'title', - 'name_field' => 'title', - 'description_field' => 'body', - 'view_mode' => 'full', - ); - $handler->display->display_options['row_plugin'] = 'fields'; - /* Field: Content: Title */ - $handler->display->display_options['fields']['title']['id'] = 'title'; - $handler->display->display_options['fields']['title']['table'] = 'node'; - $handler->display->display_options['fields']['title']['field'] = 'title'; - $handler->display->display_options['fields']['title']['label'] = ''; - $handler->display->display_options['fields']['title']['alter']['alter_text'] = 0; - $handler->display->display_options['fields']['title']['alter']['make_link'] = 0; - $handler->display->display_options['fields']['title']['alter']['absolute'] = 0; - $handler->display->display_options['fields']['title']['alter']['word_boundary'] = 0; - $handler->display->display_options['fields']['title']['alter']['ellipsis'] = 0; - $handler->display->display_options['fields']['title']['alter']['strip_tags'] = 0; - $handler->display->display_options['fields']['title']['alter']['trim'] = 0; - $handler->display->display_options['fields']['title']['alter']['html'] = 0; - $handler->display->display_options['fields']['title']['hide_empty'] = 0; - $handler->display->display_options['fields']['title']['empty_zero'] = 0; - $handler->display->display_options['fields']['title']['link_to_node'] = 1; - /* Field: Content: Body */ - $handler->display->display_options['fields']['body']['id'] = 'body'; - $handler->display->display_options['fields']['body']['table'] = 'field_data_body'; - $handler->display->display_options['fields']['body']['field'] = 'body'; - $handler->display->display_options['fields']['body']['label'] = ''; - $handler->display->display_options['fields']['body']['alter']['alter_text'] = 0; - $handler->display->display_options['fields']['body']['alter']['make_link'] = 0; - $handler->display->display_options['fields']['body']['alter']['absolute'] = 0; - $handler->display->display_options['fields']['body']['alter']['external'] = 0; - $handler->display->display_options['fields']['body']['alter']['replace_spaces'] = 0; - $handler->display->display_options['fields']['body']['alter']['trim_whitespace'] = 0; - $handler->display->display_options['fields']['body']['alter']['nl2br'] = 0; - $handler->display->display_options['fields']['body']['alter']['word_boundary'] = 1; - $handler->display->display_options['fields']['body']['alter']['ellipsis'] = 1; - $handler->display->display_options['fields']['body']['alter']['more_link'] = 0; - $handler->display->display_options['fields']['body']['alter']['strip_tags'] = 0; - $handler->display->display_options['fields']['body']['alter']['trim'] = 0; - $handler->display->display_options['fields']['body']['alter']['html'] = 0; - $handler->display->display_options['fields']['body']['element_label_colon'] = FALSE; - $handler->display->display_options['fields']['body']['element_default_classes'] = 1; - $handler->display->display_options['fields']['body']['hide_empty'] = 0; - $handler->display->display_options['fields']['body']['empty_zero'] = 0; - $handler->display->display_options['fields']['body']['hide_alter_empty'] = 1; - $handler->display->display_options['fields']['body']['field_api_classes'] = 0; - /* Field: Content: OpenLayers Example Geofield Input */ - $handler->display->display_options['fields']['field_openlayers_example_input']['id'] = 'field_openlayers_example_input'; - $handler->display->display_options['fields']['field_openlayers_example_input']['table'] = 'field_data_field_openlayers_example_input'; - $handler->display->display_options['fields']['field_openlayers_example_input']['field'] = 'field_openlayers_example_input'; - $handler->display->display_options['fields']['field_openlayers_example_input']['label'] = ''; - $handler->display->display_options['fields']['field_openlayers_example_input']['alter']['alter_text'] = 0; - $handler->display->display_options['fields']['field_openlayers_example_input']['alter']['make_link'] = 0; - $handler->display->display_options['fields']['field_openlayers_example_input']['alter']['absolute'] = 0; - $handler->display->display_options['fields']['field_openlayers_example_input']['alter']['external'] = 0; - $handler->display->display_options['fields']['field_openlayers_example_input']['alter']['replace_spaces'] = 0; - $handler->display->display_options['fields']['field_openlayers_example_input']['alter']['trim_whitespace'] = 0; - $handler->display->display_options['fields']['field_openlayers_example_input']['alter']['nl2br'] = 0; - $handler->display->display_options['fields']['field_openlayers_example_input']['alter']['word_boundary'] = 1; - $handler->display->display_options['fields']['field_openlayers_example_input']['alter']['ellipsis'] = 1; - $handler->display->display_options['fields']['field_openlayers_example_input']['alter']['more_link'] = 0; - $handler->display->display_options['fields']['field_openlayers_example_input']['alter']['strip_tags'] = 0; - $handler->display->display_options['fields']['field_openlayers_example_input']['alter']['trim'] = 0; - $handler->display->display_options['fields']['field_openlayers_example_input']['alter']['html'] = 0; - $handler->display->display_options['fields']['field_openlayers_example_input']['element_label_colon'] = FALSE; - $handler->display->display_options['fields']['field_openlayers_example_input']['element_default_classes'] = 1; - $handler->display->display_options['fields']['field_openlayers_example_input']['hide_empty'] = 0; - $handler->display->display_options['fields']['field_openlayers_example_input']['empty_zero'] = 0; - $handler->display->display_options['fields']['field_openlayers_example_input']['hide_alter_empty'] = 1; - $handler->display->display_options['fields']['field_openlayers_example_input']['click_sort_column'] = 'wkt'; - $handler->display->display_options['fields']['field_openlayers_example_input']['settings'] = array( - 'data' => 'full', - ); - $handler->display->display_options['fields']['field_openlayers_example_input']['field_api_classes'] = 0; - /* Sort criterion: Content: Post date */ - $handler->display->display_options['sorts']['created']['id'] = 'created'; - $handler->display->display_options['sorts']['created']['table'] = 'node'; - $handler->display->display_options['sorts']['created']['field'] = 'created'; - $handler->display->display_options['sorts']['created']['order'] = 'DESC'; - /* Filter criterion: Content: Published */ - $handler->display->display_options['filters']['status']['id'] = 'status'; - $handler->display->display_options['filters']['status']['table'] = 'node'; - $handler->display->display_options['filters']['status']['field'] = 'status'; - $handler->display->display_options['filters']['status']['value'] = 1; - $handler->display->display_options['filters']['status']['group'] = 1; - $handler->display->display_options['filters']['status']['expose']['operator'] = FALSE; - /* Filter criterion: Content: Type */ - $handler->display->display_options['filters']['type']['id'] = 'type'; - $handler->display->display_options['filters']['type']['table'] = 'node'; - $handler->display->display_options['filters']['type']['field'] = 'type'; - $handler->display->display_options['filters']['type']['value'] = array( - 'openlayers_example_content' => 'openlayers_example_content', - ); - - /* Display: OpenLayers Example Data Overlay */ - $handler = $view->new_display('openlayers', 'OpenLayers Example Data Overlay', 'openlayers_1'); - $handler->display->display_options['defaults']['row_plugin'] = FALSE; - $handler->display->display_options['row_plugin'] = 'fields'; - $export['openlayers_example_data_overlay'] = $view; - - $view = new view; - $view->name = 'openlayers_example_map_display_view'; - $view->description = 'View to display the OpenLayers Example Map.'; - $view->tag = 'default'; - $view->base_table = 'node'; - $view->human_name = 'OpenLayers Example Map Display View'; - $view->core = 7; - $view->api_version = '3.0'; - $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */ - - /* Display: Master */ - $handler = $view->new_display('default', 'Master', 'default'); - $handler->display->display_options['title'] = 'OpenLayers Example Map Display View'; - $handler->display->display_options['access']['type'] = 'perm'; - $handler->display->display_options['cache']['type'] = 'none'; - $handler->display->display_options['query']['type'] = 'views_query'; - $handler->display->display_options['query']['options']['query_comment'] = FALSE; - $handler->display->display_options['exposed_form']['type'] = 'basic'; - $handler->display->display_options['pager']['type'] = 'full'; - $handler->display->display_options['pager']['options']['items_per_page'] = '10'; - $handler->display->display_options['style_plugin'] = 'openlayers_map'; - $handler->display->display_options['style_options']['map'] = 'openlayers_test_openlayers_example_map'; - /* Field: Content: Title */ - $handler->display->display_options['fields']['title']['id'] = 'title'; - $handler->display->display_options['fields']['title']['table'] = 'node'; - $handler->display->display_options['fields']['title']['field'] = 'title'; - $handler->display->display_options['fields']['title']['label'] = ''; - $handler->display->display_options['fields']['title']['alter']['alter_text'] = 0; - $handler->display->display_options['fields']['title']['alter']['make_link'] = 0; - $handler->display->display_options['fields']['title']['alter']['absolute'] = 0; - $handler->display->display_options['fields']['title']['alter']['word_boundary'] = 0; - $handler->display->display_options['fields']['title']['alter']['ellipsis'] = 0; - $handler->display->display_options['fields']['title']['alter']['strip_tags'] = 0; - $handler->display->display_options['fields']['title']['alter']['trim'] = 0; - $handler->display->display_options['fields']['title']['alter']['html'] = 0; - $handler->display->display_options['fields']['title']['hide_empty'] = 0; - $handler->display->display_options['fields']['title']['empty_zero'] = 0; - $handler->display->display_options['fields']['title']['link_to_node'] = 1; - /* Sort criterion: Content: Post date */ - $handler->display->display_options['sorts']['created']['id'] = 'created'; - $handler->display->display_options['sorts']['created']['table'] = 'node'; - $handler->display->display_options['sorts']['created']['field'] = 'created'; - $handler->display->display_options['sorts']['created']['order'] = 'DESC'; - /* Filter criterion: Content: Published */ - $handler->display->display_options['filters']['status']['id'] = 'status'; - $handler->display->display_options['filters']['status']['table'] = 'node'; - $handler->display->display_options['filters']['status']['field'] = 'status'; - $handler->display->display_options['filters']['status']['value'] = 1; - $handler->display->display_options['filters']['status']['group'] = 1; - $handler->display->display_options['filters']['status']['expose']['operator'] = FALSE; - - /* Display: OpenLayers Map Display */ - $handler = $view->new_display('page', 'OpenLayers Map Display', 'page'); - $handler->display->display_options['path'] = 'openlayers-example-map-display'; - $export['openlayers_example_map_display_view'] = $view; - - return $export; -} diff --git a/tests/includes/openlayers_test.layers.inc b/tests/includes/openlayers_test.layers.inc deleted file mode 100644 index ce3348f1c67557ec5b74d0a2191f3b5a2a4303fc..0000000000000000000000000000000000000000 --- a/tests/includes/openlayers_test.layers.inc +++ /dev/null @@ -1,158 +0,0 @@ -api_version = 1; - $layer->name = 'test_kml_url'; - $layer->title = t('KML Test URL'); - $layer->description = t('Testing KML layer via an URL.'); - $layer->data = array( - 'layer_type' => 'openlayers_layer_type_kml', - 'layer_handler' => 'kml', - 'projection' => array('EPSG:4326'), - 'isBaseLayer' => FALSE, - 'vector' => TRUE, - 'method' => 'file', - 'formatOptions' => array( - 'extractStyles' => TRUE, - 'extractTracks' => FALSE, - 'extractAttributes' => TRUE, - ), - 'url' => url(drupal_get_path('module', 'openlayers_test') . '/data/openlayers_test.kml'), - ); - $layers[$layer->name] = $layer; - - // GeoJSON example with URL - $layer = new stdClass(); - $layer->api_version = 1; - $layer->name = 'test_geojson_url'; - $layer->title = t('GeoJSON Test URL'); - $layer->description = t('Testing GeoJSON layer via an URL.'); - $layer->data = array( - 'layer_type' => 'openlayers_layer_type_geojson', - 'layer_handler' => 'geojson', - 'projection' => array('EPSG:4326'), - 'isBaseLayer' => FALSE, - 'vector' => TRUE, - 'url' => url(drupal_get_path('module', 'openlayers_test') . '/data/openlayers_test.json'), - ); - $layers[$layer->name] = $layer; - - // GeoJSON example with direct data - $layer = new stdClass(); - $layer->api_version = 1; - $layer->name = 'test_geojson_direct_data'; - $layer->title = t('GeoJSON Test Direct Data'); - $layer->description = t('Testing putting GeoJSON directly in layer.'); - $layer->data = array( - 'layer_type' => 'openlayers_layer_type_geojson', - 'layer_handler' => 'geojson', - 'projection' => array('EPSG:4326'), - 'isBaseLayer' => FALSE, - 'vector' => TRUE, - 'geojson_data' => ' -{ - "type": "Feature", - "properties": { - "name": "Hello, World", - "description": "This is a GeoJSON test with data directly in the layer." - }, - "geometry": { - "type": "Polygon", - "coordinates": [ - [ - [ - -17.578125, - -1.0546875 - ], - [ - -37.265625, - 3.1640625 - ], - [ - -54.140625, - -3.8671875 - ], - [ - -48.515625, - -20.0390625 - ], - [ - -30.9375, - -24.9609375 - ], - [ - -21.796875, - -29.1796875 - ], - [ - -23.90625, - -36.9140625 - ], - [ - -39.375, - -42.5390625 - ], - [ - -51.328125, - -44.6484375 - ], - [ - -50.625, - -52.3828125 - ], - [ - -28.125, - -48.8671875 - ], - [ - -13.359375, - -41.1328125 - ], - [ - -11.953125, - -24.9609375 - ], - [ - -28.125, - -15.8203125 - ], - [ - -44.296875, - -11.6015625 - ], - [ - -35.859375, - -1.7578125 - ], - [ - -23.203125, - -9.4921875 - ], - [ - -17.578125, - -1.0546875 - ] - ] - ] - }, - "crs": { - "type": "name", - "properties": { - "name": "urn:ogc:def:crs:OGC:1.3:CRS84" - } - } -} - ', - ); - $layers[$layer->name] = $layer; - - return $layers; -} diff --git a/tests/includes/openlayers_test.maps.inc b/tests/includes/openlayers_test.maps.inc deleted file mode 100644 index 7921aa3c0eff593e362c9a5fb0aa745834e166b6..0000000000000000000000000000000000000000 --- a/tests/includes/openlayers_test.maps.inc +++ /dev/null @@ -1,247 +0,0 @@ -api_version = 1; - $behaviors_test->name = 'behaviors_test'; - $behaviors_test->title = t('Test: Behaviors'); - $behaviors_test->description = t('This is a test map.'); - $behaviors_test->data = array( - 'projection' => 'EPSG:900913', - 'displayProjection' => 'EPSG:4326', - 'width' => 'auto', - 'default_layer' => 'osm_mapnik', - 'height' => '400px', - 'image_path' => drupal_get_path('module', 'openlayers') . '/themes/default_dark/img/', - 'css_path' => drupal_get_path('module', 'openlayers') . '/themes/default_dark/style.css', - 'center' => array( - 'initial' => array( - 'centerpoint' => '0,0', - 'zoom' => '2' - ) - ), - 'behaviors' => array( - 'openlayers_behavior_panzoombar' => array(), - 'openlayers_behavior_layerswitcher' => array(), - 'openlayers_behavior_attribution' => array(), - 'openlayers_behavior_keyboarddefaults' => array(), - 'openlayers_behavior_navigation' => array(), - 'openlayers_behavior_fullscreen' => array(), - 'openlayers_behavior_mouseposition' => array(), - 'openlayers_behavior_dragpan' => array(), - 'openlayers_behavior_boxselect' => array(), - 'openlayers_behavior_permalink' => array(), - 'openlayers_behavior_scaleline' => array(), - 'openlayers_behavior_zoombox' => array(), - 'openlayers_behavior_zoomtomaxextent' => array(), - ), - 'layers' => array( - 'osm_mapnik' => 'osm_mapnik', - ) - ); - $items['behaviors_test'] = $behaviors_test; - - // Map integrating a Views overlay - $openlayers_maps_cck_views = new stdClass; - $openlayers_maps_cck_views->api_version = 1; - $openlayers_maps_cck_views->name = 'openlayers_test_map_cck_views'; - $openlayers_maps_cck_views->title = 'Test: OpenLayers Test Views'; - $openlayers_maps_cck_views->description = 'This map tests a custom content type with a WKT field and a views layer.'; - $openlayers_maps_cck_views->data = array( - 'width' => 'auto', - 'height' => '400px', - 'image_path' => drupal_get_path('module', 'openlayers') . '/themes/default_dark/img/', - 'css_path' => drupal_get_path('module', 'openlayers') . '/themes/default_dark/style.css', - 'center' => array( - 'initial' => array( - 'centerpoint' => '0,0', - 'zoom' => '2', - ), - 'restrict' => array( - 'restrictextent' => 0, - 'restrictedExtent' => '', - ), - ), - 'behaviors' => array( - 'openlayers_behavior_attribution' => array(), - 'openlayers_behavior_keyboarddefaults' => array(), - 'openlayers_behavior_layerswitcher' => array(), - 'openlayers_behavior_navigation' => array(), - 'openlayers_behavior_panzoombar' => array(), - 'openlayers_behavior_popup' => array(), - ), - 'default_layer' => 'osm_mapnik', - 'layers' => array( - 'osm_mapnik' => 'osm_mapnik', - 'openlayers_test_view_openlayers_1' => 'openlayers_test_view_openlayers_1', - ), - 'layer_styles' => array(), - 'layer_activated' => array( - 'openlayers_test_view_openlayers_1' => 'openlayers_test_view_openlayers_1', - ), - 'layer_switcher' => array( - 'openlayers_test_view_openlayers_1' => 'openlayers_test_view_openlayers_1', - ), - 'projection' => 'EPSG:900913', - 'displayProjection' => 'EPSG:4326', - 'styles' => array( - 'default' => 'default', - 'select' => 'default', - 'temporary' => 'default', - ), - 'options' => NULL, - ); - - // GeoJSON example - $openlayers_maps = new stdClass; - $openlayers_maps->disabled = FALSE; - $openlayers_maps->api_version = 1; - $openlayers_maps->name = 'geojson'; - $openlayers_maps->title = 'Test: Using GeoJSON'; - $openlayers_maps->description = 'This map uses direct data in a GeoJSON layer, as well as a URL based GeoJSON layer.'; - $openlayers_maps->data = array( - 'width' => 'auto', - 'height' => '400px', - 'image_path' => drupal_get_path('module', 'openlayers') . '/themes/default_dark/img/', - 'css_path' => drupal_get_path('module', 'openlayers') . '/themes/default_dark/style.css', - 'center' => array( - 'initial' => array( - 'centerpoint' => '0,0', - 'zoom' => '2', - ), - 'restrict' => array( - 'restrictextent' => 0, - 'restrictedExtent' => '', - ), - ), - 'behaviors' => array( - 'openlayers_behavior_attribution' => array(), - 'openlayers_behavior_keyboarddefaults' => array(), - 'openlayers_behavior_layerswitcher' => array( - 'ascending' => 1, - 'roundedCorner' => 1, - 'roundedCornerColor' => '#222222', - ), - 'openlayers_behavior_navigation' => array( - 'zoomWheelEnabled' => 1, - 'documentDrag' => 0, - ), - 'openlayers_behavior_panzoombar' => array(), - 'openlayers_behavior_popup' => array( - 'layers' => array( - 'test_geojson_direct_data' => 'test_geojson_direct_data', - 'test_geojson_url' => 'test_geojson_url', - ), - ), - ), - 'default_layer' => 'mapquest_osm', - 'layers' => array( - 'mapquest_osm' => 'mapquest_osm', - 'mapquest_openaerial' => 'mapquest_openaerial', - 'test_geojson_direct_data' => 'test_geojson_direct_data', - 'test_geojson_url' => 'test_geojson_url', - ), - 'layer_styles' => array( - 'test_geojson_direct_data' => 'default', - 'test_geojson_url' => 'default_marker_blue', - ), - 'layer_styles_select' => array( - 'test_geojson_direct_data' => 'default_select', - 'test_geojson_url' => 'default_marker_green', - ), - 'projection' => 'EPSG:900913', - 'displayProjection' => 'EPSG:4326', - 'styles' => array( - 'default' => 'default', - 'select' => 'default_select', - 'temporary' => 'default', - ), - ); - $items[$openlayers_maps->name] = $openlayers_maps; - - // GeoJSON example - $openlayers_maps = new stdClass; - $openlayers_maps->disabled = FALSE; - $openlayers_maps->api_version = 1; - $openlayers_maps->name = 'kml'; - $openlayers_maps->title = 'Test: Using KML'; - $openlayers_maps->description = 'This map uses a KML feed.'; - $openlayers_maps->data = array( - 'width' => 'auto', - 'height' => '400px', - 'image_path' => drupal_get_path('module', 'openlayers') . '/themes/default_dark/img/', - 'css_path' => drupal_get_path('module', 'openlayers') . '/themes/default_dark/style.css', - 'center' => array( - 'initial' => array( - 'centerpoint' => '-122.08452530529, 37.421872987049', - 'zoom' => '17', - ), - 'restrict' => array( - 'restrictextent' => 0, - 'restrictedExtent' => '', - ), - ), - 'behaviors' => array( - 'openlayers_behavior_attribution' => array(), - 'openlayers_behavior_keyboarddefaults' => array(), - 'openlayers_behavior_layerswitcher' => array( - 'ascending' => 1, - 'roundedCorner' => 1, - 'roundedCornerColor' => '#222222', - ), - 'openlayers_behavior_navigation' => array( - 'zoomWheelEnabled' => 1, - 'documentDrag' => 0, - ), - 'openlayers_behavior_panzoombar' => array(), - 'openlayers_behavior_popup' => array( - 'layers' => array( - 'test_geojson_direct_data' => 'test_kml_url', - ), - ), - ), - 'default_layer' => 'mapquest_osm', - 'layers' => array( - 'mapquest_osm' => 'mapquest_osm', - 'mapquest_openaerial' => 'mapquest_openaerial', - 'test_kml_url' => 'test_kml_url', - ), - 'layer_styles' => array( - 'test_kml_url' => 'default', - ), - 'layer_styles_select' => array( - 'test_kml_url' => 'default_select', - ), - 'projection' => 'EPSG:900913', - 'displayProjection' => 'EPSG:4326', - 'styles' => array( - 'default' => 'default', - 'select' => 'default_select', - 'temporary' => 'default', - ), - ); - $items[$openlayers_maps->name] = $openlayers_maps; - - // We only want to provide the Views/CCK map if the - // modules are installed and the view is provide - if (module_exists('content') && module_exists('views') && module_exists('content_copy')) { - $layers = openlayers_layers_load(); - if (!empty($layers['openlayers_test_view_openlayers_1'])) { - $items['openlayers_test_map_cck_views'] = $openlayers_maps_cck_views; - } - } - - // Return maps - return $items; -} diff --git a/tests/includes/openlayers_test.pages.inc b/tests/includes/openlayers_test.pages.inc deleted file mode 100644 index b29e67fe8cf8155d4cf61c5ef93984597bc5867b..0000000000000000000000000000000000000000 --- a/tests/includes/openlayers_test.pages.inc +++ /dev/null @@ -1,64 +0,0 @@ - $map) { - $output .= ' -

' . $map->title . '

- ' . openlayers_render_map($map) . ' - '; - } - - /* - // Create collapsed fieldset - //$render_fieldset = openlayers_render_map(); - $element = array( - '#value' => $render_fieldset['themed'], - '#title' => t('Fieldset Example'), - '#collapsed' => TRUE, - '#collapsible' => TRUE, - ); - $fieldset = theme_fieldset($element); - */ - - return $output; -} - -/** - * Callback for OpenLayers Test JS Page - */ -function openlayers_test_js() { - drupal_add_js(drupal_get_path('module', 'openlayers_test') . '/js/qunit/qunit.js'); - drupal_add_css(drupal_get_path('module', 'openlayers_test') . '/js/qunit/qunit.css'); - drupal_add_js(drupal_get_path('module', 'openlayers_test') . '/js/openlayers_test.js'); - $output = ''; - - // Display QUnit stuff - $output .= ' -

OpenLayers QUnit Tests

-

-

-
    - '; - - // Render only specific maps - $maps = array('default', 'behaviors_test'); - foreach ($maps as $name => $map) { - $output .= ' - ' . openlayers_render_map($map) . ' - '; - } - - return $output; -} \ No newline at end of file diff --git a/tests/includes/openlayers_test.views.inc b/tests/includes/openlayers_test.views.inc deleted file mode 100644 index e6ebe974de57f0dc2c7a07007252cd69809cf080..0000000000000000000000000000000000000000 --- a/tests/includes/openlayers_test.views.inc +++ /dev/null @@ -1,178 +0,0 @@ -name = 'openlayers_test_view'; - $view->description = 'OpenLayers Test View'; - $view->tag = ''; - $view->view_php = ''; - $view->base_table = 'node'; - $view->is_cacheable = FALSE; - $view->api_version = 2; - $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */ - $handler = $view->new_display('default', 'OpenLayers Test View Default Display', 'default'); - $handler->override_option('fields', array( - 'field_openlayers_test_wkt_openlayers_wkt' => array( - 'label' => '', - 'alter' => array( - 'alter_text' => 0, - 'text' => '', - 'make_link' => 0, - 'path' => '', - 'link_class' => '', - 'alt' => '', - 'prefix' => '', - 'suffix' => '', - 'target' => '', - 'help' => '', - 'trim' => 0, - 'max_length' => '', - 'word_boundary' => 1, - 'ellipsis' => 1, - 'strip_tags' => 0, - 'html' => 0, - ), - 'empty' => '', - 'hide_empty' => 0, - 'empty_zero' => 0, - 'link_to_node' => 0, - 'label_type' => 'none', - 'format' => 'openlayers_wkt', - 'multiple' => array( - 'group' => TRUE, - 'multiple_number' => '', - 'multiple_from' => '', - 'multiple_reversed' => FALSE, - ), - 'exclude' => 0, - 'id' => 'field_openlayers_test_wkt_openlayers_wkt', - 'table' => 'node_data_field_openlayers_test_wkt', - 'field' => 'field_openlayers_test_wkt_openlayers_wkt', - 'relationship' => 'none', - ), - 'teaser' => array( - 'label' => '', - 'alter' => array( - 'alter_text' => 0, - 'text' => '', - 'make_link' => 0, - 'path' => '', - 'link_class' => '', - 'alt' => '', - 'prefix' => '', - 'suffix' => '', - 'target' => '', - 'help' => '', - 'trim' => 0, - 'max_length' => '', - 'word_boundary' => 1, - 'ellipsis' => 1, - 'strip_tags' => 0, - 'html' => 0, - ), - 'empty' => '', - 'hide_empty' => 0, - 'empty_zero' => 0, - 'exclude' => 0, - 'id' => 'teaser', - 'table' => 'node_revisions', - 'field' => 'teaser', - 'relationship' => 'none', - ), - 'title' => array( - 'label' => '', - 'alter' => array( - 'alter_text' => 0, - 'text' => '', - 'make_link' => 0, - 'path' => '', - 'link_class' => '', - 'alt' => '', - 'prefix' => '', - 'suffix' => '', - 'target' => '', - 'help' => '', - 'trim' => 0, - 'max_length' => '', - 'word_boundary' => 1, - 'ellipsis' => 1, - 'strip_tags' => 0, - 'html' => 0, - ), - 'empty' => '', - 'hide_empty' => 0, - 'empty_zero' => 0, - 'link_to_node' => 1, - 'exclude' => 0, - 'id' => 'title', - 'table' => 'node', - 'field' => 'title', - 'relationship' => 'none', - ), - )); - $handler->override_option('filters', array( - 'type' => array( - 'operator' => 'in', - 'value' => array( - 'openlayers_test_type' => 'openlayers_test_type', - ), - 'group' => '0', - 'exposed' => FALSE, - 'expose' => array( - 'operator' => FALSE, - 'label' => '', - ), - 'id' => 'type', - 'table' => 'node', - 'field' => 'type', - 'relationship' => 'none', - ), - )); - $handler->override_option('access', array( - 'type' => 'none', - )); - $handler->override_option('cache', array( - 'type' => 'none', - )); - $handler->override_option('title', 'OpenLayers Test View Layer'); - $handler->override_option('items_per_page', 200); - $handler->override_option('style_plugin', 'openlayers_data'); - $handler->override_option('style_options', array( - 'grouping' => '', - 'data_source' => array( - 'value' => array( - 'openlayers_wkt' => 'openlayers_wkt', - ), - 'other_lat' => 'field_openlayers_test_wkt_openlayers_wkt', - 'other_lon' => 'field_openlayers_test_wkt_openlayers_wkt', - 'openlayers_wkt' => 'field_openlayers_test_wkt_openlayers_wkt', - 'other_top' => 'field_openlayers_test_wkt_openlayers_wkt', - 'other_right' => 'field_openlayers_test_wkt_openlayers_wkt', - 'other_bottom' => 'field_openlayers_test_wkt_openlayers_wkt', - 'other_left' => 'field_openlayers_test_wkt_openlayers_wkt', - 'name_field' => 'title', - 'description_field' => 'teaser', - ), - )); - $handler = $view->new_display('openlayers', 'OpenLayers Test View OpenLayers Display', 'openlayers_1'); - $handler->override_option('row_plugin', ''); - $handler->override_option('displays', array()); - - // Return - $views['openlayers_test_view'] = $view; - return $views; - } - } -} diff --git a/tests/js/openlayers_test.js b/tests/js/openlayers_test.js deleted file mode 100644 index 6811e500a21d17e44b84e05d3728de59b7b51180..0000000000000000000000000000000000000000 --- a/tests/js/openlayers_test.js +++ /dev/null @@ -1,46 +0,0 @@ -/** - * @file - * OpenLayers JS test file, utilizing QUnit. - */ -(function ($) { - $(document).ready(function() { - module('Utility Functions'); - - // Test the relate path function - test('Testing Drupal.openlayers.relatePath correctness', function() { - var root_path = '/this/is/path.js'; - var domain_path = 'http://www.test.com/this/is/path.js'; - var relative_path = 'this/is/path.js'; - equals(root_path, - Drupal.openlayers.relatePath(root_path, 'foo'), 'Root path is correct' ); - equals(domain_path, - Drupal.openlayers.relatePath(domain_path, 'foo'), 'Domain path is correct' ); - equals('http://foo.com/this/is/path.js', - Drupal.openlayers.relatePath(relative_path, 'http://foo.com/'), 'Relative path is correct' )}); - - // Test the object from feature function - test('Testing object_from_feature correctness', function() { - var latlonobject = {lat: 5, lon: 10}; - var llobj = Drupal.openlayers.objectFromFeature(latlonobject); - equals(10, llobj.geometry.x, 'Latitude is correct'); - equals(5, llobj.geometry.y, 'Latitude is correct'); - - var wktobject = {wkt: 'POINT(50 40)'}; - var wktobj = Drupal.openlayers.objectFromFeature(wktobject); - - equals(50, wktobj.geometry.x, 'Latitude is correct'); - equals(40, wktobj.geometry.y, 'Latitude is correct'); - }); - - module('Rendering'); - test('Testing basic rendering', function() { - // Remove stop_render - $('.openlayers-map:not(.openlayers-processed)').each(function() { - var map_id = $(this).attr('id'); - Drupal.settings.openlayers.maps[map_id].stop_render = false; - Drupal.attachBehaviors($('body'), Drupal.settings); - ok($('#' + map_id).children().hasClass('olMapViewport'), 'Map ' + map_id + ' rendered'); - }); - }); - }); -})(jQuery); \ No newline at end of file diff --git a/tests/js/qunit/index.html b/tests/js/qunit/index.html deleted file mode 100644 index ca46a8657c6f1e2c957367c76d1cf6a112cf55ec..0000000000000000000000000000000000000000 --- a/tests/js/qunit/index.html +++ /dev/null @@ -1,81 +0,0 @@ - - - - OpenLayers Drupal Module JS Test Page - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    OpenLayers Tests

    -

    -

    -
      - -
      -
      -
      -
      -
      - - diff --git a/tests/js/qunit/qunit.css b/tests/js/qunit/qunit.css deleted file mode 100644 index 5714bf4a597e8d13ac34efdb7153ea3430f50f80..0000000000000000000000000000000000000000 --- a/tests/js/qunit/qunit.css +++ /dev/null @@ -1,119 +0,0 @@ - -ol#qunit-tests { - font-family:"Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial; - margin:0; - padding:0; - list-style-position:inside; - - font-size: smaller; -} -ol#qunit-tests li{ - padding:0.4em 0.5em 0.4em 2.5em; - border-bottom:1px solid #fff; - font-size:small; - list-style-position:inside; -} -ol#qunit-tests li ol{ - box-shadow: inset 0px 2px 13px #999; - -moz-box-shadow: inset 0px 2px 13px #999; - -webkit-box-shadow: inset 0px 2px 13px #999; - margin-top:0.5em; - margin-left:0; - padding:0.5em; - background-color:#fff; - border-radius:15px; - -moz-border-radius: 15px; - -webkit-border-radius: 15px; -} -ol#qunit-tests li li{ - border-bottom:none; - margin:0.5em; - background-color:#fff; - list-style-position: inside; - padding:0.4em 0.5em 0.4em 0.5em; -} - -ol#qunit-tests li li.pass{ - border-left:26px solid #C6E746; - background-color:#fff; - color:#5E740B; - } -ol#qunit-tests li li.fail{ - border-left:26px solid #EE5757; - background-color:#fff; - color:#710909; -} -ol#qunit-tests li.pass{ - background-color:#D2E0E6; - color:#528CE0; -} -ol#qunit-tests li.fail{ - background-color:#EE5757; - color:#000; -} -ol#qunit-tests li strong { - cursor:pointer; -} -h1#qunit-header{ - background-color:#0d3349; - margin:0; - padding:0.5em 0 0.5em 1em; - color:#fff; - font-family:"Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial; - border-top-right-radius:15px; - border-top-left-radius:15px; - -moz-border-radius-topright:15px; - -moz-border-radius-topleft:15px; - -webkit-border-top-right-radius:15px; - -webkit-border-top-left-radius:15px; - text-shadow: rgba(0, 0, 0, 0.5) 4px 4px 1px; -} -h2#qunit-banner{ - font-family:"Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial; - height:5px; - margin:0; - padding:0; -} -h2#qunit-banner.qunit-pass{ - background-color:#C6E746; -} -h2#qunit-banner.qunit-fail, #qunit-testrunner-toolbar { - background-color:#EE5757; -} -#qunit-testrunner-toolbar { - font-family:"Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial; - padding:0; - /*width:80%;*/ - padding:0em 0 0.5em 2em; - font-size: small; -} -h2#qunit-userAgent { - font-family:"Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial; - background-color:#2b81af; - margin:0; - padding:0; - color:#fff; - font-size: small; - padding:0.5em 0 0.5em 2.5em; - text-shadow: rgba(0, 0, 0, 0.5) 2px 2px 1px; -} -p#qunit-testresult{ - font-family:"Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial; - margin:0; - font-size: small; - color:#2b81af; - border-bottom-right-radius:15px; - border-bottom-left-radius:15px; - -moz-border-radius-bottomright:15px; - -moz-border-radius-bottomleft:15px; - -webkit-border-bottom-right-radius:15px; - -webkit-border-bottom-left-radius:15px; - background-color:#D2E0E6; - padding:0.5em 0.5em 0.5em 2.5em; -} -strong b.fail{ - color:#710909; - } -strong b.pass{ - color:#5E740B; - } diff --git a/tests/js/qunit/qunit.js b/tests/js/qunit/qunit.js deleted file mode 100644 index 142ad726785c229c1c0f294a5419d154513d925f..0000000000000000000000000000000000000000 --- a/tests/js/qunit/qunit.js +++ /dev/null @@ -1,1042 +0,0 @@ -/* - * QUnit - A JavaScript Unit Testing Framework - * - * http://docs.jquery.com/QUnit - * - * Copyright (c) 2009 John Resig, Jörn Zaefferer - * Dual licensed under the MIT (MIT-LICENSE.txt) - * and GPL (GPL-LICENSE.txt) licenses. - */ - -(function(window) { - -var QUnit = { - - // Initialize the configuration options - init: function() { - config = { - stats: { all: 0, bad: 0 }, - moduleStats: { all: 0, bad: 0 }, - started: +new Date, - blocking: false, - autorun: false, - assertions: [], - filters: [], - queue: [] - }; - - var tests = id("qunit-tests"), - banner = id("qunit-banner"), - result = id("qunit-testresult"); - - if ( tests ) { - tests.innerHTML = ""; - } - - if ( banner ) { - banner.className = ""; - } - - if ( result ) { - result.parentNode.removeChild( result ); - } - }, - - // call on start of module test to prepend name to all tests - module: function(name, testEnvironment) { - config.currentModule = name; - - synchronize(function() { - if ( config.currentModule ) { - QUnit.moduleDone( config.currentModule, config.moduleStats.bad, config.moduleStats.all ); - } - - config.currentModule = name; - config.moduleTestEnvironment = testEnvironment; - config.moduleStats = { all: 0, bad: 0 }; - - QUnit.moduleStart( name, testEnvironment ); - }); - }, - - asyncTest: function(testName, expected, callback) { - if ( arguments.length === 2 ) { - callback = expected; - expected = 0; - } - - QUnit.test(testName, expected, callback, true); - }, - - test: function(testName, expected, callback, async) { - var name = testName, testEnvironment, testEnvironmentArg; - - if ( arguments.length === 2 ) { - callback = expected; - expected = null; - } - // is 2nd argument a testEnvironment? - if ( expected && typeof expected === 'object') { - testEnvironmentArg = expected; - expected = null; - } - - if ( config.currentModule ) { - name = config.currentModule + " module: " + name; - } - - if ( !validTest(name) ) { - return; - } - - synchronize(function() { - QUnit.testStart( testName ); - - testEnvironment = extend({ - setup: function() {}, - teardown: function() {} - }, config.moduleTestEnvironment); - if (testEnvironmentArg) { - extend(testEnvironment,testEnvironmentArg); - } - - // allow utility functions to access the current test environment - QUnit.current_testEnvironment = testEnvironment; - - config.assertions = []; - config.expected = expected; - - try { - if ( !config.pollution ) { - saveGlobal(); - } - - testEnvironment.setup.call(testEnvironment); - } catch(e) { - QUnit.ok( false, "Setup failed on " + name + ": " + e.message ); - } - - if ( async ) { - QUnit.stop(); - } - - try { - callback.call(testEnvironment); - } catch(e) { - fail("Test " + name + " died, exception and test follows", e, callback); - QUnit.ok( false, "Died on test #" + (config.assertions.length + 1) + ": " + e.message ); - // else next test will carry the responsibility - saveGlobal(); - - // Restart the tests if they're blocking - if ( config.blocking ) { - start(); - } - } - }); - - synchronize(function() { - try { - checkPollution(); - testEnvironment.teardown.call(testEnvironment); - } catch(e) { - QUnit.ok( false, "Teardown failed on " + name + ": " + e.message ); - } - - try { - QUnit.reset(); - } catch(e) { - fail("reset() failed, following Test " + name + ", exception and reset fn follows", e, reset); - } - - if ( config.expected && config.expected != config.assertions.length ) { - QUnit.ok( false, "Expected " + config.expected + " assertions, but " + config.assertions.length + " were run" ); - } - - var good = 0, bad = 0, - tests = id("qunit-tests"); - - config.stats.all += config.assertions.length; - config.moduleStats.all += config.assertions.length; - - if ( tests ) { - var ol = document.createElement("ol"); - ol.style.display = "none"; - - for ( var i = 0; i < config.assertions.length; i++ ) { - var assertion = config.assertions[i]; - - var li = document.createElement("li"); - li.className = assertion.result ? "pass" : "fail"; - li.appendChild(document.createTextNode(assertion.message || "(no message)")); - ol.appendChild( li ); - - if ( assertion.result ) { - good++; - } else { - bad++; - config.stats.bad++; - config.moduleStats.bad++; - } - } - - var b = document.createElement("strong"); - b.innerHTML = name + " (" + bad + ", " + good + ", " + config.assertions.length + ")"; - - addEvent(b, "click", function() { - var next = b.nextSibling, display = next.style.display; - next.style.display = display === "none" ? "block" : "none"; - }); - - addEvent(b, "dblclick", function(e) { - var target = e && e.target ? e.target : window.event.srcElement; - if ( target.nodeName.toLowerCase() === "strong" ) { - var text = "", node = target.firstChild; - - while ( node.nodeType === 3 ) { - text += node.nodeValue; - node = node.nextSibling; - } - - text = text.replace(/(^\s*|\s*$)/g, ""); - - if ( window.location ) { - window.location.href = window.location.href.match(/^(.+?)(\?.*)?$/)[1] + "?" + encodeURIComponent(text); - } - } - }); - - var li = document.createElement("li"); - li.className = bad ? "fail" : "pass"; - li.appendChild( b ); - li.appendChild( ol ); - tests.appendChild( li ); - - if ( bad ) { - var toolbar = id("qunit-testrunner-toolbar"); - if ( toolbar ) { - toolbar.style.display = "block"; - id("qunit-filter-pass").disabled = null; - id("qunit-filter-missing").disabled = null; - } - } - - } else { - for ( var i = 0; i < config.assertions.length; i++ ) { - if ( !config.assertions[i].result ) { - bad++; - config.stats.bad++; - config.moduleStats.bad++; - } - } - } - - QUnit.testDone( testName, bad, config.assertions.length ); - - if ( !window.setTimeout && !config.queue.length ) { - done(); - } - }); - - if ( window.setTimeout && !config.doneTimer ) { - config.doneTimer = window.setTimeout(function(){ - if ( !config.queue.length ) { - done(); - } else { - synchronize( done ); - } - }, 13); - } - }, - - /** - * Specify the number of expected assertions to gurantee that failed test (no assertions are run at all) don't slip through. - */ - expect: function(asserts) { - config.expected = asserts; - }, - - /** - * Asserts true. - * @example ok( "asdfasdf".length > 5, "There must be at least 5 chars" ); - */ - ok: function(a, msg) { - QUnit.log(a, msg); - - config.assertions.push({ - result: !!a, - message: msg - }); - }, - - /** - * Checks that the first two arguments are equal, with an optional message. - * Prints out both actual and expected values. - * - * Prefered to ok( actual == expected, message ) - * - * @example equal( format("Received {0} bytes.", 2), "Received 2 bytes." ); - * - * @param Object actual - * @param Object expected - * @param String message (optional) - */ - equal: function(actual, expected, message) { - push(expected == actual, actual, expected, message); - }, - - notEqual: function(actual, expected, message) { - push(expected != actual, actual, expected, message); - }, - - deepEqual: function(a, b, message) { - push(QUnit.equiv(a, b), a, b, message); - }, - - notDeepEqual: function(a, b, message) { - push(!QUnit.equiv(a, b), a, b, message); - }, - - strictEqual: function(actual, expected, message) { - push(expected === actual, actual, expected, message); - }, - - notStrictEqual: function(actual, expected, message) { - push(expected !== actual, actual, expected, message); - }, - - start: function() { - // A slight delay, to avoid any current callbacks - if ( window.setTimeout ) { - window.setTimeout(function() { - if ( config.timeout ) { - clearTimeout(config.timeout); - } - - config.blocking = false; - process(); - }, 13); - } else { - config.blocking = false; - process(); - } - }, - - stop: function(timeout) { - config.blocking = true; - - if ( timeout && window.setTimeout ) { - config.timeout = window.setTimeout(function() { - QUnit.ok( false, "Test timed out" ); - QUnit.start(); - }, timeout); - } - }, - - /** - * Resets the test setup. Useful for tests that modify the DOM. - */ - reset: function() { - if ( window.jQuery ) { - jQuery("#main").html( config.fixture ); - jQuery.event.global = {}; - jQuery.ajaxSettings = extend({}, config.ajaxSettings); - } - }, - - /** - * Trigger an event on an element. - * - * @example triggerEvent( document.body, "click" ); - * - * @param DOMElement elem - * @param String type - */ - triggerEvent: function( elem, type, event ) { - if ( document.createEvent ) { - event = document.createEvent("MouseEvents"); - event.initMouseEvent(type, true, true, elem.ownerDocument.defaultView, - 0, 0, 0, 0, 0, false, false, false, false, 0, null); - elem.dispatchEvent( event ); - - } else if ( elem.fireEvent ) { - elem.fireEvent("on"+type); - } - }, - - // Safe object type checking - is: function( type, obj ) { - return Object.prototype.toString.call( obj ) === "[object "+ type +"]"; - }, - - // Logging callbacks - done: function(failures, total) {}, - log: function(result, message) {}, - testStart: function(name) {}, - testDone: function(name, failures, total) {}, - moduleStart: function(name, testEnvironment) {}, - moduleDone: function(name, failures, total) {} -}; - -// Backwards compatibility, deprecated -QUnit.equals = QUnit.equal; -QUnit.same = QUnit.deepEqual; - -// Maintain internal state -var config = { - // The queue of tests to run - queue: [], - - // block until document ready - blocking: true -}; - -// Load paramaters -(function() { - var location = window.location || { search: "", protocol: "file:" }, - GETParams = location.search.slice(1).split('&'); - - for ( var i = 0; i < GETParams.length; i++ ) { - GETParams[i] = decodeURIComponent( GETParams[i] ); - if ( GETParams[i] === "noglobals" ) { - GETParams.splice( i, 1 ); - i--; - config.noglobals = true; - } else if ( GETParams[i].search('=') > -1 ) { - GETParams.splice( i, 1 ); - i--; - } - } - - // restrict modules/tests by get parameters - config.filters = GETParams; - - // Figure out if we're running the tests from a server or not - QUnit.isLocal = !!(location.protocol === 'file:'); -})(); - -// Expose the API as global variables, unless an 'exports' -// object exists, in that case we assume we're in CommonJS -if ( typeof exports === "undefined" || typeof require === "undefined" ) { - extend(window, QUnit); - window.QUnit = QUnit; -} else { - extend(exports, QUnit); - exports.QUnit = QUnit; -} - -if ( typeof document === "undefined" || document.readyState === "complete" ) { - config.autorun = true; -} - -addEvent(window, "load", function() { - // Initialize the config, saving the execution queue - var oldconfig = extend({}, config); - QUnit.init(); - extend(config, oldconfig); - - config.blocking = false; - - var userAgent = id("qunit-userAgent"); - if ( userAgent ) { - userAgent.innerHTML = navigator.userAgent; - } - - var toolbar = id("qunit-testrunner-toolbar"); - if ( toolbar ) { - toolbar.style.display = "none"; - - var filter = document.createElement("input"); - filter.type = "checkbox"; - filter.id = "qunit-filter-pass"; - filter.disabled = true; - addEvent( filter, "click", function() { - var li = document.getElementsByTagName("li"); - for ( var i = 0; i < li.length; i++ ) { - if ( li[i].className.indexOf("pass") > -1 ) { - li[i].style.display = filter.checked ? "none" : ""; - } - } - }); - toolbar.appendChild( filter ); - - var label = document.createElement("label"); - label.setAttribute("for", "qunit-filter-pass"); - label.innerHTML = "Hide passed tests"; - toolbar.appendChild( label ); - - var missing = document.createElement("input"); - missing.type = "checkbox"; - missing.id = "qunit-filter-missing"; - missing.disabled = true; - addEvent( missing, "click", function() { - var li = document.getElementsByTagName("li"); - for ( var i = 0; i < li.length; i++ ) { - if ( li[i].className.indexOf("fail") > -1 && li[i].innerHTML.indexOf('missing test - untested code is broken code') > - 1 ) { - li[i].parentNode.parentNode.style.display = missing.checked ? "none" : "block"; - } - } - }); - toolbar.appendChild( missing ); - - label = document.createElement("label"); - label.setAttribute("for", "qunit-filter-missing"); - label.innerHTML = "Hide missing tests (untested code is broken code)"; - toolbar.appendChild( label ); - } - - var main = id('main'); - if ( main ) { - config.fixture = main.innerHTML; - } - - if ( window.jQuery ) { - config.ajaxSettings = window.jQuery.ajaxSettings; - } - - QUnit.start(); -}); - -function done() { - if ( config.doneTimer && window.clearTimeout ) { - window.clearTimeout( config.doneTimer ); - config.doneTimer = null; - } - - if ( config.queue.length ) { - config.doneTimer = window.setTimeout(function(){ - if ( !config.queue.length ) { - done(); - } else { - synchronize( done ); - } - }, 13); - - return; - } - - config.autorun = true; - - // Log the last module results - if ( config.currentModule ) { - QUnit.moduleDone( config.currentModule, config.moduleStats.bad, config.moduleStats.all ); - } - - var banner = id("qunit-banner"), - tests = id("qunit-tests"), - html = ['Tests completed in ', - +new Date - config.started, ' milliseconds.
      ', - '', config.stats.all - config.stats.bad, ' tests of ', config.stats.all, ' passed, ', config.stats.bad,' failed.'].join(''); - - if ( banner ) { - banner.className = (config.stats.bad ? "qunit-fail" : "qunit-pass"); - } - - if ( tests ) { - var result = id("qunit-testresult"); - - if ( !result ) { - result = document.createElement("p"); - result.id = "qunit-testresult"; - result.className = "result"; - tests.parentNode.insertBefore( result, tests.nextSibling ); - } - - result.innerHTML = html; - } - - QUnit.done( config.stats.bad, config.stats.all ); -} - -function validTest( name ) { - var i = config.filters.length, - run = false; - - if ( !i ) { - return true; - } - - while ( i-- ) { - var filter = config.filters[i], - not = filter.charAt(0) == '!'; - - if ( not ) { - filter = filter.slice(1); - } - - if ( name.indexOf(filter) !== -1 ) { - return !not; - } - - if ( not ) { - run = true; - } - } - - return run; -} - -function push(result, actual, expected, message) { - message = message || (result ? "okay" : "failed"); - QUnit.ok( result, result ? message + ": " + expected : message + ", expected: " + QUnit.jsDump.parse(expected) + " result: " + QUnit.jsDump.parse(actual) ); -} - -function synchronize( callback ) { - config.queue.push( callback ); - - if ( config.autorun && !config.blocking ) { - process(); - } -} - -function process() { - while ( config.queue.length && !config.blocking ) { - config.queue.shift()(); - } -} - -function saveGlobal() { - config.pollution = []; - - if ( config.noglobals ) { - for ( var key in window ) { - config.pollution.push( key ); - } - } -} - -function checkPollution( name ) { - var old = config.pollution; - saveGlobal(); - - var newGlobals = diff( old, config.pollution ); - if ( newGlobals.length > 0 ) { - ok( false, "Introduced global variable(s): " + newGlobals.join(", ") ); - config.expected++; - } - - var deletedGlobals = diff( config.pollution, old ); - if ( deletedGlobals.length > 0 ) { - ok( false, "Deleted global variable(s): " + deletedGlobals.join(", ") ); - config.expected++; - } -} - -// returns a new Array with the elements that are in a but not in b -function diff( a, b ) { - var result = a.slice(); - for ( var i = 0; i < result.length; i++ ) { - for ( var j = 0; j < b.length; j++ ) { - if ( result[i] === b[j] ) { - result.splice(i, 1); - i--; - break; - } - } - } - return result; -} - -function fail(message, exception, callback) { - if ( typeof console !== "undefined" && console.error && console.warn ) { - console.error(message); - console.error(exception); - console.warn(callback.toString()); - - } else if ( window.opera && opera.postError ) { - opera.postError(message, exception, callback.toString); - } -} - -function extend(a, b) { - for ( var prop in b ) { - a[prop] = b[prop]; - } - - return a; -} - -function addEvent(elem, type, fn) { - if ( elem.addEventListener ) { - elem.addEventListener( type, fn, false ); - } else if ( elem.attachEvent ) { - elem.attachEvent( "on" + type, fn ); - } else { - fn(); - } -} - -function id(name) { - return !!(typeof document !== "undefined" && document && document.getElementById) && - document.getElementById( name ); -} - -// Test for equality any JavaScript type. -// Discussions and reference: http://philrathe.com/articles/equiv -// Test suites: http://philrathe.com/tests/equiv -// Author: Philippe Rathé -QUnit.equiv = function () { - - var innerEquiv; // the real equiv function - var callers = []; // stack to decide between skip/abort functions - - - // Determine what is o. - function hoozit(o) { - if (QUnit.is("String", o)) { - return "string"; - - } else if (QUnit.is("Boolean", o)) { - return "boolean"; - - } else if (QUnit.is("Number", o)) { - - if (isNaN(o)) { - return "nan"; - } else { - return "number"; - } - - } else if (typeof o === "undefined") { - return "undefined"; - - // consider: typeof null === object - } else if (o === null) { - return "null"; - - // consider: typeof [] === object - } else if (QUnit.is( "Array", o)) { - return "array"; - - // consider: typeof new Date() === object - } else if (QUnit.is( "Date", o)) { - return "date"; - - // consider: /./ instanceof Object; - // /./ instanceof RegExp; - // typeof /./ === "function"; // => false in IE and Opera, - // true in FF and Safari - } else if (QUnit.is( "RegExp", o)) { - return "regexp"; - - } else if (typeof o === "object") { - return "object"; - - } else if (QUnit.is( "Function", o)) { - return "function"; - } else { - return undefined; - } - } - - // Call the o related callback with the given arguments. - function bindCallbacks(o, callbacks, args) { - var prop = hoozit(o); - if (prop) { - if (hoozit(callbacks[prop]) === "function") { - return callbacks[prop].apply(callbacks, args); - } else { - return callbacks[prop]; // or undefined - } - } - } - - var callbacks = function () { - - // for string, boolean, number and null - function useStrictEquality(b, a) { - if (b instanceof a.constructor || a instanceof b.constructor) { - // to catch short annotaion VS 'new' annotation of a declaration - // e.g. var i = 1; - // var j = new Number(1); - return a == b; - } else { - return a === b; - } - } - - return { - "string": useStrictEquality, - "boolean": useStrictEquality, - "number": useStrictEquality, - "null": useStrictEquality, - "undefined": useStrictEquality, - - "nan": function (b) { - return isNaN(b); - }, - - "date": function (b, a) { - return hoozit(b) === "date" && a.valueOf() === b.valueOf(); - }, - - "regexp": function (b, a) { - return hoozit(b) === "regexp" && - a.source === b.source && // the regex itself - a.global === b.global && // and its modifers (gmi) ... - a.ignoreCase === b.ignoreCase && - a.multiline === b.multiline; - }, - - // - skip when the property is a method of an instance (OOP) - // - abort otherwise, - // initial === would have catch identical references anyway - "function": function () { - var caller = callers[callers.length - 1]; - return caller !== Object && - typeof caller !== "undefined"; - }, - - "array": function (b, a) { - var i; - var len; - - // b could be an object literal here - if ( ! (hoozit(b) === "array")) { - return false; - } - - len = a.length; - if (len !== b.length) { // safe and faster - return false; - } - for (i = 0; i < len; i++) { - if ( ! innerEquiv(a[i], b[i])) { - return false; - } - } - return true; - }, - - "object": function (b, a) { - var i; - var eq = true; // unless we can proove it - var aProperties = [], bProperties = []; // collection of strings - - // comparing constructors is more strict than using instanceof - if ( a.constructor !== b.constructor) { - return false; - } - - // stack constructor before traversing properties - callers.push(a.constructor); - - for (i in a) { // be strict: don't ensures hasOwnProperty and go deep - - aProperties.push(i); // collect a's properties - - if ( ! innerEquiv(a[i], b[i])) { - eq = false; - } - } - - callers.pop(); // unstack, we are done - - for (i in b) { - bProperties.push(i); // collect b's properties - } - - // Ensures identical properties name - return eq && innerEquiv(aProperties.sort(), bProperties.sort()); - } - }; - }(); - - innerEquiv = function () { // can take multiple arguments - var args = Array.prototype.slice.apply(arguments); - if (args.length < 2) { - return true; // end transition - } - - return (function (a, b) { - if (a === b) { - return true; // catch the most you can - } else if (a === null || b === null || typeof a === "undefined" || typeof b === "undefined" || hoozit(a) !== hoozit(b)) { - return false; // don't lose time with error prone cases - } else { - return bindCallbacks(a, callbacks, [b, a]); - } - - // apply transition with (1..n) arguments - })(args[0], args[1]) && arguments.callee.apply(this, args.splice(1, args.length -1)); - }; - - return innerEquiv; - -}(); - -/** - * jsDump - * Copyright (c) 2008 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com - * Licensed under BSD (http://www.opensource.org/licenses/bsd-license.php) - * Date: 5/15/2008 - * @projectDescription Advanced and extensible data dumping for Javascript. - * @version 1.0.0 - * @author Ariel Flesler - * @link {http://flesler.blogspot.com/2008/05/jsdump-pretty-dump-of-any-javascript.html} - */ -QUnit.jsDump = (function() { - function quote( str ) { - return '"' + str.toString().replace(/"/g, '\\"') + '"'; - }; - function literal( o ) { - return o + ''; - }; - function join( pre, arr, post ) { - var s = jsDump.separator(), - base = jsDump.indent(), - inner = jsDump.indent(1); - if ( arr.join ) - arr = arr.join( ',' + s + inner ); - if ( !arr ) - return pre + post; - return [ pre, inner + arr, base + post ].join(s); - }; - function array( arr ) { - var i = arr.length, ret = Array(i); - this.up(); - while ( i-- ) - ret[i] = this.parse( arr[i] ); - this.down(); - return join( '[', ret, ']' ); - }; - - var reName = /^function (\w+)/; - - var jsDump = { - parse:function( obj, type ) { //type is used mostly internally, you can fix a (custom)type in advance - var parser = this.parsers[ type || this.typeOf(obj) ]; - type = typeof parser; - - return type == 'function' ? parser.call( this, obj ) : - type == 'string' ? parser : - this.parsers.error; - }, - typeOf:function( obj ) { - var type; - if ( obj === null ) { - type = "null"; - } else if (typeof obj === "undefined") { - type = "undefined"; - } else if (QUnit.is("RegExp", obj)) { - type = "regexp"; - } else if (QUnit.is("Date", obj)) { - type = "date"; - } else if (QUnit.is("Function", obj)) { - type = "function"; - } else if (QUnit.is("Array", obj)) { - type = "array"; - } else if (QUnit.is("Window", obj) || QUnit.is("global", obj)) { - type = "window"; - } else if (QUnit.is("HTMLDocument", obj)) { - type = "document"; - } else if (QUnit.is("HTMLCollection", obj) || QUnit.is("NodeList", obj)) { - type = "nodelist"; - } else if (/^\[object HTML/.test(Object.prototype.toString.call( obj ))) { - type = "node"; - } else { - type = typeof obj; - } - return type; - }, - separator:function() { - return this.multiline ? this.HTML ? '
      ' : '\n' : this.HTML ? ' ' : ' '; - }, - indent:function( extra ) {// extra can be a number, shortcut for increasing-calling-decreasing - if ( !this.multiline ) - return ''; - var chr = this.indentChar; - if ( this.HTML ) - chr = chr.replace(/\t/g,' ').replace(/ /g,' '); - return Array( this._depth_ + (extra||0) ).join(chr); - }, - up:function( a ) { - this._depth_ += a || 1; - }, - down:function( a ) { - this._depth_ -= a || 1; - }, - setParser:function( name, parser ) { - this.parsers[name] = parser; - }, - // The next 3 are exposed so you can use them - quote:quote, - literal:literal, - join:join, - // - _depth_: 1, - // This is the list of parsers, to modify them, use jsDump.setParser - parsers:{ - window: '[Window]', - document: '[Document]', - error:'[ERROR]', //when no parser is found, shouldn't happen - unknown: '[Unknown]', - 'null':'null', - undefined:'undefined', - 'function':function( fn ) { - var ret = 'function', - name = 'name' in fn ? fn.name : (reName.exec(fn)||[])[1];//functions never have name in IE - if ( name ) - ret += ' ' + name; - ret += '('; - - ret = [ ret, this.parse( fn, 'functionArgs' ), '){'].join(''); - return join( ret, this.parse(fn,'functionCode'), '}' ); - }, - array: array, - nodelist: array, - arguments: array, - object:function( map ) { - var ret = [ ]; - this.up(); - for ( var key in map ) - ret.push( this.parse(key,'key') + ': ' + this.parse(map[key]) ); - this.down(); - return join( '{', ret, '}' ); - }, - node:function( node ) { - var open = this.HTML ? '<' : '<', - close = this.HTML ? '>' : '>'; - - var tag = node.nodeName.toLowerCase(), - ret = open + tag; - - for ( var a in this.DOMAttrs ) { - var val = node[this.DOMAttrs[a]]; - if ( val ) - ret += ' ' + a + '=' + this.parse( val, 'attribute' ); - } - return ret + close + open + '/' + tag + close; - }, - functionArgs:function( fn ) {//function calls it internally, it's the arguments part of the function - var l = fn.length; - if ( !l ) return ''; - - var args = Array(l); - while ( l-- ) - args[l] = String.fromCharCode(97+l);//97 is 'a' - return ' ' + args.join(', ') + ' '; - }, - key:quote, //object calls it internally, the key part of an item in a map - functionCode:'[code]', //function calls it internally, it's the content of the function - attribute:quote, //node calls it internally, it's an html attribute value - string:quote, - date:quote, - regexp:literal, //regex - number:literal, - 'boolean':literal - }, - DOMAttrs:{//attributes to dump from nodes, name=>realName - id:'id', - name:'name', - 'class':'className' - }, - HTML:true,//if true, entities are escaped ( <, >, \t, space and \n ) - indentChar:' ',//indentation unit - multiline:true //if true, items in a collection, are separated by a \n, else just a space. - }; - - return jsDump; -})(); - -})(this); diff --git a/tests/openlayers.test b/tests/openlayers.test deleted file mode 100644 index ae6ab09f68eb15bd45b988ce31797a79302805d7..0000000000000000000000000000000000000000 --- a/tests/openlayers.test +++ /dev/null @@ -1,384 +0,0 @@ - 'OpenLayers Core', - 'description' => 'Tests OpenLayers core functions.', - 'group' => 'OpenLayers', - ); - } - - function setUp() { - // Install modules - parent::setUp('openlayers', 'ctools', 'openlayers_ui', 'openlayers_test'); - } - - /** - * Test openlayers_include - */ - function testInclude() { - $user = $this->drupalCreateUser(array('administer openlayers')); - $this->drupalLogin($user); - - // Go to test page and ensure includes happened. - $this->drupalGet('admin/structure/openlayers/test'); - $this->assertRaw('openlayers.css', t('The OpenLayers CSS file was included')); - $this->assertRaw('openlayers.js', t('The OpenLayers JS file was included')); - } - - /** - * Test map rendering - */ - function testRender() { - $rendered = openlayers_render_map(); - //$this->verbose('Map output: ' . var_export($rendered, TRUE)); - - // Check output - $this->assertTrue((stripos($rendered, 'default') !== FALSE), t('Default name found')); - $this->assertTrue((stripos($rendered, 'id="openlayers-container-openlayers-map') !== FALSE), - t('Container ID found')); - $this->assertTrue((stripos($rendered, 'id="openlayers-map') !== FALSE), - t('Map ID found')); - $this->assertTrue((stripos($rendered, 'class="openlayers-map') !== FALSE), - t('Map Class found')); - } -} - -/** - * Test OpenLayers basic UI - */ -class OpenLayersUI extends DrupalWebTestCase { - public static function getInfo() { - return array( - 'name' => 'OpenLayers UI', - 'description' => 'Tests OpenLayers basic UI.', - 'group' => 'OpenLayers', - ); - } - - function setUp() { - // Install modules - parent::setUp('openlayers', 'ctools', 'openlayers_ui', 'openlayers_test'); - } - - /** - * Ensure that the source can be updated - */ - function testSourceChange() { - $user = $this->drupalCreateUser(array('administer openlayers')); - $this->drupalLogin($user); - - // Update source settings - $new_openlayers_source = 'http://openlayers.org/nightly/OpenLayers.js'; - $openlayers_settings = array( - 'openlayers_source_type' => 'external', - 'openlayers_source_external' => $new_openlayers_source - ); - $this->drupalPost('admin/structure/openlayers', $openlayers_settings, t('Save configuration')); - // Go to map page - $this->drupalGet('admin/structure/openlayers'); - $this->assertResponse(200, t('User can reach the settings page.')); - // Check that the new source change is represented - $this->drupalGet('admin/structure/openlayers'); - $this->assertRaw($new_openlayers_source, t('The OpenLayers source was changed')); - } -} - -/** - * Test OpenLayers maps. - */ -class OpenLayersMaps extends DrupalWebTestCase { - public static function getInfo() { - return array( - 'name' => 'OpenLayers Maps', - 'description' => 'Tests the OpenLayers maps system.', - 'group' => 'OpenLayers', - ); - } - - function setUp() { - // Install modules - parent::setUp('openlayers', 'ctools', 'openlayers_ui', 'openlayers_test'); - } - - /** - * Ensure that the map shows up in the interface - */ - function testOpenLayersMaps() { - $user = $this->drupalCreateUser(array('administer openlayers')); - $this->drupalLogin($user); - - // Go to map page - $this->drupalGet('admin/structure/openlayers/maps'); - $this->assertResponse(200, t('User can reach map list.')); - - // Ensure that the default test is listed - $this->assertText(t('Default Map'), - t('Assert that the default map\'s title appears.')); - - // Maps - $this->drupalGet('admin/structure/openlayers/maps/default/export'); - $this->assertResponse(200, t('User can reach default map export page.')); - - $this->drupalGet('admin/structure/openlayers/maps/clone/default'); - $this->assertResponse(200, t('User can reach default map clone page.')); - - $this->drupalGet('admin/structure/openlayers/maps/add'); - $this->assertResponse(200, t('User can reach map add page.')); - } - - /** - * Add a new map - */ - function testMapAdd() { - $user = $this->drupalCreateUser(array('administer openlayers')); - $this->drupalLogin($user); - - // Add new map. Add scaleline so we can look for it later - $map_settings = array( - 'name' => 'testing_map', - 'title' => t('Testing Map'), - 'description' => t('Testing Map description.'), - 'behaviors[openlayers_behavior_scaleline][enabled]' => TRUE, - ); - $this->drupalPost('admin/structure/openlayers/maps/add', $map_settings, t('Save')); - $this->assertText(t('Map saved.'), t('The map was successfully saved.')); - - // Remove Map - $this->drupalPost('admin/structure/openlayers/maps/list/' . $map_settings['name'] . '/delete', - array(), t('Delete')); - $this->assertText('Map was deleted.', t('Map removed succesfully.')); - } -} - -/** - * Test OpenLayers styles. - */ -class OpenLayersStyles extends DrupalWebTestCase { - public static function getInfo() { - return array( - 'name' => 'OpenLayers Styles', - 'description' => 'Tests the OpenLayers Styles system.', - 'group' => 'OpenLayers', - ); - } - - function setUp() { - // Install modules - parent::setUp('openlayers', 'ctools', 'openlayers_ui', 'openlayers_test'); - } - - function testOpenLayersStyles() { - $user = $this->drupalCreateUser(array('administer openlayers')); - $this->drupalLogin($user); - - // New style. - $new_style = array( - 'name' => 'unitstyle', - 'title' => 'Unit Style', - 'description' => 'Unit Style for Drupal', - ); - - // Check basic navigation. - $this->drupalGet('admin/structure/openlayers/styles/list/default/export'); - $this->assertResponse(200, t('User can reach default style export page.')); - $this->drupalGet('admin/structure/openlayers/styles/add'); - $this->assertResponse(200, t('User can reach style add page.')); - - // Add new style. - $this->drupalPost('admin/structure/openlayers/styles/add', $new_style, t('Save')); - $this->assertText(t('Style saved.'), - t('The style was successfully saved.')); - - // Test that the style shows up in the style list. - $this->drupalGet('admin/structure/openlayers/styles'); - $this->assertRaw(t('Unit Style'), - t('A new style has been added by the test')); - - // Test removing style. - $this->drupalPost('admin/structure/openlayers/styles/list/unitstyle/delete', - array(), t('Delete')); - $this->assertText('Style was deleted.', - t('Style removed succesfully.')); - } -} - -/** - * Test OpenLayers layers. - */ -class OpenLayersLayers extends DrupalWebTestCase { - public static function getInfo() { - return array( - 'name' => 'OpenLayers Layers', - 'description' => 'Tests the OpenLayers Layers system.', - 'group' => 'OpenLayers', - ); - } - - function setUp() { - // Install modules - parent::setUp('openlayers', 'ctools', 'openlayers_ui', 'openlayers_test'); - } - - function testOpenLayersLayers() { - $user = $this->drupalCreateUser(array('administer openlayers')); - $this->drupalLogin($user); - - // New layers to add - $layer_inputs = array( - 'openlayers_layer_type_osm' => array( - 'name' => 'unitlayerosm', - 'title' => 'Unit Layer', - 'description' => 'Unit Layer for Drupal', - ), - 'openlayers_layer_type_xyz' => array( - 'name' => 'unitlayerxyz', - 'title' => 'Unit Layer', - 'description' => 'Unit Layer for Drupal', - ), - 'openlayers_layer_type_kml' => array( - 'name' => 'unitlayerkml', - 'title' => 'Unit Layer', - 'description' => 'Unit Layer for Drupal', - 'openlayers_layer_type_kml[method]' => 'raw', - 'openlayers_layer_type_kml[raw]' => $this->randomString(32) - ), - 'openlayers_layer_type_wms' => array( - 'name' => 'unitlayerwms', - 'title' => 'Unit Layer', - 'description' => 'Unit Layer for Drupal', - ), - 'openlayers_layer_type_cloudmade' => array( - 'name' => 'unitlayercloudmade', - 'title' => 'Unit Layer', - 'description' => 'Unit Layer for Drupal', - ), - 'openlayers_layer_type_bing' => array( - 'name' => 'unitlayerbing', - 'title' => 'Unit Layer', - 'description' => 'Unit Layer for Drupal', - ), - 'openlayers_layer_type_google' => array( - 'name' => 'unitlayergoogle', - 'title' => 'Unit Layer', - 'description' => 'Unit Layer for Drupal', - ) - ); - - // Basic navigation. - $this->drupalGet('admin/structure/openlayers/layers/add'); - $this->assertResponse(200, t('User can reach layer add page.')); - - // Go through each new layer for testing. - foreach ($layer_inputs as $layer_type => $input_data) { - // Test saving new layer. - $input_data['layer_type'] = $layer_type; - $this->drupalPost('admin/structure/openlayers/layers/add', - $input_data, t('Save')); - $this->assertText(t('Layer saved.'), - t('The layer was successfully saved.')); - - // Ensure that the layer shows up in the list. - $this->drupalGet('admin/structure/openlayers/layers'); - $this->assertRaw($input_data['title'], - t('A new layer of layer type %type_name has been added by the test', - array('%type_name' => $layer_type))); - - // Test removing layer. - $this->drupalPost('admin/structure/openlayers/layers/list/' . - $input_data['name'] . '/delete', array(), t('Delete')); - $this->assertText('Layer was deleted.', - t('Layer removed succesfully.')); - } - } -} - -/** - * Test Case for Map Alters - */ -class OpenLayersMapAlters extends DrupalWebTestCase { - public static function getInfo() { - return array( - 'name' => 'OpenLayers Map Alters', - 'description' => 'Tests the OpenLayers map alter hooks.', - 'group' => 'OpenLayers', - ); - } - - function setUp() { - // Install modules - parent::setUp('openlayers', 'ctools', 'openlayers_ui', 'openlayers_test'); - } - - function testOpenLayersMapAlters() { - $user = $this->drupalCreateUser(array('administer openlayers')); - $this->drupalLogin($user); - - // Styles - $this->drupalGet('admin/structure/openlayers/test'); - $this->assertText(t('OpenLayers preprocess map alter hook fired.'), - t('Map preprocess alter fired correctly.')); - $this->assertText(t('OpenLayers map alter hook fired.'), - t('Map alter fired correctly.')); - } -} - -/** - * OpenLayers Unit Tests - * - * Do not use t() in Unit tests. - * https://drupal.org/node/811254 - * - * Unit tests do not bootstrap Drupal very - * far which makes them a bit useless if - * we are utilizing Drupal API functions. - */ -class OpenLayersUnitTests extends DrupalUnitTestCase { - public static function getInfo() { - return array( - 'name' => 'OpenLayers Unit Tests', - 'description' => 'Tests functions for OpenLayers.', - 'group' => 'OpenLayers', - ); - } - - function testOpenLayersStylePath() { - module_load_include('inc', 'openlayers', 'includes/openlayers.render'); - global $base_url; - - // Full URL - $path = 'http://example.org/sites/all/modules/openlayers/example/${path}.jpg'; - $styled_path = openlayers_style_path($path); - $this->assertTrue($styled_path === $path, 'OpenLayers Style Path function with full URL.'); - - // Just replacement value - $path = '${path}'; - $styled_path = openlayers_style_path($path); - $this->assertTrue($styled_path === $path, 'OpenLayers Style Path function with just replacement value.'); - - // Relative URL - $path = 'sites/all/modules/openlayers/example/${path}.jpg'; - $styled_path = openlayers_style_path($path); - $this->assertTrue($styled_path === $base_url . '/' . $path, 'OpenLayers Style Path function with relative URL.'); - } -} diff --git a/tests/openlayers_test.info b/tests/openlayers_test.info deleted file mode 100644 index 3012a3025d680830e38879cc73d9797436375caf..0000000000000000000000000000000000000000 --- a/tests/openlayers_test.info +++ /dev/null @@ -1,9 +0,0 @@ -name = "OpenLayers Tests" -description = "OpenLayers test module. There is no reason to install this." -core = 7.x -package = "OpenLayers" -dependencies[] = openlayers -hidden = TRUE -files[] = openlayers.test -files[] = includes/openlayers_test.maps.inc -files[] = includes/openlayers_test.views.inc diff --git a/tests/openlayers_test.install b/tests/openlayers_test.install deleted file mode 100644 index 401558282afe97720bba5424dceef7a4c592d421..0000000000000000000000000000000000000000 --- a/tests/openlayers_test.install +++ /dev/null @@ -1,191 +0,0 @@ - 'openlayers_test_type', - 'name' => st('OpenLayers Test Type'), - 'module' => 'node', - 'description' => st('This is a test content type for OpenLayers.'), - 'custom' => TRUE, - 'modified' => TRUE, - 'locked' => TRUE, - ); - - $node_type = (object)_node_type_set_defaults($node_type); - node_type_save($node_type); - // Default to not promoted. - variable_set('node_options_openlayers_test_type', array('status')); - - // The import process of CCK is not simply calling a function, - // so we just feed the submit function the correct values - module_load_include('inc', 'node', 'content_types.inc'); - module_load_include('inc', 'content', 'includes/content.admin.inc'); - module_load_include('inc', 'content', 'includes/content.crud'); - module_load_include('module', 'content_copy', 'content_copy'); - // Leverage macro making function - $GLOBALS['content_copy']['submissions'] = _openlayers_test_content_definition(); - $macro = content_copy_get_macro(); - - // Make form array - $form = array(); - $form_state = array( - 'values' => array( - 'type_name' => 'openlayers_test_type', - 'macro' => $macro, - ), - ); - - // Call submit function - content_copy_import_form_submit($form, $form_state); - } -} - -/** - * Implementation of hook_uninstall(). - */ -function openlayers_test_uninstall() { - // Remove any added data (check for function) - if (function_exists('node_type_delete')) { - node_type_delete('openlayers_test_type'); - } - - // Get module variables - $variables = db_query("SELECT v.name FROM {variable} AS v WHERE v.name LIKE ':pattern'", - array(':pattern' => db_like('openlayers_test_') . '%'))->fetchAll(); - // Remove variables - foreach ($variables as $v) { - variable_del($v); - } -} - -/** - * Get content type definition with fields. - * - * Retireives content type definition and fields - * as exported from CCK. - */ -function _openlayers_test_content_definition() { - $content['type'] = array( - 'name' => 'OpenLayers Test Type', - 'type' => 'openlayers_test_type', - 'description' => 'This is a content type for testing OpenLayers functionality.', - 'title_label' => 'Title', - 'body_label' => 'Body', - 'min_word_count' => '0', - 'help' => '', - 'node_options' => - array( - 'status' => TRUE, - 'promote' => FALSE, - 'sticky' => FALSE, - 'revision' => FALSE, - ), - 'old_type' => 'openlayers_test_type', - 'orig_type' => 'openlayers_test_type', - 'module' => 'node', - 'custom' => '1', - 'modified' => '1', - 'locked' => '1', - 'comment' => 2, - 'comment_default_mode' => 4, - 'comment_default_order' => 1, - 'comment_default_per_page' => 50, - 'comment_controls' => 3, - 'comment_anonymous' => 0, - 'comment_subject_field' => 1, - 'comment_preview' => 1, - 'comment_form_location' => 0, - ); - $content['fields'] = array( - 0 => - array( - 'label' => 'OpenLayers Test WKT', - 'field_name' => 'field_openlayers_test_wkt', - 'type' => 'openlayers_wkt', - 'widget_type' => 'openlayers_wkt_widget', - 'change' => 'Change basic information', - 'weight' => '31', - 'openlayers_cck_map' => 'default', - 'description' => 'This is some help text for this field.', - 'default_value' => - array( - 0 => - array( - 'openlayers_wkt' => '', - ), - ), - 'default_value_php' => '', - 'default_value_widget' => NULL, - 'group' => FALSE, - 'required' => 0, - 'multiple' => '0', - 'openlayers_cck_feature_types' => - array( - 'point' => 'point', - 'path' => 'path', - 'polygon' => 'polygon', - ), - 'op' => 'Save field settings', - 'module' => 'openlayers_cck', - 'widget_module' => 'openlayers_cck', - 'columns' => - array( - 'openlayers_wkt' => - array( - 'type' => 'text', - 'size' => 'big', - 'not null' => FALSE, - 'sortable' => TRUE, - 'views' => TRUE, - ), - ), - 'display_settings' => - array( - 'label' => - array( - 'format' => 'above', - 'exclude' => 0, - ), - 'teaser' => - array( - 'format' => 'default', - 'exclude' => 0, - ), - 'full' => - array( - 'format' => 'default', - 'exclude' => 0, - ), - 4 => - array( - 'format' => 'default', - 'exclude' => 0, - ), - ), - ), - ); - $content['extra'] = array( - 'title' => '-5', - 'body_field' => '0', - 'revision_information' => '20', - 'comment_settings' => '30', - 'menu' => '-2', - ); - - return $content; -} \ No newline at end of file diff --git a/tests/openlayers_test.module b/tests/openlayers_test.module deleted file mode 100644 index 1a531066adc89b800a9432105d888dc570a9a30f..0000000000000000000000000000000000000000 --- a/tests/openlayers_test.module +++ /dev/null @@ -1,126 +0,0 @@ - 'Tests', - 'description' => 'Test Pages for OpenLayers.', - 'page callback' => 'openlayers_test_show_maps', - 'access arguments' => array('administer openlayers'), - 'file' => 'includes/openlayers_test.pages.inc', - 'type' => MENU_LOCAL_TASK, - 'weight' => 9999, - ); - $items['admin/structure/openlayers/test/list'] = array( - 'title' => 'Show Maps', - 'type' => MENU_DEFAULT_LOCAL_TASK, - 'weight' => -20, - ); - $items['admin/structure/openlayers/test/js'] = array( - 'title' => 'JS Tests', - 'description' => 'Test Pages for OpenLayers Javascript.', - 'page callback' => 'openlayers_test_js', - 'access arguments' => array('administer openlayers'), - 'file' => 'includes/openlayers_test.pages.inc', - 'type' => MENU_LOCAL_TASK, - 'weight' => -10, - ); - - - return $items; -} - -/** - * Implements hook_ctools_plugin_api(). - */ -function openlayers_test_ctools_plugin_api($module, $api) { - // Define plugins for OpenLayers plugins api - if ($module == "openlayers") { - switch ($api) { - case 'openlayers_maps': - return array('version' => 1); - - case 'openlayers_layers': - return array('version' => 1); - - } - } -} - -/** - * Implements hook_views_api(). - */ -function openlayers_test_views_api() { - return array( - 'api' => 2, - ); -} - -/** - * Implements hook_openlayers_maps(). - */ -function openlayers_test_openlayers_maps() { - module_load_include('inc', 'openlayers_test', 'includes/openlayers_test.maps'); - return _openlayers_test_openlayers_maps(); -} - -/** - * Implements hook_openlayers_layers(). - */ -function openlayers_test_openlayers_layers() { - module_load_include('inc', 'openlayers_test', 'includes/openlayers_test.layers'); - return _openlayers_test_openlayers_layers(); -} - -/** - * Implements hook_views_default_views(). - */ -function openlayers_test_views_default_views() { - module_load_include('inc', 'openlayers_test', 'includes/openlayers_test.views'); - return _openlayers_test_views_default_views(); -} - -/** - * Impements hook_openlayers_map_preprocess_alter(). - */ -function openlayers_test_openlayers_map_preprocess_alter(&$map) { - // For testing purposes, display a message on the only the Test - // page, and only once. - static $performed = FALSE; - if (!$performed && $_GET['q'] == 'admin/structure/openlayers/test') { - drupal_set_message(t('OpenLayers preprocess map alter hook fired.')); - $performed = TRUE; - } - - // Add stop render for JS testing - if ($_GET['q'] == 'admin/structure/openlayers/test/js') { - $map['stop_render'] = TRUE; - } -} - -/** - * Impements hook_openlayers_map_alter(). - */ -function openlayers_test_openlayers_map_alter(&$map) { - // For testing purposes, display a message on the only the Test - // page, and only once. - static $performed = FALSE; - if (!$performed && $_GET['q'] == 'admin/structure/openlayers/test') { - drupal_set_message(t('OpenLayers map alter hook fired.')); - $performed = TRUE; - } -} \ No newline at end of file diff --git a/themes/default_dark/img/README.txt b/themes/default_dark/img/README.txt deleted file mode 100644 index 0d7a8fa9accdcb68011ad57e15f1a8e222785bc5..0000000000000000000000000000000000000000 --- a/themes/default_dark/img/README.txt +++ /dev/null @@ -1,6 +0,0 @@ -Default image set for the OpenLayers Drupal module. - -Many original images used with permission (and licensed under GPL) -from MapBox. - -https://github.com/developmentseed/openlayers_themes \ No newline at end of file diff --git a/themes/default_dark/img/add_point_off.png b/themes/default_dark/img/add_point_off.png deleted file mode 100755 index 8c612223b754398a5957238dec99539dd15cce32..0000000000000000000000000000000000000000 Binary files a/themes/default_dark/img/add_point_off.png and /dev/null differ diff --git a/themes/default_dark/img/add_point_on.png b/themes/default_dark/img/add_point_on.png deleted file mode 100755 index e80c0847699ead62e6c0e8a71d0221fd98bbe493..0000000000000000000000000000000000000000 Binary files a/themes/default_dark/img/add_point_on.png and /dev/null differ diff --git a/themes/default_dark/img/blank.gif b/themes/default_dark/img/blank.gif deleted file mode 100644 index 62f47dcc287932cd5707c10b9e4e64916b34dfa7..0000000000000000000000000000000000000000 Binary files a/themes/default_dark/img/blank.gif and /dev/null differ diff --git a/themes/default_dark/img/close.gif b/themes/default_dark/img/close.gif deleted file mode 100644 index 805b32d76c2428696be2b6bfa39703c78bc7682e..0000000000000000000000000000000000000000 Binary files a/themes/default_dark/img/close.gif and /dev/null differ diff --git a/themes/default_dark/img/cloud-popup-relative.png b/themes/default_dark/img/cloud-popup-relative.png deleted file mode 100644 index bf7cb0f8126f9805897439d4f39e6ac74a6ceceb..0000000000000000000000000000000000000000 Binary files a/themes/default_dark/img/cloud-popup-relative.png and /dev/null differ diff --git a/themes/default_dark/img/drag-rectangle-off.png b/themes/default_dark/img/drag-rectangle-off.png deleted file mode 100755 index ebeaa6d891d44dc3a29a377b5f29ca5506ebb00c..0000000000000000000000000000000000000000 Binary files a/themes/default_dark/img/drag-rectangle-off.png and /dev/null differ diff --git a/themes/default_dark/img/drag-rectangle-on.png b/themes/default_dark/img/drag-rectangle-on.png deleted file mode 100755 index 89effb2573bb78e7a04441a94be5b7443fcf3c3a..0000000000000000000000000000000000000000 Binary files a/themes/default_dark/img/drag-rectangle-on.png and /dev/null differ diff --git a/themes/default_dark/img/draw_line_off.png b/themes/default_dark/img/draw_line_off.png deleted file mode 100755 index 964293c75f75dfcbfd29628902c93b164f62f4c1..0000000000000000000000000000000000000000 Binary files a/themes/default_dark/img/draw_line_off.png and /dev/null differ diff --git a/themes/default_dark/img/draw_line_on.png b/themes/default_dark/img/draw_line_on.png deleted file mode 100755 index f0e892f260bfea20323e27b3394d5aaace62ca67..0000000000000000000000000000000000000000 Binary files a/themes/default_dark/img/draw_line_on.png and /dev/null differ diff --git a/themes/default_dark/img/draw_point_off.png b/themes/default_dark/img/draw_point_off.png deleted file mode 100755 index 1473bfe2d730f2a9d49a4a5dfc59b39e15131224..0000000000000000000000000000000000000000 Binary files a/themes/default_dark/img/draw_point_off.png and /dev/null differ diff --git a/themes/default_dark/img/draw_point_on.png b/themes/default_dark/img/draw_point_on.png deleted file mode 100755 index d4060d474505fc1b56d2ba1d131ba53054003efe..0000000000000000000000000000000000000000 Binary files a/themes/default_dark/img/draw_point_on.png and /dev/null differ diff --git a/themes/default_dark/img/draw_polygon_off.png b/themes/default_dark/img/draw_polygon_off.png deleted file mode 100755 index 3896c72669dca4d69243f7800cf54c58fb17b620..0000000000000000000000000000000000000000 Binary files a/themes/default_dark/img/draw_polygon_off.png and /dev/null differ diff --git a/themes/default_dark/img/draw_polygon_on.png b/themes/default_dark/img/draw_polygon_on.png deleted file mode 100755 index 9f6590e0d7ceda9ebe52b67f2c30f6712baf6484..0000000000000000000000000000000000000000 Binary files a/themes/default_dark/img/draw_polygon_on.png and /dev/null differ diff --git a/themes/default_dark/img/east-mini.png b/themes/default_dark/img/east-mini.png deleted file mode 100644 index b5be557984ee5efed19b8a8327168ae21c871d1e..0000000000000000000000000000000000000000 Binary files a/themes/default_dark/img/east-mini.png and /dev/null differ diff --git a/themes/default_dark/img/editing_tool_bar.png b/themes/default_dark/img/editing_tool_bar.png deleted file mode 100755 index b225fc5f052c406f434807b4206c8fb529feca06..0000000000000000000000000000000000000000 Binary files a/themes/default_dark/img/editing_tool_bar.png and /dev/null differ diff --git a/themes/default_dark/img/icons_ol.svg b/themes/default_dark/img/icons_ol.svg deleted file mode 100644 index 43be4b4a4bcb1caff0e690fdb84e7a9254ed77eb..0000000000000000000000000000000000000000 --- a/themes/default_dark/img/icons_ol.svg +++ /dev/null @@ -1,1948 +0,0 @@ - - - -image/svg+xmlediting_tool_bar.png -remove_point_off.pngdraw_point_off.png -marker.pngmarker-blue.pngmarker-gold.pngmarker-green.png -on.png(s) -pan_off.png -add_point_off.png -draw_line_off.png -draw_polygon_off.png -move_feature_off.png -drag-rectangle-off.pngmeasuring-stick-off.pngpanning-hand-off.png - \ No newline at end of file diff --git a/themes/default_dark/img/layer-switcher-maximize.png b/themes/default_dark/img/layer-switcher-maximize.png deleted file mode 100644 index bb812f293971fa9768a6c56cea457f2f6323dff0..0000000000000000000000000000000000000000 Binary files a/themes/default_dark/img/layer-switcher-maximize.png and /dev/null differ diff --git a/themes/default_dark/img/layer-switcher-minimize.png b/themes/default_dark/img/layer-switcher-minimize.png deleted file mode 100644 index 3ff2b4ad5de1104ae062e6c562536c871d0deb93..0000000000000000000000000000000000000000 Binary files a/themes/default_dark/img/layer-switcher-minimize.png and /dev/null differ diff --git a/themes/default_dark/img/marker-blue.png b/themes/default_dark/img/marker-blue.png deleted file mode 100755 index 3f5a207b2cedeeb939399c53ec0f3ac2600e0c75..0000000000000000000000000000000000000000 Binary files a/themes/default_dark/img/marker-blue.png and /dev/null differ diff --git a/themes/default_dark/img/marker-gold.png b/themes/default_dark/img/marker-gold.png deleted file mode 100755 index 3d69631979b5e50a9b840937870e40687c6220cb..0000000000000000000000000000000000000000 Binary files a/themes/default_dark/img/marker-gold.png and /dev/null differ diff --git a/themes/default_dark/img/marker-green.png b/themes/default_dark/img/marker-green.png deleted file mode 100755 index b082705dec46053b58d943093c849da22b4639d3..0000000000000000000000000000000000000000 Binary files a/themes/default_dark/img/marker-green.png and /dev/null differ diff --git a/themes/default_dark/img/marker-red.png b/themes/default_dark/img/marker-red.png deleted file mode 100755 index f515f89f062551c71fc2faeb3878a928a91cde30..0000000000000000000000000000000000000000 Binary files a/themes/default_dark/img/marker-red.png and /dev/null differ diff --git a/themes/default_dark/img/marker.png b/themes/default_dark/img/marker.png deleted file mode 100755 index f515f89f062551c71fc2faeb3878a928a91cde30..0000000000000000000000000000000000000000 Binary files a/themes/default_dark/img/marker.png and /dev/null differ diff --git a/themes/default_dark/img/measuring-stick-off.png b/themes/default_dark/img/measuring-stick-off.png deleted file mode 100755 index 01d20a2bcf823ee2f108ac0f9ed5104e04ed3a47..0000000000000000000000000000000000000000 Binary files a/themes/default_dark/img/measuring-stick-off.png and /dev/null differ diff --git a/themes/default_dark/img/measuring-stick-on.png b/themes/default_dark/img/measuring-stick-on.png deleted file mode 100755 index 717d1b6a406cbc02dba9e30393e4487e8422736e..0000000000000000000000000000000000000000 Binary files a/themes/default_dark/img/measuring-stick-on.png and /dev/null differ diff --git a/themes/default_dark/img/move_feature_off.png b/themes/default_dark/img/move_feature_off.png deleted file mode 100755 index f97709f9b0abc14efe016d5d078dc25feb76813a..0000000000000000000000000000000000000000 Binary files a/themes/default_dark/img/move_feature_off.png and /dev/null differ diff --git a/themes/default_dark/img/move_feature_on.png b/themes/default_dark/img/move_feature_on.png deleted file mode 100755 index b0f11120a71fb7ea95b5e43d6904de628ea230ae..0000000000000000000000000000000000000000 Binary files a/themes/default_dark/img/move_feature_on.png and /dev/null differ diff --git a/themes/default_dark/img/north-mini.png b/themes/default_dark/img/north-mini.png deleted file mode 100644 index 3d569c914a4ac1ef7ad8c7b3dee5830827b734b4..0000000000000000000000000000000000000000 Binary files a/themes/default_dark/img/north-mini.png and /dev/null differ diff --git a/themes/default_dark/img/overview_replacement.png b/themes/default_dark/img/overview_replacement.png deleted file mode 100644 index c5a901f62eea8f51b17c4abf2913c65d5e471027..0000000000000000000000000000000000000000 Binary files a/themes/default_dark/img/overview_replacement.png and /dev/null differ diff --git a/themes/default_dark/img/pan-panel.png b/themes/default_dark/img/pan-panel.png deleted file mode 100644 index f42533d82969586188e5c0c79875a2d2e09cdb43..0000000000000000000000000000000000000000 Binary files a/themes/default_dark/img/pan-panel.png and /dev/null differ diff --git a/themes/default_dark/img/pan_off.png b/themes/default_dark/img/pan_off.png deleted file mode 100755 index ce395a651d721cc923cf5c7d6597f0c937a843f0..0000000000000000000000000000000000000000 Binary files a/themes/default_dark/img/pan_off.png and /dev/null differ diff --git a/themes/default_dark/img/pan_on.png b/themes/default_dark/img/pan_on.png deleted file mode 100755 index e5079a4c14f0b299c9c6a471a50cde27ebca6f21..0000000000000000000000000000000000000000 Binary files a/themes/default_dark/img/pan_on.png and /dev/null differ diff --git a/themes/default_dark/img/panning-hand-off.png b/themes/default_dark/img/panning-hand-off.png deleted file mode 100755 index 6f0c2e4d2a8df3afb6cd0495c051d19ae42eaef2..0000000000000000000000000000000000000000 Binary files a/themes/default_dark/img/panning-hand-off.png and /dev/null differ diff --git a/themes/default_dark/img/panning-hand-on.png b/themes/default_dark/img/panning-hand-on.png deleted file mode 100755 index 87d61a5868a8819e94abd11db3485a4feac3ae5d..0000000000000000000000000000000000000000 Binary files a/themes/default_dark/img/panning-hand-on.png and /dev/null differ diff --git a/themes/default_dark/img/remove_point_off.png b/themes/default_dark/img/remove_point_off.png deleted file mode 100755 index 380b1df3bc7ea04c4bddb735ca9f5987cec6012b..0000000000000000000000000000000000000000 Binary files a/themes/default_dark/img/remove_point_off.png and /dev/null differ diff --git a/themes/default_dark/img/remove_point_on.png b/themes/default_dark/img/remove_point_on.png deleted file mode 100755 index 29951b8b88ef0cc31c25f9a007dc3e001d6f9961..0000000000000000000000000000000000000000 Binary files a/themes/default_dark/img/remove_point_on.png and /dev/null differ diff --git a/themes/default_dark/img/ruler.png b/themes/default_dark/img/ruler.png deleted file mode 100755 index 0abc900e9e9d066c538771cf4e32bedf19cbb0c4..0000000000000000000000000000000000000000 Binary files a/themes/default_dark/img/ruler.png and /dev/null differ diff --git a/themes/default_dark/img/save_features_off.png b/themes/default_dark/img/save_features_off.png deleted file mode 100644 index f33f87290056ae1672819946813bd4da0cadbbe2..0000000000000000000000000000000000000000 Binary files a/themes/default_dark/img/save_features_off.png and /dev/null differ diff --git a/themes/default_dark/img/save_features_on.png b/themes/default_dark/img/save_features_on.png deleted file mode 100644 index af14d5e2d10daff5dc0c70af45d3a62ecbbdf4f0..0000000000000000000000000000000000000000 Binary files a/themes/default_dark/img/save_features_on.png and /dev/null differ diff --git a/themes/default_dark/img/slider.png b/themes/default_dark/img/slider.png deleted file mode 100644 index a46f986ce9f9730a3b7e44fb344053eeb0a54982..0000000000000000000000000000000000000000 Binary files a/themes/default_dark/img/slider.png and /dev/null differ diff --git a/themes/default_dark/img/south-mini.png b/themes/default_dark/img/south-mini.png deleted file mode 100644 index 15a34e0978420b394b16e23c0aa60dd4c0530b0c..0000000000000000000000000000000000000000 Binary files a/themes/default_dark/img/south-mini.png and /dev/null differ diff --git a/themes/default_dark/img/west-mini.png b/themes/default_dark/img/west-mini.png deleted file mode 100644 index 7599ae5d7cdc97ef8ee7534f261852402c8b3549..0000000000000000000000000000000000000000 Binary files a/themes/default_dark/img/west-mini.png and /dev/null differ diff --git a/themes/default_dark/img/zoom-minus-mini.png b/themes/default_dark/img/zoom-minus-mini.png deleted file mode 100644 index 5310c4f49b40dd757639da41d80611c31c3e19d2..0000000000000000000000000000000000000000 Binary files a/themes/default_dark/img/zoom-minus-mini.png and /dev/null differ diff --git a/themes/default_dark/img/zoom-panel.png b/themes/default_dark/img/zoom-panel.png deleted file mode 100644 index 1ea7fd7fe9764b7c0035e9a3d8364967da1a988d..0000000000000000000000000000000000000000 Binary files a/themes/default_dark/img/zoom-panel.png and /dev/null differ diff --git a/themes/default_dark/img/zoom-plus-mini.png b/themes/default_dark/img/zoom-plus-mini.png deleted file mode 100644 index cf04a2545dd804ed7417c1264f162255ad4f3fec..0000000000000000000000000000000000000000 Binary files a/themes/default_dark/img/zoom-plus-mini.png and /dev/null differ diff --git a/themes/default_dark/img/zoom-world-mini.png b/themes/default_dark/img/zoom-world-mini.png deleted file mode 100644 index 4420155e84ce02d175e67ab124e496a3eb3761e6..0000000000000000000000000000000000000000 Binary files a/themes/default_dark/img/zoom-world-mini.png and /dev/null differ diff --git a/themes/default_dark/img/zoombar.png b/themes/default_dark/img/zoombar.png deleted file mode 100644 index f29d2116e194584dde1bfebe79ee0da05c10c6c4..0000000000000000000000000000000000000000 Binary files a/themes/default_dark/img/zoombar.png and /dev/null differ diff --git a/themes/default_dark/markers/marker-black-small.png b/themes/default_dark/markers/marker-black-small.png deleted file mode 100644 index 4028633fabb1d616c0addd069ed72f2fa9166716..0000000000000000000000000000000000000000 Binary files a/themes/default_dark/markers/marker-black-small.png and /dev/null differ diff --git a/themes/default_dark/markers/marker-black.png b/themes/default_dark/markers/marker-black.png deleted file mode 100644 index c845992ee27afa9177cc95c9bb296836e6fd62b4..0000000000000000000000000000000000000000 Binary files a/themes/default_dark/markers/marker-black.png and /dev/null differ diff --git a/themes/default_dark/openlayers_style.css b/themes/default_dark/openlayers_style.css deleted file mode 100644 index 522d8f087f31399127944c7fe4b60c1d11ec2ec0..0000000000000000000000000000000000000000 --- a/themes/default_dark/openlayers_style.css +++ /dev/null @@ -1,490 +0,0 @@ -div.olMap { - z-index: 0; - padding: 0 !important; - margin: 0 !important; - cursor: default; -} - -div.olMapViewport { - text-align: left; -} - -div.olLayerDiv { - -moz-user-select: none; - -khtml-user-select: none; -} - -.olLayerGoogleCopyright { - left: 2px; - bottom: 2px; -} -.olLayerGoogleV3.olLayerGoogleCopyright { - right: auto !important; -} -.olLayerGooglePoweredBy { - left: 2px; - bottom: 15px; -} -.olLayerGoogleV3.olLayerGooglePoweredBy { - bottom: 15px !important; -} -.olControlAttribution { - font-size: smaller; - right: 3px; - bottom: 4.5em; - position: absolute; - display: block; -} -.olControlScale { - right: 3px; - bottom: 3em; - display: block; - position: absolute; - font-size: smaller; -} -.olControlScaleLine { - display: block; - position: absolute; - left: 10px; - bottom: 15px; - font-size: xx-small; -} -.olControlScaleLineBottom { - border: solid 2px black; - border-bottom: none; - margin-top:-2px; - text-align: center; -} -.olControlScaleLineTop { - border: solid 2px black; - border-top: none; - text-align: center; -} - -.olControlPermalink { - right: 3px; - bottom: 1.5em; - display: block; - position: absolute; - font-size: smaller; -} - -div.olControlMousePosition { - bottom: 0; - right: 3px; - display: block; - position: absolute; - font-family: Arial; - font-size: smaller; -} - -.olControlOverviewMapContainer { - position: absolute; - bottom: 0; - right: 0; -} - -.olControlOverviewMapElement { - padding: 10px 18px 10px 10px; - background-color: #00008B; - -moz-border-radius: 1em 0 0 0; -} - -.olControlOverviewMapMinimizeButton, -.olControlOverviewMapMaximizeButton { - height: 18px; - width: 18px; - right: 0; - bottom: 80px; - cursor: pointer; -} - -.olControlOverviewMapExtentRectangle { - overflow: hidden; - background-image: url("img/blank.gif"); - cursor: move; - border: 2px dotted red; -} -.olControlOverviewMapRectReplacement { - overflow: hidden; - cursor: move; - background-image: url("img/overview_replacement.gif"); - background-repeat: no-repeat; - background-position: center; -} - -.olLayerGeoRSSDescription { - float:left; - width:100%; - overflow:auto; - font-size:1.0em; -} -.olLayerGeoRSSClose { - float:right; - color:gray; - font-size:1.2em; - margin-right:6px; - font-family:sans-serif; -} -.olLayerGeoRSSTitle { - float:left;font-size:1.2em; -} - -.olPopupContent { - padding:5px; - overflow: auto; -} - -/* See #1978462 */ -.olPopup img { - max-width: 9999px; - max-height: 9999px; -} - -.olControlNavigationHistory { - background-image: url("img/navigation_history.png"); - background-repeat: no-repeat; - width: 24px; - height: 24px; - -} -.olControlNavigationHistoryPreviousItemActive { - background-position: 0 0; -} -.olControlNavigationHistoryPreviousItemInactive { - background-position: 0 -24px; -} -.olControlNavigationHistoryNextItemActive { - background-position: -24px 0; -} -.olControlNavigationHistoryNextItemInactive { - background-position: -24px -24px; -} - -div.olControlSaveFeaturesItemActive { - background-image: url(img/save_features_on.png); - background-repeat: no-repeat; - background-position: 0 1px; -} -div.olControlSaveFeaturesItemInactive { - background-image: url(img/save_features_off.png); - background-repeat: no-repeat; - background-position: 0 1px; -} - -.olHandlerBoxZoomBox { - border: 2px solid red; - position: absolute; - background-color: white; - opacity: 0.50; - font-size: 1px; - filter: alpha(opacity=50); -} -.olHandlerBoxSelectFeature { - border: 2px solid blue; - position: absolute; - background-color: white; - opacity: 0.50; - font-size: 1px; - filter: alpha(opacity=50); -} - -.olControlPanPanel { - top: 10px; - left: 5px; -} - -.olControlPanPanel div { - background-image: url(img/pan-panel.png); - height: 18px; - width: 18px; - cursor: pointer; - position: absolute; -} - -.olControlPanPanel .olControlPanNorthItemInactive { - top: 0; - left: 9px; - background-position: 0 0; -} -.olControlPanPanel .olControlPanSouthItemInactive { - top: 36px; - left: 9px; - background-position: 18px 0; -} -.olControlPanPanel .olControlPanWestItemInactive { - position: absolute; - top: 18px; - left: 0; - background-position: 0 18px; -} -.olControlPanPanel .olControlPanEastItemInactive { - top: 18px; - left: 18px; - background-position: 18px 18px; -} - -.olControlZoomPanel { - top: 71px; - left: 14px; -} - -.olControlZoomPanel div { - background-image: url(img/zoom-panel.png); - position: absolute; - height: 18px; - width: 18px; - cursor: pointer; -} - -.olControlZoomPanel .olControlZoomInItemInactive { - top: 0; - left: 0; - background-position: 0 0; -} - -.olControlZoomPanel .olControlZoomToMaxExtentItemInactive { - top: 18px; - left: 0; - background-position: 0 -18px; -} - -.olControlZoomPanel .olControlZoomOutItemInactive { - top: 36px; - left: 0; - background-position: 0 18px; -} - -/* - * When a potential text is bigger than the image it move the image - * with some headers (closes #3154) - */ -.olControlPanZoomBar div { - font-size: 1px; -} - -.olPopupCloseBox { - background: url("img/close.gif") no-repeat; - cursor: pointer; -} - -.olFramedCloudPopupContent { - padding: 5px; - overflow: auto; -} - -.olControlNoSelect { - -moz-user-select: none; - -khtml-user-select: none; -} - -.olImageLoadError { - background-color: pink; - opacity: 0.5; - filter: alpha(opacity=50); /* IE */ -} - -/** - * Cursor styles - */ - -.olCursorWait { - cursor: wait; -} -.olDragDown { - cursor: move; -} -.olDrawBox { - cursor: crosshair; -} -.olControlDragFeatureOver { - cursor: move; -} -.olControlDragFeatureActive.olControlDragFeatureOver.olDragDown { - cursor: -moz-grabbing; -} - -/** - * Layer switcher - */ -.olControlLayerSwitcher { - position: absolute; - top: 25px; - right: 0; - width: 20em; - font-family: sans-serif; - font-weight: bold; - margin-top: 3px; - margin-left: 3px; - margin-bottom: 3px; - font-size: smaller; - color: white; - background-color: transparent; -} - -.olControlLayerSwitcher .layersDiv { - padding-top: 5px; - padding-left: 10px; - padding-bottom: 5px; - padding-right: 10px; - background-color: darkblue; -} - -.olControlLayerSwitcher .layersDiv .baseLbl, -.olControlLayerSwitcher .layersDiv .dataLbl { - margin-top: 3px; - margin-left: 3px; - margin-bottom: 3px; -} - -.olControlLayerSwitcher .layersDiv .baseLayersDiv, -.olControlLayerSwitcher .layersDiv .dataLayersDiv { - padding-left: 10px; -} - -.olControlLayerSwitcher .maximizeDiv, -.olControlLayerSwitcher .minimizeDiv { - width: 18px; - height: 18px; - top: 5px; - right: 0; - cursor: pointer; -} - -.olBingAttribution { - color: #DDD; -} -.olBingAttribution.road { - color: #333; -} - -.olGoogleAttribution.hybrid, .olGoogleAttribution.satellite { - color: #EEE; -} -.olGoogleAttribution { - color: #333; -} -span.olGoogleAttribution a { - color: #77C; -} -span.olGoogleAttribution.hybrid a, span.olGoogleAttribution.satellite a { - color: #EEE; -} - -/** - * Editing and navigation icons. - * (using the editing_tool_bar.png sprint image) - */ -.olControlNavToolbar , -.olControlEditingToolbar { - margin: 5px 5px 0 0; -} -.olControlNavToolbar div, -.olControlEditingToolbar div { - background-image: url("img/editing_tool_bar.png"); - background-repeat: no-repeat; - margin: 0 0 5px 5px; - width: 24px; - height: 22px; - cursor: pointer -} -/* positions */ -.olControlEditingToolbar { - right: 26px; - top: 0; -} -.olControlNavToolbar { - top: 295px; - left: 9px; -} -/* layouts */ -.olControlEditingToolbar div { - float: right; -} -/* individual controls */ -.olControlNavToolbar .olControlNavigationItemInactive, -.olControlEditingToolbar .olControlNavigationItemInactive { - background-position: -103px -1px; -} -.olControlNavToolbar .olControlNavigationItemActive , -.olControlEditingToolbar .olControlNavigationItemActive { - background-position: -103px -24px; -} -.olControlNavToolbar .olControlZoomBoxItemInactive { - background-position: -128px -1px; -} -.olControlNavToolbar .olControlZoomBoxItemActive { - background-position: -128px -24px; -} -.olControlEditingToolbar .olControlDrawFeaturePointItemInactive { - background-position: -77px -1px; -} -.olControlEditingToolbar .olControlDrawFeaturePointItemActive { - background-position: -77px -24px; -} -.olControlEditingToolbar .olControlDrawFeaturePathItemInactive { - background-position: -51px -1px; -} -.olControlEditingToolbar .olControlDrawFeaturePathItemActive { - background-position: -51px -24px; -} -.olControlEditingToolbar .olControlDrawFeaturePolygonItemInactive{ - background-position: -26px -1px; -} -.olControlEditingToolbar .olControlDrawFeaturePolygonItemActive { - background-position: -26px -24px; -} - -div.olControlZoom { - position: absolute; - top: 8px; - left: 8px; - background: rgba(255,255,255,0.4); - border-radius: 4px; - padding: 2px; -} -div.olControlZoom a { - display: block; - margin: 1px; - padding: 0; - color: white; - font-size: 18px; - font-family: 'Lucida Grande', Verdana, Geneva, Lucida, Arial, Helvetica, sans-serif; - font-weight: bold; - text-decoration: none; - text-align: center; - height: 22px; - width:22px; - line-height: 19px; - background: #130085; /* fallback for IE - IE6 requires background shorthand*/ - background: rgba(0, 60, 136, 0.5); - filter: alpha(opacity=80); -} -div.olControlZoom a:hover { - background: #130085; /* fallback for IE */ - background: rgba(0, 60, 136, 0.7); - filter: alpha(opacity=100); -} -@media only screen and (max-width: 600px) { - div.olControlZoom a:hover { - background: rgba(0, 60, 136, 0.5); - } -} -a.olControlZoomIn { - border-radius: 4px 4px 0 0; -} -a.olControlZoomOut { - border-radius: 0 0 4px 4px; -} - - -/** - * Animations - */ - -.olLayerGrid .olTileImage { - -webkit-transition: opacity 0.2s linear; - -moz-transition: opacity 0.2s linear; - -o-transition: opacity 0.2s linear; - transition: opacity 0.2s linear; -} diff --git a/themes/default_dark/style.css b/themes/default_dark/style.css deleted file mode 100644 index 4f901371669edfc762ccf1b684332b4202fd5409..0000000000000000000000000000000000000000 --- a/themes/default_dark/style.css +++ /dev/null @@ -1,101 +0,0 @@ -/** - * @file - * CSS file for OpenLayers dark theme. - * - * We include the default styles, then add - * some specificity to override certain elements - * like image references. - */ - -@import url(openlayers_style.css); - - -.olControlOverviewMapExtentRectangle { - border: none; -} -.olControlOverviewMapRectReplacement { - background-image: url(img/overview_replacement.png); -} - -/** - * A few custom styles - */ -.openlayers-popup { - color: #EEEEEE; -} -.olImageLoadError, -.openlayers-map .olImageLoadError { - background-color: transparent; - display: none !important; -} - -/** - * CSS fix, see #1646646 - */ -label.olButton { - display: inline; - margin-left: .5em; -} - -/** - * Improve placement of controls that overlap when both are enabled. - */ -.openlayers_behavior_fullscreen_button_panelActive .olControlEditingToolbar { - right: 30px; -} -.olControlMousePositionActive .olControlAttribution { - bottom: 1.2em; - right: 3px; -} - -/** - * Make the fullscreen behavior button match dark design. - * The fullscreen button is added to the editing tool bar PNG to reduce - * HTTP requests. - */ -.openlayers_behavior_fullscreen_buttonItemInactive { - background-image: url(img/editing_tool_bar.png); - background-position: -153px -1px; - width: 24px; - height: 22px; -} -.openlayers_map_fullscreen .openlayers_behavior_fullscreen_buttonItemInactive { - background-position: -153px -24px; -} - -.openlayers-container { - position: relative; -} - -/** - * The following are images that are not in - * this theme (but should be). - */ - -/* -.openlayers-map .olControlNavigationHistory { - background-image: url("img/navigation_history.png"); -} -*/ - -.openlayers-map .olControlOverviewMapRectReplacement { - background-image: url("img/overview_replacement.gif"); -} -.openlayers-map .olControlNavigationHistory { - background-image: url("img/navigation_history.png"); -} -.openlayers-map div.olControlSaveFeaturesItemActive { - background-image: url("img/save_features_on.png"); -} -div.olControlSaveFeaturesItemInactive { - background-image: url("img/save_features_off.png"); -} -.openlayers-map .olControlPanPanel div { - background-image: url("img/pan-panel.png"); -} -.openlayers-map .olPopupCloseBox { - background: url("img/close.gif") no-repeat scroll 0 0 transparent; -} -.openlayers-map .olControlZoomPanel div { - background-image: url("img/zoom-panel.png"); -}