first import

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

View File

@@ -0,0 +1,47 @@
<?php
/**
* OpenLayers Box
*/
class openlayers_simple extends boxes_box {
/**
* Implementation of boxes_content::options_defaults().
*/
public function options_defaults() {
return array(
'map' => ''
);
}
/**
* 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)
);
}
}

View File

@@ -0,0 +1,67 @@
<?php
/**
* @file
* OpenLayers Map Content Type. Displays a Map.
*/
/**
* Plugins are described by creating a $plugin array which will be used
* by the system that includes this file.
*/
$plugin = array(
// And this is just the administrative title.
// All our callbacks are named according to the standard pattern and can be deduced.
'title' => 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'),
);
}
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;
}

View File

@@ -0,0 +1,474 @@
<?php
/**
* @file
*
* OpenLayers default packaged layers
*/
function _openlayers_openlayers_layers() {
global $is_https;
$mapquest_host = $is_https ? '-s.mqcdn.com' : '.mqcdn.com';
$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('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('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('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('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 = 'MapQuests rendering of OpenStreetMap.';
$layer->data = array(
'isBaseLayer' => TRUE,
'attribution' => t('&copy;<a href="@ccbysa">CCBYSA</a> '.
'<a href="@openstreetmap">&copy; OpenStreetMap contributors</a>',
array(
'@openstreetmap' => 'http://www.openstreetmap.org/copyright',
'@ccbysa' => 'http://creativecommons.org/licenses/by-sa/2.0/',
)
) . '. '. t('Tiles Courtesy of <a href="http://www.mapquest.com/">MapQuest</a>.'),
'projection' => array('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' => FALSE,
'resolutions' => openlayers_get_resolutions('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 = 'MapQuests 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 <a href="http://www.mapquest.com/">MapQuest</a>.'),
'projection' => array('900913'),
'layer_type' => 'openlayers_layer_type_xyz',
'url' => array(
'//oatile1' . $mapquest_host . '/naip/${z}/${x}/${y}.png',
'//oatile2' . $mapquest_host . '/naip/${z}/${x}/${y}.png',
'//oatile3' . $mapquest_host . '/naip/${z}/${x}/${y}.png',
'//oatile4' . $mapquest_host . '/naip/${z}/${x}/${y}.png',
),
'wrapDateLine' => TRUE,
);
$layers[$layer->name] = $layer;
$layer = new stdClass();
$layer->api_version = 1;
$layer->name = 'yahoo_satellite';
$layer->title = 'Yahoo Maps Satellite';
$layer->description = 'Yahoo satellite imagery tiles.';
$layer->data = array(
'isBaseLayer' => TRUE,
'type' => 'satellite',
'projection' => array('900913'),
'layer_type' => 'openlayers_layer_type_yahoo',
);
$layers[$layer->name] = $layer;
$layer = new stdClass();
$layer->api_version = 1;
$layer->name = 'yahoo_street';
$layer->title = 'Yahoo Maps Street';
$layer->description = 'Yahoo streets tiles.';
$layer->data = array(
'isBaseLayer' => TRUE,
'type' => 'street',
'projection' => array('900913'),
'layer_type' => 'openlayers_layer_type_yahoo',
);
$layers[$layer->name] = $layer;
$layer = new stdClass();
$layer->api_version = 1;
$layer->name = 'yahoo_hybrid';
$layer->title = 'Yahoo Maps Hybrid';
$layer->description = 'Yahoo hybrid of streets and satellite tiles.';
$layer->data = array(
'isBaseLayer' => TRUE,
'type' => 'hybrid',
'projection' => array('900913'),
'layer_type' => 'openlayers_layer_type_yahoo',
);
$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(
'isBaseLayer' => TRUE,
'type' => 'Road',
'projection' => array('900913'),
'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(
'isBaseLayer' => TRUE,
'type' => 'Aerial',
'projection' => array('900913'),
'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(
'isBaseLayer' => TRUE,
'type' => 'AerialWithLabels',
'projection' => array('900913'),
'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('&copy;<a href="@ccbysa">CCBYSA</a> '.
'<a href="@openstreetmap">&copy; OpenStreetMap contributors</a>',
array(
'@openstreetmap' => 'http://www.openstreetmap.org/copyright',
'@ccbysa' => 'http://creativecommons.org/licenses/by-sa/2.0/',
)
),
'projection' => array('900913'),
'layer_type' => 'openlayers_layer_type_xyz',
'url' => '//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('&copy;<a href="@ccbysa">CCBYSA</a> '.
'<a href="@openstreetmap">&copy; OpenStreetMap contributors</a>',
array(
'@openstreetmap' => 'http://www.openstreetmap.org/copyright',
'@ccbysa' => 'http://creativecommons.org/licenses/by-sa/2.0/',
)
),
'projection' => array('900913'),
'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('&copy;<a href="@ccbysa">CCBYSA</a> '.
'<a href="@openstreetmap">&copy; OpenStreetMap contributors</a>',
array(
'@openstreetmap' => 'http://www.openstreetmap.org/copyright',
'@ccbysa' => 'http://creativecommons.org/licenses/by-sa/2.0/',
)
),
'projection' => array('4326'),
'layer_type' => 'openlayers_layer_type_wms',
'url' => 'http://oam.hypercube.telascience.org/tiles',
'params' => array(
'isBaseLayer' => FALSE,
'layers' => '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' => '<?xml version="1.0" encoding="UTF-8"?><kml xmlns="http://www.opengis.net/kml/2.2"><Placemark><name>Simple placemark</name><description>Attached to the ground. Intelligently places itself at the height of the underlying terrain.</description><Point><coordinates>-122.0822035425683,37.42228990140251,0</coordinates></Point></Placemark></kml>',
'formatOptions' => array(
'extractStyles' => TRUE,
'extractTracks' => FALSE,
'extractAttributes' => TRUE,
),
'projection' => array(
0 => '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('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'),
'maxExtent' => openlayers_get_extent('4326'),
),
);
$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('900913'),
'serverResolutions' => openlayers_get_resolutions('4326'),
'layer_type' => 'openlayers_layer_type_geojson',
'layer_handler' => 'geojson',
'projection' => array('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 = array_combine(range(0, 21), openlayers_get_resolutions('900913'));
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_mapbox',
'osm' => FALSE,
'isBaseLayer' => TRUE,
'type' => 'png',
'resolutions' => array_intersect_key($resolutions, array_flip(range($item['minzoom'], $item['maxzoom']))),
'projection' => array('900913'),
);
$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('Yahoo hybrid of streets and satellite tiles.'),
t('Yahoo satellite imagery tiles.'),
t('Yahoo streets tiles.'),
t('MapQuests rendering of OpenStreetMap.'),
t('MapQuests aerial photo map.'),
);
}
function _mapbox_layers_info() {
$info = array();
$info['mapbox_streets'] = array(
'name'=> t('MapBox Streets'),
'description' => t('MapBox Streets'),
'layername' => 'mapbox-streets',
'minzoom' => 0,
'maxzoom' => 16
);
$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;
}

View File

@@ -0,0 +1,426 @@
<?php
/**
* @file
* This file contains map implementations
*
* @ingroup openlayers
*/
/**
* Map definitions
*
* Internal callback for openlayers map implementation.
*
* @return
* Array of maps
*/
function _openlayers_openlayers_maps() {
$items = array();
// Default map with MapQuest
$default = new stdClass();
$default->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' => '900913',
'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' => '4326',
'maxExtent' => openlayers_get_extent('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(
'seperator' => '',
),
'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' => '900913',
'displayProjection' => '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' => '900913',
'displayProjection' => '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' => '-122.0822035425683, 37.42228990140251',
'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' => '900913',
'displayProjection' => '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' => '-63.281250000007, -20.46819494553',
'zoom' => '2',
),
'restrict' => array(
'restrictextent' => 0,
'restrictedExtent' => '',
),
),
'behaviors' => array(
'openlayers_behavior_attribution' => array(
'seperator' => '',
),
'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' => '900913',
'displayProjection' => '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.093009923589588, 51.500381463117',
'zoom' => '12',
),
'restrict' => array(
'restrictextent' => 0,
'restrictedExtent' => '',
),
),
'behaviors' => array(
'openlayers_behavior_attribution' => array(
'seperator' => '',
),
'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' => '900913',
'displayProjection' => '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;
}

View File

@@ -0,0 +1,228 @@
<?php
/**
* @file
* Processing functions for layers and behaviors
* @ingroup openlayers
*/
/**
* Initialize the layer array into an indexed array of layer objects
*
* @param $layers
* Array of layers to process
* @param $map
* Map array
* @return $layer_data
* Array of initialized layer objects
*/
function _openlayers_layers_process($layers = array(), &$map = array()) {
$layer_data = array();
// Load Layers and assign weights
foreach ($layers as $key => $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->render($map);
$layer_object->data['title'] = $layer_object->title;
$layer_object->data['weight'] = $layer_object->weight;
$layer_data[$layer_object->name] = $layer_object->data;
}
}
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')) {
$behavior = new $class($behaviors[$key], $map);
$rendered[$key] = $behavior->render($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 ( <style_role> : <style_name> | <style_array> )
* @param $layer_styles
* Array of layer styles ( <layer_name> : <style_name> )
* @param $layer_styles_select
* Array of layer styles ( <layer_name> : <style_name> )
* @param $map
* Map array
* @return $processed
* Array of processed styles ( <style_name> => <style_array> )
*/
function _openlayers_styles_process($styles = array(),
$layer_styles = array(), $layer_styles_select = 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 $style) {
if (!isset($processed[$style]) &&
!empty($styles_info[$style]) &&
$info = $styles_info[$style]->data) {
$processed[$style] = $info;
}
}
// Add layer styles select
foreach ($layer_styles_select as $style) {
if (!isset($processed[$style]) &&
!empty($styles_info[$style]) &&
$info = $styles_info[$style]->data) {
$processed[$style] = $info;
}
}
// Add layer styles
foreach ($layer_styles as $style) {
if (!isset($processed[$style]) &&
!empty($styles_info[$style]) &&
$info = $styles_info[$style]->data) {
$processed[$style] = $info;
}
}
// Update URLs to support different types of paths
foreach ($processed as $k => $style) {
$processed[$k] = openlayers_render_style($style);
}
// Run through theme function
$processed = theme('openlayers_styles', array(
'styles' => $processed,
'map' => $map)
);
// Return processed
return $processed;
}
/**
* Render style array.
*
* At the moment, this only makes the external grpahics
* relative.
*/
function openlayers_render_style($style = array()) {
// Relative path conversion
if (!empty($style['externalGraphic'])) {
// Check full URL or absolute path
if (!valid_url($style['externalGraphic'], TRUE)
&& strpos($style['externalGraphic'], '/') !== 0) {
// Make full URL from Drupal path
$style['externalGraphic'] = openlayers_style_path($style['externalGraphic']);
}
}
return $style;
}
/**
* 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() {
return 'openlayers-map-' . substr(md5(uniqid(mt_rand())), 0, 8);
}
/**
* URL Style
*
* Takes in a path and makes full URL for style. Overall, this
* can be handled by url(), but we have to avoid some encoding
* for variable replacement. Note that this is not perfect as
* it will decode values that maybe not specifically part of the
* attribute replacement.
*
* A value that is just a replacement value, ${value} should
* not be run through the file_create_url() function.
*
* @param $path
* Path to process.
* @return
* Processed path.
*/
function openlayers_style_path($path) {
if (strpos($path, '${') !== 0) {
$path = file_create_url($path);
$path = str_replace('%24%7B', '${', $path);
$path = str_replace('%7D', '}', $path);
}
return $path;
}

View File

@@ -0,0 +1,123 @@
<?php
/**
* @file
* This file contains styles implementations
*
* @ingroup openlayers
*/
/**
* Style Implementation
*
* Internal callback for openlayers style implementation.
*
* @return
* Array of styles for an OpenLayers map
*/
function _openlayers_openlayers_styles() {
$styles = array();
// 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;
// Hides features
$style = new stdClass();
$style->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 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;
// 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' => drupal_get_path('module', 'openlayers') .
'/themes/default_dark/img/marker-' . $marker . '.png',
'graphicWidth' => 21,
'graphicHeight' => 25,
'graphicXOffset' => -10,
'graphicYOffset' => -25,
);
$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' => 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' => 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;
return $styles;
}

View File

@@ -0,0 +1,49 @@
<?php
/**
* @file
* This file holds the theme and preprocess functions for openlayers module
*
* @ingroup openlayers
*/
/**
* Preprocess function for openlayers_map
*/
function openlayers_preprocess_openlayers_map(&$variables, $hook) {
$map = $variables['map'];
$map['map_name'] = isset($map['map_name']) ? $map['map_name'] : '';
$css_map_name = drupal_clean_css_identifier($map['map_name']);
$links = array();
if (!empty($map['map_name'])) {
$links = array(
'#type' => 'contextual_links',
'#contextual_links' => array(
'openlayers' => array(
'admin/structure/openlayers/maps/list', array($map['map_name']),
),
)
);
}
$variables['links'] = render($links);
$variables['container']['classes'] = implode(" ", array(
'contextual-links-region',
'openlayers-container',
'openlayers-container-map-' . $css_map_name
));
$variables['container']['width'] = $map['width'];
$variables['container']['height'] = $map['height'];
$variables['container']['id'] = 'openlayers-container-' . $map['id'];
$variables['classes_array'][] = 'openlayers-map-' . $css_map_name;
}
/**
* Theme function to be able to override styles
*/
function theme_openlayers_styles($args) {
return $args['styles'];
}