summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPol Dell'Aiera2014-09-12 13:27:26 +0200
committerPol Dell'Aiera2014-09-12 13:27:26 +0200
commit4a197517651c9616f08553db86d390314c453877 (patch)
treeca129e62c0e32e3f96e93c1ff61b7f57ffeab9c2
parent7ba9e056d3810869f5bad5a9a1574d7ffbb18b22 (diff)
OpenLayers 3.1.x
- Complete rewrite of the module. - OpenLayers 3 JS Library - New user interface, options... - Many things are broken and needs to be worked on, but at least, we have something to start.
-rw-r--r--README.txt123
-rw-r--r--css/openlayers.css81
-rw-r--r--docs/API.txt36
-rw-r--r--docs/BEHAVIORS.txt124
-rw-r--r--docs/CHANGELOG.txt2
-rw-r--r--docs/CUSTOMIZATION.txt46
-rw-r--r--docs/IE.txt61
-rw-r--r--docs/JAVASCRIPT.txt34
-rw-r--r--docs/KML.txt29
-rw-r--r--docs/LAYER_TYPES.txt78
-rw-r--r--docs/OPENLAYERS_VIEWS.txt11
-rw-r--r--docs/RAW_LAYERS.txt65
-rw-r--r--docs/UPGRADE.txt13
-rw-r--r--docs/openlayers.api.php280
-rw-r--r--drush/openlayers.drush.inc10
-rwxr-xr-ximages/druplicon.pngbin0 -> 25329 bytes
-rw-r--r--includes/openlayers.behaviors.inc167
-rw-r--r--includes/openlayers.control.inc5
-rw-r--r--includes/openlayers.default_controls.inc81
-rw-r--r--includes/openlayers.default_interactions.inc166
-rw-r--r--includes/openlayers.default_layers.inc85
-rw-r--r--includes/openlayers.default_maps.inc263
-rw-r--r--includes/openlayers.default_sources.inc97
-rw-r--r--includes/openlayers.interaction.inc5
-rw-r--r--includes/openlayers.layer.inc19
-rw-r--r--includes/openlayers.layer_types.inc92
-rw-r--r--includes/openlayers.layers.inc439
-rw-r--r--includes/openlayers.map.inc84
-rw-r--r--includes/openlayers.maps.inc421
-rw-r--r--includes/openlayers.object.inc72
-rw-r--r--includes/openlayers.projections.inc245
-rw-r--r--includes/openlayers.render.inc181
-rw-r--r--includes/openlayers.source.inc5
-rw-r--r--includes/openlayers.styles.inc138
-rw-r--r--js/openlayers.js554
-rw-r--r--modules/openlayers_ui/includes/openlayers_ui.admin.inc190
-rw-r--r--modules/openlayers_ui/includes/openlayers_ui.layers.inc49
-rw-r--r--modules/openlayers_ui/includes/openlayers_ui.maps.inc287
-rw-r--r--modules/openlayers_ui/includes/openlayers_ui.theme.inc96
-rw-r--r--modules/openlayers_ui/js/openlayers_ui.admin.js53
-rw-r--r--modules/openlayers_ui/js/openlayers_ui.maps.js75
-rw-r--r--modules/openlayers_ui/js/openlayers_ui.styles.js58
-rw-r--r--modules/openlayers_ui/openlayers_ui.css120
-rw-r--r--modules/openlayers_ui/openlayers_ui.install33
-rw-r--r--modules/openlayers_ui/openlayers_ui.module318
-rw-r--r--modules/openlayers_ui/plugins/export_ui/openlayers_controls.inc115
-rw-r--r--modules/openlayers_ui/plugins/export_ui/openlayers_controls_ui.class.php92
-rw-r--r--modules/openlayers_ui/plugins/export_ui/openlayers_interactions.inc115
-rw-r--r--modules/openlayers_ui/plugins/export_ui/openlayers_interactions_ui.class.php92
-rw-r--r--modules/openlayers_ui/plugins/export_ui/openlayers_layers.inc128
-rw-r--r--modules/openlayers_ui/plugins/export_ui/openlayers_layers_ui.class.php272
-rw-r--r--modules/openlayers_ui/plugins/export_ui/openlayers_maps.inc299
-rw-r--r--modules/openlayers_ui/plugins/export_ui/openlayers_maps_ui.class.php731
-rw-r--r--modules/openlayers_ui/plugins/export_ui/openlayers_projections.inc47
-rw-r--r--modules/openlayers_ui/plugins/export_ui/openlayers_projections_ui.class.php88
-rw-r--r--modules/openlayers_ui/plugins/export_ui/openlayers_sources.inc118
-rw-r--r--modules/openlayers_ui/plugins/export_ui/openlayers_sources_ui.class.php92
-rw-r--r--modules/openlayers_ui/plugins/export_ui/openlayers_styles.inc42
-rw-r--r--modules/openlayers_ui/plugins/export_ui/openlayers_styles_ui.class.php472
-rw-r--r--modules/openlayers_ui/themes/openlayers-ui-styles-preview.tpl.php1
-rw-r--r--modules/openlayers_views/includes/openlayers_views.theme.inc32
-rw-r--r--modules/openlayers_views/openlayers_views.info19
-rw-r--r--modules/openlayers_views/openlayers_views.install23
-rw-r--r--modules/openlayers_views/openlayers_views.module173
-rw-r--r--modules/openlayers_views/plugins/layer_types/openlayers_views_image.inc136
-rw-r--r--modules/openlayers_views/plugins/layer_types/openlayers_views_vector.inc146
-rw-r--r--modules/openlayers_views/plugins/layer_types/openlayers_views_vector.js29
-rw-r--r--modules/openlayers_views/views/openlayers_views.views.inc72
-rw-r--r--modules/openlayers_views/views/openlayers_views.views.theme.inc18
-rw-r--r--modules/openlayers_views/views/openlayers_views_plugin_display_openlayers.inc47
-rw-r--r--modules/openlayers_views/views/openlayers_views_style_data.inc467
-rw-r--r--modules/openlayers_views/views/openlayers_views_style_data_image.inc149
-rw-r--r--modules/openlayers_views/views/openlayers_views_style_map.inc74
-rw-r--r--openlayers.info23
-rw-r--r--openlayers.install605
-rw-r--r--openlayers.make.example4
-rw-r--r--openlayers.module1688
-rw-r--r--plugins/behaviors/openlayers_behavior_argparser.inc42
-rw-r--r--plugins/behaviors/openlayers_behavior_argparser.js12
-rw-r--r--plugins/behaviors/openlayers_behavior_attribution.inc42
-rw-r--r--plugins/behaviors/openlayers_behavior_attribution.js12
-rw-r--r--plugins/behaviors/openlayers_behavior_boxselect.inc40
-rw-r--r--plugins/behaviors/openlayers_behavior_boxselect.js59
-rw-r--r--plugins/behaviors/openlayers_behavior_cluster.inc292
-rw-r--r--plugins/behaviors/openlayers_behavior_cluster.js155
-rw-r--r--plugins/behaviors/openlayers_behavior_dragpan.inc56
-rw-r--r--plugins/behaviors/openlayers_behavior_dragpan.js12
-rw-r--r--plugins/behaviors/openlayers_behavior_drawfeatures.css20
-rw-r--r--plugins/behaviors/openlayers_behavior_drawfeatures.inc64
-rw-r--r--plugins/behaviors/openlayers_behavior_drawfeatures.js150
-rw-r--r--plugins/behaviors/openlayers_behavior_fullscreen.css25
-rw-r--r--plugins/behaviors/openlayers_behavior_fullscreen.inc45
-rw-r--r--plugins/behaviors/openlayers_behavior_fullscreen.js43
-rw-r--r--plugins/behaviors/openlayers_behavior_fullscreen.pngbin663 -> 0 bytes
-rw-r--r--plugins/behaviors/openlayers_behavior_geolocate.inc68
-rw-r--r--plugins/behaviors/openlayers_behavior_geolocate.js29
-rw-r--r--plugins/behaviors/openlayers_behavior_graticule.inc84
-rw-r--r--plugins/behaviors/openlayers_behavior_graticule.js11
-rw-r--r--plugins/behaviors/openlayers_behavior_hover.inc47
-rw-r--r--plugins/behaviors/openlayers_behavior_hover.js38
-rw-r--r--plugins/behaviors/openlayers_behavior_keyboarddefaults.inc27
-rw-r--r--plugins/behaviors/openlayers_behavior_keyboarddefaults.js13
-rw-r--r--plugins/behaviors/openlayers_behavior_layerswitcher.inc100
-rw-r--r--plugins/behaviors/openlayers_behavior_layerswitcher.js27
-rw-r--r--plugins/behaviors/openlayers_behavior_layerzoom.inc49
-rw-r--r--plugins/behaviors/openlayers_behavior_layerzoom.js37
-rw-r--r--plugins/behaviors/openlayers_behavior_mapformvalues.inc28
-rw-r--r--plugins/behaviors/openlayers_behavior_mapformvalues.js53
-rw-r--r--plugins/behaviors/openlayers_behavior_mouseposition.inc70
-rw-r--r--plugins/behaviors/openlayers_behavior_mouseposition.js11
-rw-r--r--plugins/behaviors/openlayers_behavior_navigation.inc58
-rw-r--r--plugins/behaviors/openlayers_behavior_navigation.js12
-rw-r--r--plugins/behaviors/openlayers_behavior_panzoom.inc32
-rw-r--r--plugins/behaviors/openlayers_behavior_panzoom.js11
-rw-r--r--plugins/behaviors/openlayers_behavior_panzoombar.inc49
-rw-r--r--plugins/behaviors/openlayers_behavior_panzoombar.js11
-rw-r--r--plugins/behaviors/openlayers_behavior_permalink.inc42
-rw-r--r--plugins/behaviors/openlayers_behavior_permalink.js11
-rw-r--r--plugins/behaviors/openlayers_behavior_popup.inc77
-rw-r--r--plugins/behaviors/openlayers_behavior_popup.js127
-rw-r--r--plugins/behaviors/openlayers_behavior_scaleline.inc35
-rw-r--r--plugins/behaviors/openlayers_behavior_scaleline.js11
-rw-r--r--plugins/behaviors/openlayers_behavior_tooltip.inc53
-rw-r--r--plugins/behaviors/openlayers_behavior_tooltip.js95
-rw-r--r--plugins/behaviors/openlayers_behavior_touch_navigation.inc42
-rw-r--r--plugins/behaviors/openlayers_behavior_touch_navigation.js12
-rw-r--r--plugins/behaviors/openlayers_behavior_zoombox.inc27
-rw-r--r--plugins/behaviors/openlayers_behavior_zoombox.js11
-rw-r--r--plugins/behaviors/openlayers_behavior_zoompanel.inc27
-rw-r--r--plugins/behaviors/openlayers_behavior_zoompanel.js11
-rw-r--r--plugins/behaviors/openlayers_behavior_zoomtolayer.inc53
-rw-r--r--plugins/behaviors/openlayers_behavior_zoomtolayer.js91
-rw-r--r--plugins/behaviors/openlayers_behavior_zoomtomaxextent.inc27
-rw-r--r--plugins/behaviors/openlayers_behavior_zoomtomaxextent.js15
-rw-r--r--plugins/boxes/openlayers_simple.inc47
-rw-r--r--plugins/content_types/icon_openlayers_map.pngbin953 -> 0 bytes
-rw-r--r--plugins/content_types/openlayers_map.inc66
-rw-r--r--plugins/layer_types/openlayers_layer_type_bing.inc104
-rw-r--r--plugins/layer_types/openlayers_layer_type_bing.js15
-rw-r--r--plugins/layer_types/openlayers_layer_type_cloudmade.inc90
-rw-r--r--plugins/layer_types/openlayers_layer_type_cloudmade.js14
-rw-r--r--plugins/layer_types/openlayers_layer_type_dummy.inc37
-rw-r--r--plugins/layer_types/openlayers_layer_type_dummy.js7
-rw-r--r--plugins/layer_types/openlayers_layer_type_geojson.inc116
-rw-r--r--plugins/layer_types/openlayers_layer_type_geojson.js108
-rw-r--r--plugins/layer_types/openlayers_layer_type_google.inc161
-rw-r--r--plugins/layer_types/openlayers_layer_type_google.js25
-rw-r--r--plugins/layer_types/openlayers_layer_type_gpx.inc190
-rw-r--r--plugins/layer_types/openlayers_layer_type_gpx.js20
-rw-r--r--plugins/layer_types/openlayers_layer_type_image.inc158
-rw-r--r--plugins/layer_types/openlayers_layer_type_image.js28
-rw-r--r--plugins/layer_types/openlayers_layer_type_kml.inc189
-rw-r--r--plugins/layer_types/openlayers_layer_type_kml.js57
-rw-r--r--plugins/layer_types/openlayers_layer_type_maptiler.inc79
-rw-r--r--plugins/layer_types/openlayers_layer_type_maptiler.js29
-rw-r--r--plugins/layer_types/openlayers_layer_type_osm.inc73
-rw-r--r--plugins/layer_types/openlayers_layer_type_osm.js12
-rw-r--r--plugins/layer_types/openlayers_layer_type_pointgrid.inc86
-rw-r--r--plugins/layer_types/openlayers_layer_type_pointgrid.js19
-rw-r--r--plugins/layer_types/openlayers_layer_type_raw.inc40
-rw-r--r--plugins/layer_types/openlayers_layer_type_raw.js20
-rw-r--r--plugins/layer_types/openlayers_layer_type_tms.inc118
-rw-r--r--plugins/layer_types/openlayers_layer_type_tms.js31
-rw-r--r--plugins/layer_types/openlayers_layer_type_wms.inc129
-rw-r--r--plugins/layer_types/openlayers_layer_type_wms.js38
-rw-r--r--plugins/layer_types/openlayers_layer_type_wmts.inc148
-rw-r--r--plugins/layer_types/openlayers_layer_type_wmts.js48
-rw-r--r--plugins/layer_types/openlayers_layer_type_xyz.inc93
-rw-r--r--plugins/layer_types/openlayers_layer_type_xyz.js35
-rw-r--r--plugins/openlayers/control/openlayers_control_attribution.inc24
-rw-r--r--plugins/openlayers/control/openlayers_control_attribution.js3
-rw-r--r--plugins/openlayers/control/openlayers_control_defaults.inc14
-rw-r--r--plugins/openlayers/control/openlayers_control_defaults.js3
-rw-r--r--plugins/openlayers/control/openlayers_control_fullscreen.inc14
-rw-r--r--plugins/openlayers/control/openlayers_control_fullscreen.js3
-rw-r--r--plugins/openlayers/control/openlayers_control_mouseposition.inc30
-rw-r--r--plugins/openlayers/control/openlayers_control_mouseposition.js5
-rw-r--r--plugins/openlayers/control/openlayers_control_rotate.inc14
-rw-r--r--plugins/openlayers/control/openlayers_control_rotate.js3
-rw-r--r--plugins/openlayers/control/openlayers_control_scaleline.inc14
-rw-r--r--plugins/openlayers/control/openlayers_control_scaleline.js3
-rw-r--r--plugins/openlayers/control/openlayers_control_zoom.inc14
-rw-r--r--plugins/openlayers/control/openlayers_control_zoom.js3
-rw-r--r--plugins/openlayers/control/openlayers_control_zoomslider.inc14
-rw-r--r--plugins/openlayers/control/openlayers_control_zoomslider.js3
-rw-r--r--plugins/openlayers/control/openlayers_control_zoomtoextent.inc14
-rw-r--r--plugins/openlayers/control/openlayers_control_zoomtoextent.js3
-rw-r--r--plugins/openlayers/interaction/openlayers_interaction_doubleclickzoom.inc13
-rw-r--r--plugins/openlayers/interaction/openlayers_interaction_doubleclickzoom.js3
-rw-r--r--plugins/openlayers/interaction/openlayers_interaction_draganddrop.inc13
-rw-r--r--plugins/openlayers/interaction/openlayers_interaction_draganddrop.js3
-rw-r--r--plugins/openlayers/interaction/openlayers_interaction_dragbox.inc13
-rw-r--r--plugins/openlayers/interaction/openlayers_interaction_dragbox.js3
-rw-r--r--plugins/openlayers/interaction/openlayers_interaction_dragpan.inc13
-rw-r--r--plugins/openlayers/interaction/openlayers_interaction_dragpan.js3
-rw-r--r--plugins/openlayers/interaction/openlayers_interaction_dragrotate.inc13
-rw-r--r--plugins/openlayers/interaction/openlayers_interaction_dragrotate.js3
-rw-r--r--plugins/openlayers/interaction/openlayers_interaction_dragrotateandzoom.inc13
-rw-r--r--plugins/openlayers/interaction/openlayers_interaction_dragrotateandzoom.js3
-rw-r--r--plugins/openlayers/interaction/openlayers_interaction_dragzoom.inc13
-rw-r--r--plugins/openlayers/interaction/openlayers_interaction_dragzoom.js3
-rw-r--r--plugins/openlayers/interaction/openlayers_interaction_draw.inc13
-rw-r--r--plugins/openlayers/interaction/openlayers_interaction_draw.js31
-rw-r--r--plugins/openlayers/interaction/openlayers_interaction_keyboardpan.inc13
-rw-r--r--plugins/openlayers/interaction/openlayers_interaction_keyboardpan.js3
-rw-r--r--plugins/openlayers/interaction/openlayers_interaction_keyboardzoom.inc13
-rw-r--r--plugins/openlayers/interaction/openlayers_interaction_keyboardzoom.js3
-rw-r--r--plugins/openlayers/interaction/openlayers_interaction_modify.inc13
-rw-r--r--plugins/openlayers/interaction/openlayers_interaction_modify.js3
-rw-r--r--plugins/openlayers/interaction/openlayers_interaction_mousewheelzoom.inc13
-rw-r--r--plugins/openlayers/interaction/openlayers_interaction_mousewheelzoom.js3
-rw-r--r--plugins/openlayers/interaction/openlayers_interaction_pinchrotate.inc13
-rw-r--r--plugins/openlayers/interaction/openlayers_interaction_pinchrotate.js3
-rw-r--r--plugins/openlayers/interaction/openlayers_interaction_pinchzoom.inc13
-rw-r--r--plugins/openlayers/interaction/openlayers_interaction_pinchzoom.js3
-rw-r--r--plugins/openlayers/interaction/openlayers_interaction_pointer.inc13
-rw-r--r--plugins/openlayers/interaction/openlayers_interaction_pointer.js3
-rw-r--r--plugins/openlayers/interaction/openlayers_interaction_select.inc13
-rw-r--r--plugins/openlayers/interaction/openlayers_interaction_select.js3
-rw-r--r--plugins/openlayers/interaction/openlayers_interaction_setvalues.inc42
-rw-r--r--plugins/openlayers/interaction/openlayers_interaction_setvalues.js25
-rw-r--r--plugins/openlayers/layer/openlayers_layer_heatmap.inc28
-rw-r--r--plugins/openlayers/layer/openlayers_layer_heatmap.js3
-rw-r--r--plugins/openlayers/layer/openlayers_layer_image.inc93
-rw-r--r--plugins/openlayers/layer/openlayers_layer_image.js3
-rw-r--r--plugins/openlayers/layer/openlayers_layer_tile.inc40
-rw-r--r--plugins/openlayers/layer/openlayers_layer_tile.js3
-rw-r--r--plugins/openlayers/layer/openlayers_layer_vector.inc13
-rw-r--r--plugins/openlayers/layer/openlayers_layer_vector.js3
-rw-r--r--plugins/openlayers/map/openlayers_map_map.inc98
-rw-r--r--plugins/openlayers/map/openlayers_map_map.js13
-rw-r--r--plugins/openlayers/source/openlayers_source_bingmaps.inc30
-rw-r--r--plugins/openlayers/source/openlayers_source_bingmaps.js3
-rw-r--r--plugins/openlayers/source/openlayers_source_geojson.inc49
-rw-r--r--plugins/openlayers/source/openlayers_source_geojson.js3
-rw-r--r--plugins/openlayers/source/openlayers_source_imagestatic.inc13
-rw-r--r--plugins/openlayers/source/openlayers_source_imagestatic.js20
-rw-r--r--plugins/openlayers/source/openlayers_source_mapquest.inc30
-rw-r--r--plugins/openlayers/source/openlayers_source_mapquest.js3
-rw-r--r--plugins/openlayers/source/openlayers_source_osm.inc13
-rw-r--r--plugins/openlayers/source/openlayers_source_osm.js3
-rw-r--r--plugins/openlayers/source/openlayers_source_tilejson.inc23
-rw-r--r--plugins/openlayers/source/openlayers_source_tilejson.js3
-rw-r--r--plugins/openlayers/source/openlayers_source_xyz.inc49
-rw-r--r--plugins/openlayers/source/openlayers_source_xyz.js3
-rw-r--r--plugins/quicktabs/QuickMap.inc48
-rw-r--r--tests/data/openlayers_test.json65
-rw-r--r--tests/data/openlayers_test.kml915
-rw-r--r--tests/features/openlayers_test_example_feature/openlayers_test_example_feature.features.field.inc153
-rw-r--r--tests/features/openlayers_test_example_feature/openlayers_test_example_feature.features.inc36
-rw-r--r--tests/features/openlayers_test_example_feature/openlayers_test_example_feature.info24
-rw-r--r--tests/features/openlayers_test_example_feature/openlayers_test_example_feature.module7
-rw-r--r--tests/features/openlayers_test_example_feature/openlayers_test_example_feature.openlayers_maps.inc131
-rw-r--r--tests/features/openlayers_test_example_feature/openlayers_test_example_feature.views_default.inc202
-rw-r--r--tests/includes/openlayers_test.layers.inc158
-rw-r--r--tests/includes/openlayers_test.maps.inc247
-rw-r--r--tests/includes/openlayers_test.pages.inc64
-rw-r--r--tests/includes/openlayers_test.views.inc178
-rw-r--r--tests/js/openlayers_test.js46
-rw-r--r--tests/js/qunit/index.html81
-rw-r--r--tests/js/qunit/qunit.css119
-rw-r--r--tests/js/qunit/qunit.js1042
-rw-r--r--tests/openlayers.test384
-rw-r--r--tests/openlayers_test.info9
-rw-r--r--tests/openlayers_test.install191
-rw-r--r--tests/openlayers_test.module126
-rw-r--r--themes/default_dark/img/README.txt6
-rwxr-xr-xthemes/default_dark/img/add_point_off.pngbin828 -> 0 bytes
-rwxr-xr-xthemes/default_dark/img/add_point_on.pngbin831 -> 0 bytes
-rw-r--r--themes/default_dark/img/blank.gifbin43 -> 0 bytes
-rw-r--r--themes/default_dark/img/close.gifbin1152 -> 0 bytes
-rw-r--r--themes/default_dark/img/cloud-popup-relative.pngbin7455 -> 0 bytes
-rwxr-xr-xthemes/default_dark/img/drag-rectangle-off.pngbin1421 -> 0 bytes
-rwxr-xr-xthemes/default_dark/img/drag-rectangle-on.pngbin1623 -> 0 bytes
-rwxr-xr-xthemes/default_dark/img/draw_line_off.pngbin680 -> 0 bytes
-rwxr-xr-xthemes/default_dark/img/draw_line_on.pngbin728 -> 0 bytes
-rwxr-xr-xthemes/default_dark/img/draw_point_off.pngbin667 -> 0 bytes
-rwxr-xr-xthemes/default_dark/img/draw_point_on.pngbin710 -> 0 bytes
-rwxr-xr-xthemes/default_dark/img/draw_polygon_off.pngbin789 -> 0 bytes
-rwxr-xr-xthemes/default_dark/img/draw_polygon_on.pngbin844 -> 0 bytes
-rw-r--r--themes/default_dark/img/east-mini.pngbin298 -> 0 bytes
-rwxr-xr-xthemes/default_dark/img/editing_tool_bar.pngbin6767 -> 0 bytes
-rw-r--r--themes/default_dark/img/icons_ol.svg1948
-rw-r--r--themes/default_dark/img/layer-switcher-maximize.pngbin303 -> 0 bytes
-rw-r--r--themes/default_dark/img/layer-switcher-minimize.pngbin367 -> 0 bytes
-rwxr-xr-xthemes/default_dark/img/marker-blue.pngbin561 -> 0 bytes
-rwxr-xr-xthemes/default_dark/img/marker-gold.pngbin554 -> 0 bytes
-rwxr-xr-xthemes/default_dark/img/marker-green.pngbin577 -> 0 bytes
-rwxr-xr-xthemes/default_dark/img/marker-red.pngbin578 -> 0 bytes
-rwxr-xr-xthemes/default_dark/img/marker.pngbin578 -> 0 bytes
-rwxr-xr-xthemes/default_dark/img/measuring-stick-off.pngbin805 -> 0 bytes
-rwxr-xr-xthemes/default_dark/img/measuring-stick-on.pngbin1156 -> 0 bytes
-rwxr-xr-xthemes/default_dark/img/move_feature_off.pngbin676 -> 0 bytes
-rwxr-xr-xthemes/default_dark/img/move_feature_on.pngbin695 -> 0 bytes
-rw-r--r--themes/default_dark/img/north-mini.pngbin298 -> 0 bytes
-rw-r--r--themes/default_dark/img/overview_replacement.pngbin1038 -> 0 bytes
-rw-r--r--themes/default_dark/img/pan-panel.pngbin1377 -> 0 bytes
-rwxr-xr-xthemes/default_dark/img/pan_off.pngbin753 -> 0 bytes
-rwxr-xr-xthemes/default_dark/img/pan_on.pngbin771 -> 0 bytes
-rwxr-xr-xthemes/default_dark/img/panning-hand-off.pngbin891 -> 0 bytes
-rwxr-xr-xthemes/default_dark/img/panning-hand-on.pngbin913 -> 0 bytes
-rwxr-xr-xthemes/default_dark/img/remove_point_off.pngbin709 -> 0 bytes
-rwxr-xr-xthemes/default_dark/img/remove_point_on.pngbin764 -> 0 bytes
-rwxr-xr-xthemes/default_dark/img/ruler.pngbin757 -> 0 bytes
-rw-r--r--themes/default_dark/img/save_features_off.pngbin1206 -> 0 bytes
-rw-r--r--themes/default_dark/img/save_features_on.pngbin1250 -> 0 bytes
-rw-r--r--themes/default_dark/img/slider.pngbin236 -> 0 bytes
-rw-r--r--themes/default_dark/img/south-mini.pngbin310 -> 0 bytes
-rw-r--r--themes/default_dark/img/west-mini.pngbin299 -> 0 bytes
-rw-r--r--themes/default_dark/img/zoom-minus-mini.pngbin229 -> 0 bytes
-rw-r--r--themes/default_dark/img/zoom-panel.pngbin772 -> 0 bytes
-rw-r--r--themes/default_dark/img/zoom-plus-mini.pngbin276 -> 0 bytes
-rw-r--r--themes/default_dark/img/zoom-world-mini.pngbin545 -> 0 bytes
-rw-r--r--themes/default_dark/img/zoombar.pngbin1010 -> 0 bytes
-rw-r--r--themes/default_dark/markers/marker-black-small.pngbin1798 -> 0 bytes
-rw-r--r--themes/default_dark/markers/marker-black.pngbin2163 -> 0 bytes
-rw-r--r--themes/default_dark/openlayers_style.css490
-rw-r--r--themes/default_dark/style.css101
318 files changed, 3570 insertions, 21206 deletions
diff --git a/README.txt b/README.txt
deleted file mode 100644
index a136cfc..0000000
--- 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 4737b98..c434e1f 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 65b3884..0000000
--- 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 09cc8c1..0000000
--- 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 ff045ec..0000000
--- 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 147c28f..0000000
--- 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 11501cd..0000000
--- 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
-<code><meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" /></code>
-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 0393f40..0000000
--- 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 8d600f3..0000000
--- 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 b984506..0000000
--- 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 0bab140..0000000
--- 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 54640fc..0000000
--- 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 f763941..0000000
--- 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 adf8602..0000000
--- a/docs/openlayers.api.php
+++ /dev/null
@@ -1,280 +0,0 @@
-<?php
-
-/**
- * @file
- * Hooks provided by the OpenLayers suite of modules. This file allows
- * hooks to be documented automatically with Doxygen, like on api.drupal.org.
- *
- * @ingroup openlayers
- */
-
-/**
- * OpenLayers Map Preprocess Alter
- *
- * Map array alter. Fired before processing the array, and
- * before checking for errors. The whole array is passed
- * along and will allow you to alter it in any way. This
- * is a good place to alter the map, if the other hooks
- * do not provide the functionality you need.
- *
- * @param $map
- * Map array
- */
-function hook_openlayers_map_preprocess_alter(&$map = array()) {
- // Do something to the $map
-}
-
-/**
- * OpenLayers Map Alter
- *
- * Post-processing Map array alter. Fired after processing the array, and
- * before checking for errors. The whole array is passed
- * along and will allow you to alter it in any way. Adding behaviors,
- * pre-defined layers here will not work. This is good for minor tweaks
- * after the map has been processed.
- *
- * @param $map
- * Map array
- */
-function hook_openlayers_map_alter(&$map = array()) {
- // Do something to the $map
-}
-
-/**
- * OpenLayers Layer Types
- *
- * Provides information on layer types. This is a CTools plugin. Please
- * see LAYER_TYPES.txt in the module for more information.
- *
- * @return
- * Return a nested associative array with the top level
- * being a unique string identifier key which corresponds to the
- * layers' types. The next level being an array of key/value
- * pairs:
- * - "description":
- * - "layer_type":
- */
-function hook_openlayers_layer_types() {
- // Take from openlayers.layer_types.inc
-
- return array(
- 'openlayers_layer_type_google' => 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 46c6647..1991cac 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 0000000..f8ced55
--- /dev/null
+++ b/images/druplicon.png
Binary files differ
diff --git a/includes/openlayers.behaviors.inc b/includes/openlayers.behaviors.inc
deleted file mode 100644
index 99fabab..0000000
--- a/includes/openlayers.behaviors.inc
+++ /dev/null
@@ -1,167 +0,0 @@
-<?php
-
-/**
- * @file
- * This file contains behaviors implementations.
- *
- * @ingroup openlayers
- */
-
-/**
- * Internal callback
- * Helper function to return default behaviors.
- *
- * @return mixed
- */
-function _openlayers_openlayers_behaviors() {
- $behaviors['openlayers_behavior_argparser'] = array(
- 'title' => t('Argument Parser'),
- 'description' => t('Parses Permalink-formatted arguments without adding a
- Permalink link to the map. Permalink is usually similar to:
- ?zoom=1&lat=11&lon=11&layers=B0F'),
- 'type' => 'layer',
- );
- $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. <strong>This is included with the Navigation behavior</strong>. 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 0000000..393af7a
--- /dev/null
+++ b/includes/openlayers.control.inc
@@ -0,0 +1,5 @@
+<?php
+
+abstract class openlayers_control extends openlayers_object {
+
+}
diff --git a/includes/openlayers.default_controls.inc b/includes/openlayers.default_controls.inc
new file mode 100644
index 0000000..dbb2065
--- /dev/null
+++ b/includes/openlayers.default_controls.inc
@@ -0,0 +1,81 @@
+<?php
+
+function openlayers_default_controls() {
+ $export = array();
+
+ $control = new stdClass;
+ $control->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 0000000..e50f641
--- /dev/null
+++ b/includes/openlayers.default_interactions.inc
@@ -0,0 +1,166 @@
+<?php
+
+function openlayers_default_interactions() {
+ $export = array();
+
+ $interaction = new stdClass;
+ $interaction->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 0000000..e1666ca
--- /dev/null
+++ b/includes/openlayers.default_layers.inc
@@ -0,0 +1,85 @@
+<?php
+
+function openlayers_default_layers() {
+ $export = array();
+
+ $layer = new stdClass;
+ $layer->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 0000000..e143032
--- /dev/null
+++ b/includes/openlayers.default_maps.inc
@@ -0,0 +1,263 @@
+<?php
+
+function openlayers_default_maps() {
+ $export = array();
+
+ $map = new stdClass();
+ $map->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 0000000..5e3c7d7
--- /dev/null
+++ b/includes/openlayers.default_sources.inc
@@ -0,0 +1,97 @@
+<?php
+
+function openlayers_default_sources() {
+ $export = array();
+
+ $source = new stdClass;
+ $source->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 0000000..a2210f9
--- /dev/null
+++ b/includes/openlayers.interaction.inc
@@ -0,0 +1,5 @@
+<?php
+
+abstract class openlayers_interaction extends openlayers_object {
+
+}
diff --git a/includes/openlayers.layer.inc b/includes/openlayers.layer.inc
new file mode 100644
index 0000000..e9588c9
--- /dev/null
+++ b/includes/openlayers.layer.inc
@@ -0,0 +1,19 @@
+<?php
+
+abstract class openlayers_layer extends openlayers_object {
+
+ protected $attached = array();
+
+ public function getSource() {
+ return $this->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 78a36e6..0000000
--- a/includes/openlayers.layer_types.inc
+++ /dev/null
@@ -1,92 +0,0 @@
-<?php
-
-/**
- * @file
- * This file contains layer types implementations.
- *
- * @ingroup openlayers
- */
-
-/**
- * Internal callback
- * Helper function to return default layer types.
- *
- * @return mixed
- */
-function _openlayers_openlayers_layer_types() {
- $layer_types['openlayers_layer_type_bing'] = array(
- 'title' => t('Bing'),
- 'description' => t('Microsoft Bing.')
- );
- $layer_types['openlayers_layer_type_cloudmade'] = array(
- 'title' => t('CloudMade'),
- 'description' => t('<a href="!url">CloudMade</a> 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 <code>hook_openlayers_map_preprocess</code> for example).')
- );
- $layer_types['openlayers_layer_type_geojson'] = array(
- 'title' => t('GeoJSON'),
- 'description' => t('Provides a vector layer based on <a href="!url">GeoJSON</a>.', 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('<a href="!url">KML</a> overlay.', array('!url' => 'http://en.wikipedia.org/wiki/Keyhole_Markup_Language')),
- );
- $layer_types['openlayers_layer_type_maptiler'] = array(
- 'title' => t('MapTiler'),
- 'description' => t('<a href="!url">MapTiler</a> 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('<a href="!url">Tile Map Service</a>', array('!url' => 'http://en.wikipedia.org/wiki/Tile_Map_Service')),
- );
- $layer_types['openlayers_layer_type_wms'] = array(
- 'title' => t('WMS'),
- 'description' => t('<a href="!url">Web Map Service</a>', array('!url' => 'http://en.wikipedia.org/wiki/Web_Map_Service')),
- );
- $layer_types['openlayers_layer_type_wmts'] = array(
- 'title' => t('WMTS'),
- 'description' => t('<a href="!url">Web Map Tile Service</a>', 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 5ad57b6..0000000
--- a/includes/openlayers.layers.inc
+++ /dev/null
@@ -1,439 +0,0 @@
-<?php
-
-/**
- * @file
- * This file contains layers implementations.
- *
- * @ingroup openlayers
- */
-
-/**
- * Internal callback
- * Helper function to return default layers.
- *
- * @return mixed
- */
-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('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('&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('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 <a href="http://www.mapquest.com/">MapQuest</a>.'),
- '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('&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('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('&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('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('&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('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' => '<?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(
- '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 0000000..3277b4e
--- /dev/null
+++ b/includes/openlayers.map.inc
@@ -0,0 +1,84 @@
+<?php
+
+class openlayers_map extends openlayers_object {
+
+ protected $id;
+ protected $attached = array();
+
+ public function getId() {
+ if (isset($this->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 c4166e4..0000000
--- a/includes/openlayers.maps.inc
+++ /dev/null
@@ -1,421 +0,0 @@
-<?php
-
-/**
- * @file
- * This file contains map implementations.
- *
- * @ingroup openlayers
- */
-
-/**
- * Internal callback
- * Helper function to return default maps.
- *
- * @return mixed
- */
-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' => '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 0000000..a0631de
--- /dev/null
+++ b/includes/openlayers.object.inc
@@ -0,0 +1,72 @@
+<?php
+
+abstract class openlayers_object {
+
+ public $machine_name;
+ public $name;
+ public $description;
+ public $class;
+ public $options = array();
+ protected $attached = array();
+
+ function defauts_properties() {
+ return array(
+ 'machine_name' => '',
+ '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 e505102..0000000
--- a/includes/openlayers.projections.inc
+++ /dev/null
@@ -1,245 +0,0 @@
-<?php
-
-/**
- * @file
- * This file contains projections implementations.
- *
- * @ingroup openlayers
- */
-
-/**
- * Internal callback
- * Helper function to return default projections.
- *
- * @return mixed
- */
-function _openlayers_openlayers_projections() {
- $projections = array();
-
- // CH1903+ / LV95
- $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: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 a867ef3..0000000
--- a/includes/openlayers.render.inc
+++ /dev/null
@@ -1,181 +0,0 @@
-<?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->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 ( <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(), $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 0000000..9257d83
--- /dev/null
+++ b/includes/openlayers.source.inc
@@ -0,0 +1,5 @@
+<?php
+
+abstract class openlayers_source extends openlayers_object {
+
+}
diff --git a/includes/openlayers.styles.inc b/includes/openlayers.styles.inc
deleted file mode 100644
index 241782d..0000000
--- a/includes/openlayers.styles.inc
+++ /dev/null
@@ -1,138 +0,0 @@
-<?php
-
-/**
- * @file
- * This file contains styles implementations.
- *
- * @ingroup openlayers
- */
-
-/**
- * Internal callback
- * Helper function to return default styles.
- *
- * @return mixed
- */
-function _openlayers_openlayers_styles() {
- $styles = array();
-
- // 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 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 7632a3d..6a7c75c 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 1fca365..46267e6 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('<p>By default the your site will point to a hosted version of the
- OpenLayers library at %ol_api_url.</p>
- <p>For better performance and reliability, you should use an internal version of the library.
- <a href="!ol_url">Download the OpenLayers library</a>, and add it to your Drupal installation.
- Use the new drush command \'<em>dl-openlayers</em>\' to download it and place it at the right place automatically.
- If you download the library manually, then place it in the <em>libraries/openlayers</em> folder and new options will appear under <em>OpenLayers source type</em> 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.</p>
- <ul>
- <li>The default suggested, compatible version: <strong>%suggested_api</strong></li>
- <li>The default suggested, compatible hosted URL: <strong>%ol_api_url</strong></li>
- <li>Your version found from client-side, Javascript check: <strong>%client</strong></li>
- </ul>',
- 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('
- <ul>
- <li>Select internal to load the OpenLayers library from your drupal installation.
- <br/>You can use the drush command <em>dl-openlayers</em> to download the library and place it at the right place automatically.</li>
- <li>Select external to load it from Internet.</li>
- </ul>
- <p>You should use the <a href="!libraries">libraries module</a> to enable the internal loading of the library.</p>
- ', 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 (<em>version >= 2.12</em>) has different variants. Select the one you prefer for your installation. <b>Warning: OpenLayers is design to only work for original variants.</b> 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' => '</div>',
'#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 5051b16..0000000
--- a/modules/openlayers_ui/includes/openlayers_ui.layers.inc
+++ /dev/null
@@ -1,49 +0,0 @@
-<?php
-
-/**
- * @file
- * This file holds the functions handling layers in the
- * Openlayers UI.
- *
- * @ingroup openlayers
- */
-
-/**
- * Layer-wide-settings form
- */
-function openlayers_ui_layers_settings($form, &$form_state, $layer = NULL) {
- $form = array();
-
- foreach (openlayers_layer_types() as $name => $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 0f2f400..0000000
--- a/modules/openlayers_ui/includes/openlayers_ui.maps.inc
+++ /dev/null
@@ -1,287 +0,0 @@
-<?php
-
-/**
- * @file
- * This file holds the functions handling maps in the
- * Openlayers UI.
- *
- * @ingroup openlayers
- */
-
-/**
- * Form submit for map add form, for the projection add ahah
- */
-function openlayers_ui_maps_add_projection_submit($form, &$form_state) {
- unset($form_state['submit_handlers']);
- form_execute_handlers('submit', $form, $form_state);
- $form_state['rebuild'] = TRUE;
-}
-
-
-/**
- * OpenLayers AHAH
- *
- * Function to handle the AHAH request of the openlayers form
- */
-function openlayers_ui_map_ahah() {
- $form_state = array('storage' => 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 2d2a542..0000000
--- a/modules/openlayers_ui/includes/openlayers_ui.theme.inc
+++ /dev/null
@@ -1,96 +0,0 @@
-<?php
-
-/**
- * @file
- * This file holds the theme functions for openlayers ui module
- *
- * @ingroup openlayers
- */
-
-/**
- * Theme function for form description of layers
- */
-function theme_openlayers_ui_form_layer_description($args) {
- if (!empty($args['layer_link'])) {
- $args['layer_title'] = l($args['layer_title'], $args['layer_link'], array('query' => drupal_get_destination()));
- }
- return $args['layer_title'] . ($args['layer_description'] ?
- ' <span class="openlayers-form-layer-description">' .
- $args['layer_description'] . '</span>' :
- '');
-}
-
-/**
- * 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 .= " - <span class='openlayers-form-projection-description'>$names</span>";
- }
- 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 4f4f827..0000000
--- 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 893f57e..0000000
--- 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 3fce3d0..0000000
--- 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('<div class="openlayers-ui-style-preview-top"></div>')
- .append('<div class="openlayers-ui-style-preview-left"></div>');
- }
- });
- }
-};
-
-})(jQuery);
diff --git a/modules/openlayers_ui/openlayers_ui.css b/modules/openlayers_ui/openlayers_ui.css
deleted file mode 100644
index 6b1439b..0000000
--- 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 719c620..b3d9bbc 100644
--- a/modules/openlayers_ui/openlayers_ui.install
+++ b/modules/openlayers_ui/openlayers_ui.install
@@ -1,34 +1 @@
<?php
-
-/**
- * @file
- * This file holds the functions for the installing
- * and enabling of the openlayers_ui module.
- *
- * @ingroup openlayers
- */
-
-/**
- * Implementation of hook_uninstall().
- */
-function openlayers_ui_uninstall() {
- // Get module variables
- global $conf;
- foreach (array_keys($conf) as $key) {
- // Find variables that have the module prefix
- if (strpos($key, 'openlayers_ui_') === 0) {
- variable_del($key);
- }
- }
-}
-
-/**
- * This is needed to rebuild menu items and set parent correctly on
- * Openlayers tabs when using CTools Export UI and have a good breadcrumb.
- * Thanks @Dave Reid for the help !
- */
-function openlayers_ui_update_7201() {
- db_delete('menu_links')
- ->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 2a80755..f525976 100644
--- a/modules/openlayers_ui/openlayers_ui.module
+++ b/modules/openlayers_ui/openlayers_ui.module
@@ -1,111 +1,4 @@
<?php
-/**
- * @file
- * Main Drupal module file for the OpenLayers UI module
- *
- * @ingroup openlayers
- */
-
-/**
- * Implements hook_init().
- */
-function openlayers_ui_init() {
- // For backwards compability for the change from maps to presets
- // in the 7.x-2.x version, we want to make it really obvious that
- // administrators and developers should be updating their maps
- //
- // There are also other requirement checks like the compatible
- // suggestlibrary version.
- if (strpos($_GET['q'], 'admin/structure/openlayers') === 0) {
- include_once DRUPAL_ROOT . '/includes/install.inc';
- drupal_load_updates();
- module_load_include('install', 'openlayers', 'openlayers');
- $reqs = openlayers_requirements('runtime');
- foreach ($reqs as $r) {
- if ($r['severity'] != REQUIREMENT_OK) {
- $severity = $r['severity'] == REQUIREMENT_WARNING ? 'warning' : 'error';
- drupal_set_message(t('<strong>!title</strong> !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('<div class="openlayers-ui-version-check-message">' .
- t('Checking client library via Javascript...') . '</div>', 'none');
- }
- }
-}
-
-/**
- * Implements hook_help
- */
-function openlayers_ui_help($path, $arg) {
- switch ($path) {
- case 'admin/help#openlayers_ui':
- return '<p>' . t('Provides a user interface to manage OpenLayers maps.') . '</p>';
- case 'admin/structure/openlayers':
- return '<p>' . t('Configure where Drupal finds
- the OpenLayers javascript library. Using a local or <a href="@olb">compacted
- version</a> 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')) . '</p>';
- case 'admin/structure/openlayers/styles':
- return '<p>' . t('OpenLayer styles are stored versions of
- <a href="@ols">javascript StyleMap objects</a>, 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')) . '</p>';
- case 'admin/structure/openlayers/styles/add':
- return '<p>' . 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')
- . '</p>';
- case 'admin/structure/openlayers/maps':
- return '<p>' . 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.') . '</p>';
- case 'admin/structure/openlayers/layers':
- return '<p>' . 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.') . '</p>';
- case 'admin/structure/openlayers/projections':
- return t('<p><a href="http://en.wikipedia.org/wiki/Map_projection">Projections</a> describe how the earth is flattened to a map image. They define coordinate systems for data retrieval.</p>');
- case 'admin/structure/openlayers/layers/settings':
- return '<p>' . 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.') . '</p>';
-
- }
-}
-
-/**
- * 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' => "<div class='openlayers-dependency-flag'>"
- . "<span class='openlayers-dependency-value'>$dependency</span>"
- . "<span class='openlayers-dependency-broken'>"
- . t('Dependency not found:') . ' ' . $dependency . "</span>"
- . "</div>"
- );
- }
- 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 0000000..c3f1e20
--- /dev/null
+++ b/modules/openlayers_ui/plugins/export_ui/openlayers_controls.inc
@@ -0,0 +1,115 @@
+<?php
+/**
+ * CTools Export UI required function for plugin definition
+ * See function ctools_plugin_load_includes() in the module ctools.
+ */
+function openlayers_ui_openlayers_controls_ctools_export_ui() {
+ return array(
+ 'schema' => '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('<Choose the control type>'));
+ 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 0000000..3c8a7e1
--- /dev/null
+++ b/modules/openlayers_ui/plugins/export_ui/openlayers_controls_ui.class.php
@@ -0,0 +1,92 @@
+<?php
+
+class openlayers_controls_ui extends ctools_export_ui {
+
+ /**
+ * 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/controls']['type'] = MENU_LOCAL_TASK;
+ $items['admin/structure/openlayers/controls']['weight'] = 1;
+ }
+
+ /**
+ * 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-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 0000000..3981fb6
--- /dev/null
+++ b/modules/openlayers_ui/plugins/export_ui/openlayers_interactions.inc
@@ -0,0 +1,115 @@
+<?php
+/**
+ * CTools Export UI required function for plugin definition
+ * See function ctools_plugin_load_includes() in the module ctools.
+ */
+function openlayers_ui_openlayers_interactions_ctools_export_ui() {
+ return array(
+ 'schema' => '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('<Choose the interaction type>'));
+ 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 0000000..6259b83
--- /dev/null
+++ b/modules/openlayers_ui/plugins/export_ui/openlayers_interactions_ui.class.php
@@ -0,0 +1,92 @@
+<?php
+
+class openlayers_interactions_ui extends ctools_export_ui {
+
+ /**
+ * 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/interactions']['type'] = MENU_LOCAL_TASK;
+ $items['admin/structure/openlayers/interactions']['weight'] = 2;
+ }
+
+ /**
+ * 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-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 7d7a82d..a293a20 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('<Choose the layer type>'));
+ 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('<Choose the source>'));
+ 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 89129e2..904cf55 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 @@
<?php
-/**
- * @file
- */
class openlayers_layers_ui extends ctools_export_ui {
- function edit_form(&$form, &$form_state) {
- parent::edit_form($form, $form_state);
-
- $layer_types = openlayers_layer_types();
- $options = array('' => 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 a4dc3e7..6d4ef76 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 a0eb77b..9bb756e 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 @@
<?php
-/**
- * @file
- */
class openlayers_maps_ui extends ctools_export_ui {
- function edit_form(&$form, &$form_state) {
- parent::edit_form($form, $form_state);
-
- $map = $form_state['item'];
- if (empty($map->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 <em>Preview</em>
- 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' => '<p>' . t('Turn map previews on by default on the !link.',
- array('!link' => l(t('Settings page'), 'admin/structure/openlayers/settings'))) . '</p>',
- );
- }
-
- // 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('<p>The path to a directory of UI graphics. Use any of the
- following:</p>
- <ul>
- <li><strong>Leave blank</strong> for default graphics as provided
- by the OpenLayers library. </li>
- <li><strong>Relative Drupal path</strong> a path without leading slash and
- the base path will be prepended, ex. "sites/all/themes/path/to/images/"</li>
- <li><strong>Absolute path</strong> a path with leading slash and path will
- start from sites root directory, ex. "/path/to/images/"</li>
- <li><strong>Full URL</strong> such as "http://example.com/image/"</li>
- </ul>
- <p>Always include trailing slash. The default path provided with this module
- is: %default</p>
- <p><strong>This is actually a setting for the OpenLayers
- object and will affect all maps on the same page.</strong></p>',
- 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('<p>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:</p>
- <ul>
- <li><strong>Leave blank</strong> for default hosted OpenLayers which
- is !link</li>
- <li><strong>Relative Drupal path</strong> a path without leading slash and
- the base path will be prepended, ex. "sites/all/themes/path/to/style.css"</li>
- <li><strong>Absolute path</strong> a path with leading slash and path will
- start from sites root directory, ex. "/path/to/style.css"</li>
- <li><strong>Full URL</strong> such as "http://example.com/style.css"</li>
- </ul>
- <p>The default path provided with this module
- is: %default</p>
- <p><strong>This is actually a setting for the OpenLayers
- object and will affect all maps on the same page.</strong></p>',
- 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('<p>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:</p>
- <ul>
- <li><strong>Leave blank</strong> no proxy path.</li>
- <li><strong>Relative Drupal path</strong> a path without leading slash and
- the base path will be prepended, ex. "proxy?request="</li>
- <li><strong>Absolute path</strong> a path with leading slash and path will
- start from sites root directory, ex. "/cgi_proxy?request="</li>
- <li><strong>Full URL</strong> such as "http://example.com/proxy?request="</li>
- </ul>
- <p><strong>This is actually a setting for the OpenLayers
- object and will affect all maps on the same page.</strong></p>'
- ),
- '#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.
- <strong>Shift-drag</strong> 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' => '<div class="form-item openlayers-center-helpmap" style="display:block">' . render($build) . '</div>'
- );
- $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 <em>longitude,latitude</em>.'),
- '#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 <strong>holding the shift key and dragging a box</strong> 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('<p><strong>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.</strong></p>
- <p>Select the !link_proj for your map. The list next
- to each projection is the layers that support this projection.</p>',
- 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('<strong>Add Data Overlays</strong>: You can add regular
- overlays, like <a href="!geojson">GeoJSON</a> or <a href="!kml">KML</a>,
- or you can utilize <a href="!views_url">Views</a> to create data overlays.
- To create a Views-based overlay, you must choose the <strong>OpenLayers
- Data Overlay Display Type</strong>, and then explicitly set the the
- <strong>same for the Format</strong>. The options in the <em>Format
- Settings</em> will only use fields you have added. To learn more, take
- a look at the <a href="!online_url">online documentation on Drupal.org</a>.',
- 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 <a href="!views_url">Views</a> module to
- display your map as page or in a block. By creating a new Views Display of
- type <strong>Page</strong> or <strong>Block</strong> you can then choose
- the <strong>OpenLayers Map Format</strong>. For more details, check out
- the <a href="!online_url">online documentation on Drupal.org</a>.',
- 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 <code>openlayers_render_map()</code>.
- Most of the code is well documented. To learn how to extend the module,
- take a look at the <a href="!online_url">online documentation on
- Drupal.org</a> as well as the files in the <code>docs/</code> 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 4166c07..0000000
--- a/modules/openlayers_ui/plugins/export_ui/openlayers_projections.inc
+++ /dev/null
@@ -1,47 +0,0 @@
-<?php
-/**
- * @file Binds openlayers_projections with ctools
- */
-
-/**
- * @return array
- */
-function openlayers_ui_openlayers_projections_ctools_export_ui() {
- return array(
- 'schema' => '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 e9a1e1e..0000000
--- a/modules/openlayers_ui/plugins/export_ui/openlayers_projections_ui.class.php
+++ /dev/null
@@ -1,88 +0,0 @@
-<?php
-class openlayers_projections_ui extends ctools_export_ui {
- function edit_form(&$form, &$form_state) {
- parent::edit_form($form, $form_state);
-
- // Hide internal identifier from user
- $form['info']['identifier']['#type'] = 'hidden';
- $form['info']['identifier']['#required'] = FALSE;
-
- $projectionData = $form_state['item'];
-
- $form['info']['authority'] = array(
- '#id' => '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 0000000..57e4085
--- /dev/null
+++ b/modules/openlayers_ui/plugins/export_ui/openlayers_sources.inc
@@ -0,0 +1,118 @@
+<?php
+/**
+ * CTools Export UI required function for plugin definition
+ * See function ctools_plugin_load_includes() in the module ctools.
+ */
+function openlayers_ui_openlayers_sources_ctools_export_ui() {
+ return array(
+ 'schema' => '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('<Choose the source type>'));
+ 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 0000000..27b733b
--- /dev/null
+++ b/modules/openlayers_ui/plugins/export_ui/openlayers_sources_ui.class.php
@@ -0,0 +1,92 @@
+<?php
+
+class openlayers_sources_ui extends ctools_export_ui {
+
+ /**
+ * 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/sources']['type'] = MENU_LOCAL_TASK;
+ $items['admin/structure/openlayers/sources']['weight'] = -1;
+ }
+
+ /**
+ * 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-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 6fdfc16..0000000
--- a/modules/openlayers_ui/plugins/export_ui/openlayers_styles.inc
+++ /dev/null
@@ -1,42 +0,0 @@
-<?php
-/**
- * CTools Export UI required function for plugin definition
- * See function ctools_plugin_load_includes() in the module ctools.
- */
-function openlayers_ui_openlayers_styles_ctools_export_ui() {
- return array(
- 'schema' => '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 99f4153..0000000
--- a/modules/openlayers_ui/plugins/export_ui/openlayers_styles_ui.class.php
+++ /dev/null
@@ -1,472 +0,0 @@
-<?php
-/**
- * @file
- */
-
-class openlayers_styles_ui extends ctools_export_ui {
-
- function edit_form(&$form, &$form_state) {
- parent::edit_form($form, $form_state);
-
- $style = $form_state['item'];
- if (empty($style->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:
- <ul><li>Full path, such as http://example.com/icon.png</li>
- <li>Relative Drupal path, such as sites/all/modules/example/icon.png</li>
- <li>Absolute path, such as /icon.png (though this is not suggested for maintainability reasons)</li></ul>'),
- '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
- <a href="!url">CSS cursor styles</a>.', 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('<code>@fid</code> <em>(from view @viewname and display @displayname.)</em>', 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' => '<p class="no-fields-message">',
- '#markup' => t('There are no available fields to use as tokens.'),
- '#suffix' => '</p>',
- );
-
- $form['available_fields']['fields_instruction'] = array(
- '#access' => user_access('administer views'),
- '#prefix' => '<p class="no-fields-instruction">',
- '#markup' => t(
- 'Go to the <a !attributes>Views administration</a> page and create an "OpenLayers Data Overlay" display.',
- array(
- '!attributes' => drupal_attributes(array('href' => url('admin/structure/views'))),
- )
- ),
- '#suffix' => '</p>',
- );
- }
-
- // 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 c1f4f86..0000000
--- a/modules/openlayers_ui/themes/openlayers-ui-styles-preview.tpl.php
+++ /dev/null
@@ -1 +0,0 @@
-<div id="<?php print $style->name; ?>" class="openlayers-ui-style-preview"></div>
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 8f0b308..0000000
--- a/modules/openlayers_views/includes/openlayers_views.theme.inc
+++ /dev/null
@@ -1,32 +0,0 @@
-<?php
-
-/**
- * @file
- * This file holds the theme functions for openlayers_views module
- *
- * @ingroup openlayers
- */
-
-/**
- * Theme function for openlayers_views_group_display_item
- *
- * Output of OpenLayers View diplay plugin for grouped items.
- */
-function theme_openlayers_views_group_display_item($args) {
- // Build output
- return ((!empty($args['name'])) ?
- '<h2 class="point-title openlayers-views-group-feature-name">'
- . $args['name']
- . '</h2>' : '') .
- (!empty($args['description']) ?
- '<div class="point-content openlayers-views-group-feature-description">'
- . $args['description']
- . '</div>' : '');
-}
-
-/**
- * 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 1072afd..0000000
--- 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 62b9c71..0000000
--- a/modules/openlayers_views/openlayers_views.install
+++ /dev/null
@@ -1,23 +0,0 @@
-<?php
-
-/**
- * @file
- * This file holds the functions for the installing
- * and enabling of the openlayers_views module.
- *
- * @ingroup openlayers
- */
-
-/**
- * Implementation of hook_uninstall().
- */
-function openlayers_views_uninstall() {
- // Get module variables
- global $conf;
- foreach (array_keys($conf) as $key) {
- // Find variables that have the module prefix
- if (strpos($key, 'openlayers_views_') === 0) {
- variable_del($key);
- }
- }
-}
diff --git a/modules/openlayers_views/openlayers_views.module b/modules/openlayers_views/openlayers_views.module
deleted file mode 100644
index f9b7cba..0000000
--- a/modules/openlayers_views/openlayers_views.module
+++ /dev/null
@@ -1,173 +0,0 @@
-<?php
-
-/**
- * @file
- * This file holds the main Drupal hook functions
- * and private functions for the openlayers_views module.
- *
- * @ingroup openlayers
- */
-
-/**
- * Implements hook_help().
- */
-function openlayers_views_help($path, $arg) {
- switch ($path) {
- case 'admin/help#openlayers_views':
- return '<p>'
- . t('The OpenLayers Views module provides a set of plugins '
- . 'for Views.')
- . '</p>';
- }
-}
-
-/**
- * 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 978d2c8..0000000
--- a/modules/openlayers_views/plugins/layer_types/openlayers_views_image.inc
+++ /dev/null
@@ -1,136 +0,0 @@
-<?php
-/**
- * @file
- * OpenLayers Views Vector Layer Type
- */
-
-/**
- * Ctools plugin definition
- */
-function openlayers_views_openlayers_views_image_openlayers_layer_types() {
- return array(
- 'title' => 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('' => '<none>');
- 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 bafab69..0000000
--- a/modules/openlayers_views/plugins/layer_types/openlayers_views_vector.inc
+++ /dev/null
@@ -1,146 +0,0 @@
-<?php
-/**
- * @file
- * OpenLayers Views Vector Layer Type
- */
-
-/**
- * Ctools plugin definition
- */
-function openlayers_views_openlayers_views_vector_openlayers_layer_types() {
- return array(
- 'title' => 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('' => '<none>');
- 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 1716594..0000000
--- 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 7ab96ac..0000000
--- a/modules/openlayers_views/views/openlayers_views.views.inc
+++ /dev/null
@@ -1,72 +0,0 @@
-<?php
-
-/**
- * @file
- * This file holds main views functions for the openlayers_views module.
- *
- * @ingroup openlayers
- */
-
-/**
- * Implementation of hook_views_plugins().
- */
-function openlayers_views_views_plugins() {
- return array(
- 'module' => '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 fc166ef..0000000
--- a/modules/openlayers_views/views/openlayers_views.views.theme.inc
+++ /dev/null
@@ -1,18 +0,0 @@
-<?php
-
-/**
- * @file
- * This file holds views theme function for style plugin.
- *
- * @ingroup openlayers
- */
-
-/**
- * Implementation of theme function
- */
-function theme_openlayers_views_map($args) {
- return (isset($args['title']) ? '<h3>' . $args['title'] . '</h3>' : '') .
- '<div class="openlayers-views-map">'
- . $args['map']
- . '</div>';
-}
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 c08ed34..0000000
--- a/modules/openlayers_views/views/openlayers_views_plugin_display_openlayers.inc
+++ /dev/null
@@ -1,47 +0,0 @@
-<?php
-
-/**
- * @file
- * Display plugin for OpenLayers Data
- *
- * @ingroup openlayers
- */
-
-class openlayers_views_plugin_display_openlayers extends views_plugin_display {
- function uses_breadcrumb() { return FALSE; }
- function get_style_type() { return 'openlayers'; }
-
- /**
- * OpenLayers data features are used directly in the map object.
- */
- function execute() {
- return $this->view->render();
- }
-
- function preview() {
- return '<pre>' . check_plain($this->view->render()) . '</pre>';
- }
-
- 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 f85e1fe..0000000
--- a/modules/openlayers_views/views/openlayers_views_style_data.inc
+++ /dev/null
@@ -1,467 +0,0 @@
-<?php
-
-/**
- * @file
- * This file holds style plugin for OpenLayers Views
- *
- * @ingroup openlayers
- */
-
-/**
- * @class
- * Extension of the Views Plugin Style for OpenLayers
- *
- * This class extended the default views plugin class to provide
- * a style plugin for the Open Layers module.
- */
-class openlayers_views_style_data extends views_plugin_style {
-
- /**
- * Render the map features.
- *
- * Overrides views_plugin_style->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' => '<div class="error form-item description">',
- '#suffix' => '</div>',
- );
- 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 720b471..0000000
--- a/modules/openlayers_views/views/openlayers_views_style_data_image.inc
+++ /dev/null
@@ -1,149 +0,0 @@
-<?php
-
-/**
- * @file
- * This file holds style plugin for OpenLayers Views
- *
- * @ingroup openlayers
- */
-
-/**
- * @class
- * Extension of the Views Plugin Style for OpenLayers
- *
- * This class extended the default views plugin class to provide
- * a style plugin for the Open Layers module.
- */
-class openlayers_views_style_data_image extends views_plugin_style {
-
- /**
- * Set default options
- *
- * Overrides views_plugin_style->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' => '<div class="error form-item description">',
- '#suffix' => '</div>',
- );
- 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 e19fec9..0000000
--- a/modules/openlayers_views/views/openlayers_views_style_map.inc
+++ /dev/null
@@ -1,74 +0,0 @@
-<?php
-
-/**
- * @file
- * This file holds style plugin for OpenLayers Views
- *
- * @ingroup openlayers
- */
-
-/**
- * @class
- * Extension of the Views Plugin Syle for OpenLayers
- *
- * This class extended the default views plugin class to provide
- * a style plugin for the Open Layers module.
- */
-class openlayers_views_style_map extends views_plugin_style {
- /**
- * Set default options
- */
- function option_definition() {
- $options = parent::option_definition();
- $options['map'] = array(
- 'default' => 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 a9ead1c..0721d4c 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 c0d48bf..eed2ae6 100644
--- a/openlayers.install
+++ b/openlayers.install
@@ -1,20 +1,6 @@
<?php
/**
- * @file
- * This file holds the functions for the installing
- * and enabling of the openlayers module.
- *
- * @ingroup openlayers
- */
-
-/**
- * Implements hook_install().
- */
-function openlayers_install() {
-}
-
-/**
* Implements hook_uninstall().
*/
function openlayers_uninstall() {
@@ -37,26 +23,29 @@ function openlayers_schema() {
$schema['openlayers_maps'] = array(
'description' => '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 <a href="@url">read the upgrade page</a>, 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 <a href="@url">read the upgrade page</a>, 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 c5316f0..e5d3518 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 74da678..205449b 100644
--- a/openlayers.module
+++ b/openlayers.module
@@ -1,1570 +1,229 @@
<?php
-/**
- * @defgroup openlayers OpenLayers provides an API and
- * Modules to interface with OpenLayers
- */
+include 'includes/openlayers.object.inc';
+include 'includes/openlayers.interaction.inc';
+include 'includes/openlayers.map.inc';
+include 'includes/openlayers.control.inc';
+include 'includes/openlayers.layer.inc';
+include 'includes/openlayers.source.inc';
-/**
- * @file
- * Main OpenLayers API File
- *
- * This file holds the main Drupal hook functions,
- * and the openlayers API functions for the openlayers module.
- *
- * @ingroup openlayers
- */
-
-/**
- * OpenLayers hosted default library.
- */
-define('OPENLAYERS_DEFAULT_LIBRARY', 'http://openlayers.org/api/2.13/OpenLayers.js');
-
-/**
- * OpenLayers library compatible suggestion.
- */
-define('OPENLAYERS_SUGGESTED_LIBRARY', 2.13);
-
-/**
- * OpenLayers hosted API version. What version is used when going to
- * http://openlayers.org/api/OpenLayers.js
- */
-define('OPENLAYERS_HOSTED_API_LIBRARY', 2.13);
-
-/**
- * Implements hook_help().
- */
-function openlayers_help($path, $arg) {
- switch ($path) {
- case 'admin/help#openlayers':
- return '<p>' . t('The OpenLayers module is the base module for the
- OpenLayers suite of modules, and provides the main API.') . '</p>';
- }
- 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')
+ ),
+ 'control' => array(
+ 'use hooks' => FALSE,
+ 'classes' => array('handler')
),
- 'layer_types' => array(
- 'use hooks' => TRUE,
- 'classes' => array('layer_types'),
+ '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();
-
- // 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);
-
- // 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();
-
- // 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;
+ $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;
}
}
- 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']
- );
-
- $css_styles = '';
- foreach ($styles as $property => $value) {
- $css_styles .= $property . ':' . $value . ';';
- }
-
- $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']);
+ $map->setOption('target', $map->getId());
+ $objects['map'] = $map->toArray();
- // Create ID for map as this will help with alters.
- $map['id'] = _openlayers_create_map_id('openlayers-map-' . $css_map_name);
+ $attached = $map->attached();
- // TODO: contextual links
- $links = array(
- '#type' => 'contextual_links',
- '#contextual_links' => array(
- 'openlayers' => array(
- 'admin/structure/openlayers/maps/list', array($map['map_name']),
- ),
- )
- );
-
- $container_classes = implode(" ", array(
- 'contextual-links-region',
- 'openlayers-container',
- 'openlayers-container-map-' . $css_map_name
- ));
+ drupal_alter('openlayers_map', $map);
- $build = array(
- '#type' => 'container',
- '#attributes' => array(
- 'id' => 'openlayers-container-' . $map['id'],
- 'style' => $css_styles,
- 'class' => $container_classes
- ),
- 'map' => array(
- '#theme' => 'html_tag',
- '#tag' => 'div',
- '#value' => '',
- '#attributes' => array(
- 'id' => $map['id'],
- 'style' => $css_styles,
- 'class' => 'openlayers-map openlayers-map-' . $css_map_name
- )
- )
- );
+ // Return themed map if no errors found
- $build['#attached'] = array();
- $build['#attached']['js'] = array(
- drupal_get_path('module', 'openlayers') . '/js/openlayers.js' => array(
- 'weight' => -2
+ $setting = array(
+ 'openlayers' => array(
+ 'maps' => array(
+ $map->getId() => $objects
)
- );
- $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'];
- }
-
- 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());
- }
-}
-
-/**
- * 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);
- 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
- */
-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'),
+ )
);
- 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 <em>!type</em>. 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;
-}
-
-/**
- * Check the plugin definition of a behavior.
- * Some field *MUST* be there to work correctly with OL.
- *
- * @ingroup openlayers_api
- * @param $definition
- * @return bool
- */
-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'),
+ $attached['js'][] = array(
+ 'data' => $setting,
+ 'type' => 'setting'
);
- 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 <em>!behavior</em>. 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;
- }
+ $styles = array(
+ 'width' => $map->getOption('width'),
+ 'height' => $map->getOption('height')
+ );
- 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
- <a href="@drupallog">Drupal log</a> for details',
- array('@drupallog' => url('admin/reports/dblog')))
- );
- return !$strict;
+ $css_styles = '';
+ foreach ($styles as $property => $value) {
+ $css_styles .= $property . ':' . $value . ';';
}
- 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
- <a href="@drupallog">Drupal log</a> for details',
- array('@drupallog' => url('admin/reports/dblog')))
- );
- return !$strict;
+ $current_path = current_path();
+ if ('system/ajax' == $current_path) {
+ $current_path = $_SESSION['current_path'];
}
- 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'],
+ $links = array(
+ 'openlayers' => array(
+ 'title' => 'Edit',
+ 'href' => 'admin/structure/openlayers/maps/list/' . $map->machine_name . '/edit',
+ 'query' => array(
+ 'destination' => $current_path
)
- );
- 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;
-}
-
-/**
- * Get all behaviors.
- *
- * @ingroup openlayers_api
- *
- * @param $reset
- * Boolean whether to reset cache or not.
- * @return
- * Array of behavior info.
- */
-function openlayers_behaviors($reset = FALSE, $include_disabled = FALSE) {
- ctools_include('plugins');
- $behaviors = ctools_get_plugins('openlayers', 'behaviors');
-
- if (!$include_disabled) {
- $behaviors = array_filter($behaviors, 'openlayers_object_enabled');
- }
-
- return array_filter($behaviors, 'openlayers_behavior_definition_check');
-
-}
-
-/**
- * Get all openlayers styles.
- *
- * @ingroup openlayers_api
- *
- * @param $reset
- * Boolean whether to reset cache or not.
- * @return
- * Array of all available styles.
- */
-function openlayers_styles($reset = FALSE, $include_disabled = FALSE) {
- ctools_include('export');
- if ($reset) {
- ctools_export_load_object_reset('openlayers_styles');
- }
-
- $styles = ctools_export_load_object('openlayers_styles', 'all', array());
-
- if (!$include_disabled) {
- $styles = array_filter($styles, 'openlayers_object_enabled');
- }
-
- 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;
-}
-
-/**
- * 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<openlayers_projection>
- */
-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<openlayers_projection>
- * 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
+ $container_classes = implode(" ", array(
+ 'contextual-links-region',
+ 'openlayers-container',
+ 'openlayers-container-map-' . $map->getId()
+ ));
+
+ $build = array(
+ '#type' => 'container',
+ 'contextual_links' => array(
+ '#prefix' => '<div class="contextual-links-wrapper">',
+ '#suffix' => '</div>',
+ '#theme' => 'links__contextual',
+ '#links' => $links,
+ '#attributes' => array('class' => array('contextual-links')),
+ '#attached' => array(
+ 'library' => array(array('contextual', 'contextual-links')),
),
- '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
+ ),
+ '#attributes' => array(
+ 'id' => 'openlayers-container-' . $map->getId(),
+ 'class' => $container_classes
+ ),
+ 'map' => array(
+ '#theme' => 'html_tag',
+ '#tag' => 'div',
+ '#value' => '',
+ '#attributes' => array(
+ 'id' => $map->getId(),
+ 'style' => $css_styles,
+ 'class' => 'openlayers-map openlayers-map-' . $map->getId()
),
- );
- }
-
- /**
- * 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);
+ '#attached' => array(
+ 'js' => $attached['js']
+ )
+ )
+ );
- }
+ if ($map->getOption('contextualLinks') == FALSE) {
+ unset($build['contextual_links']);
}
- 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'
- )
- )
- );
+ return $build;
}
-/**
- * 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;
+function openlayers_render_map(openlayers_map $map) {
+ $build = openlayers_render_build_map($map);
+ return render($build);
}
/**
* Implements hook_libraries_info().
*/
function openlayers_libraries_info() {
- $libraries['openlayers'] = array(
- 'name' => 'OpenLayers',
+ $libraries['openlayers3'] = array(
+ 'name' => 'OpenLayers3',
'vendor url' => 'http://openlayers.org/',
- 'download url' => 'http://openlayers.org/download/OpenLayers-2.13.tar.gz',
+ 'download url' => 'TODO',
'version arguments' => array(
- 'file' => 'lib/OpenLayers.js',
- 'pattern' => '/OpenLayers.VERSION_NUMBER="Release (.*?)"/',
- 'lines' => 1000,
+ 'file' => 'build/ol.js',
+ 'pattern' => '@Version: (.*)@',
+ 'lines' => 3,
),
'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'
- )
- ),
- ),
+ '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')
+ 'css' => array('css/openlayers.css' => array('weight' => 10))
),
),
);
@@ -1580,24 +239,57 @@ function openlayers_libraries_info() {
function openlayers_element_info() {
return array(
'openlayers' => array(
- '#pre_render' => array('openlayers_element_pre_render_callback'),
+ '#input' => FALSE,
+ '#tree' => TRUE,
+ '#process' => array('openlayers_element_process_callback'),
'#theme_wrappers' => array('form_element')
)
);
}
-/**
- * Callback.
- *
- * @param $element
- * @return mixed
- */
-function openlayers_element_pre_render_callback($element) {
+function openlayers_element_process_callback($element, &$form_state) {
if (is_string($element['#map'])) {
- $map = openlayers_map_load($element['#map']);
- $element += openlayers_render_map_data($map->data);
+ $map = openlayers_object_load('map', $element['#map']);
+ $build = openlayers_render_map($map);
+ $element['map'] = array(
+ '#markup' => $build
+ );
}
return $element;
}
+/**
+ * Implements hook_block_info().
+ */
+function openlayers_block_info() {
+ ctools_include('export');
+ $all_maps = ctools_export_crud_load_all('openlayers_maps');
+ $blocks = array();
+
+ 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 $blocks;
+}
+
+/**
+ * Implements hook_block_view().
+ */
+function openlayers_block_view($delta = '') {
+ ctools_include('export');
+ $block = array();
+
+ if ($map = openlayers_object_load('map', $delta)) {
+ if ($map->getOption('provideBlock', 1)) {
+ $block['subject'] = $map->name;
+ $block['content'] = openlayers_render_map($map);
+ }
+ }
+
+ return $block;
+}
diff --git a/plugins/behaviors/openlayers_behavior_argparser.inc b/plugins/behaviors/openlayers_behavior_argparser.inc
deleted file mode 100644
index 302b969..0000000
--- a/plugins/behaviors/openlayers_behavior_argparser.inc
+++ /dev/null
@@ -1,42 +0,0 @@
-<?php
-/**
- * @file
- * Implementation of OpenLayers behavior.
- */
-
-/**
- * Attribution Behavior
- */
-class openlayers_behavior_argparser extends openlayers_behavior {
- /**
- * Provide initial values for options.
- */
- function options_init() {
- return array(
- 'anchor' => FALSE,
- );
- }
-
- function js_dependency() {
- return array('OpenLayers.Control.ArgParser');
- }
-
- function options_form($defaults = array()) {
- return array(
- 'anchor' => array(
- '#type' => 'checkbox',
- '#title' => t('Anchor'),
- '#description' => t('Permalink is in the form of an anchor (#) instead of a query (?).'),
- '#default_value' => (isset($defaults['anchor'])) ? $defaults['anchor'] : FALSE,
- ),
- );
- }
-
- 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 f16bec0..0000000
--- 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 5199585..0000000
--- a/plugins/behaviors/openlayers_behavior_attribution.inc
+++ /dev/null
@@ -1,42 +0,0 @@
-<?php
-/**
- * @file
- * Implementation of OpenLayers behavior.
- */
-
-/**
- * Attribution Behavior
- */
-class openlayers_behavior_attribution extends openlayers_behavior {
- /**
- * Provide initial values for options.
- */
- function options_init() {
- return array(
- 'separator' => '',
- );
- }
-
- 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 1be8655..0000000
--- 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 d06aecd..0000000
--- a/plugins/behaviors/openlayers_behavior_boxselect.inc
+++ /dev/null
@@ -1,40 +0,0 @@
-<?php
-/**
- * @file
- * Implementation of OpenLayers behavior.
- */
-
-/**
- * BoxSelect Behavior
- */
-class openlayers_behavior_boxselect extends openlayers_behavior {
- /**
- * Provide initial values for options.
- */
- function options_init() {
- return array(
- 'input_fields' => '',
- );
- }
-
- function js_dependency() {
- return array(
- 'OpenLayers.Control.DrawFeature',
- 'OpenLayers.Layer.Vector',
- 'OpenLayers.Handler.RegularPolygon'
- );
- }
-
- function options_form($defaults = array()) {
- return array(
- );
- }
-
- 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 19404b3..0000000
--- 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 0a14e47..0000000
--- a/plugins/behaviors/openlayers_behavior_cluster.inc
+++ /dev/null
@@ -1,292 +0,0 @@
-<?php
-/**
- * @file
- * Implementation of OpenLayers Cluster behavior.
- */
-
-/**
- * Cluster behavior
- */
-class openlayers_behavior_cluster extends openlayers_behavior {
- /**
- * Provide initial values for options.
- */
- function options_init() {
- return array(
- 'clusterlayer' => array(),
- 'distance' => '20',
- 'threshold' => NULL,
- '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 5498571..0000000
--- 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 += '<div class="'+classes.join(' ')+'">' +
- Drupal.theme.prototype.openlayersPopup(pf) + '</div>';
- }
- 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 7493c33..0000000
--- a/plugins/behaviors/openlayers_behavior_dragpan.inc
+++ /dev/null
@@ -1,56 +0,0 @@
-<?php
-/**
- * @file
- * Implementation of OpenLayers behavior.
- */
-
-/**
- * DragPan Behavior
- */
-class openlayers_behavior_dragpan extends openlayers_behavior {
- /**
- * Provide initial values for options.
- */
- function options_init() {
- return array(
- 'enableKinetic' => FALSE,
- 'kineticInterval' => 10,
- );
- }
-
- function js_dependency() {
- return array('OpenLayers.Control.DragPan');
- }
-
- function options_form($defaults = array()) {
- $form = array();
-
- // This options seem to be buggy. Shoudl look into more.
- /*
- $form = array(
- 'enableKinetic' => array(
- '#title' => t('Enable Kinetic Dragging'),
- '#type' => 'checkbox',
- '#description' => t('Enables dragging and panning to have acceleration.'),
- '#default_value' => isset($defaults['enableKinetic']) ? $defaults['enableKinetic'] : FALSE,
- ),
- 'kineticInterval' => array(
- '#title' => t('Kinetic Interval'),
- '#type' => 'textfield',
- '#description' => t('An integer of millseconds of time between steps in "Kinetic Scrolling".'),
- '#default_value' => isset($defaults['kineticInterval']) ? $defaults['kineticInterval'] : 10,
- ),
- );
- */
-
- return $form;
- }
-
- 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 7cb0eae..0000000
--- 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 8c79f81..0000000
--- 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 b2efd21..0000000
--- a/plugins/behaviors/openlayers_behavior_drawfeatures.inc
+++ /dev/null
@@ -1,64 +0,0 @@
-<?php
-/**
- * @file
- * Implementation of OpenLayers behavior.
- */
-
-/**
- * Draw Features behavior
- */
-class openlayers_behavior_drawfeatures extends openlayers_behavior {
- /**
- * Provide initial values for options.
- */
- function options_init() {
- return array(
- 'element_id' => '',
- 'feature_types' => array(),
- 'feature_limit' => 0,
- );
- }
-
- function options_form($defaults = array()) {
- $features = array(
- 'point' => t('Point'),
- 'path' => t('Path'),
- 'polygon' => t('Polygon'),
- );
-
- return array(
- 'feature_types' => array(
- '#title' => t('Available Features'),
- '#type' => 'checkboxes',
- '#options' => $features,
- '#description' => t('Select what features are available to draw.'),
- '#default_value' => isset($defaults['feature_types']) ? $defaults['feature_types'] : array(),
- ),
- 'feature_limit' => array(
- '#title' => t('Number of features'),
- '#type' => 'textfield',
- '#description' => t('The number of features that are allowed to be
- drawn. Leave blank or at 0 for unlimited.'),
- '#default_value' => isset($defaults['feature_limit']) ? $defaults['feature_limit'] : 0,
- ),
- 'element_id' => array(
- '#type' => 'textfield',
- '#default_value' => (isset($defaults['element_id'])) ?
- $defaults['element_id'] : '',
- '#title' => t('Element ID'),
- '#description' => t('The DOM element ID that will be passed the value of the features. This will probably be a textfield or textarea.'),
- )
- );
- }
-
- 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 de64013..0000000
--- 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 1d818f3..0000000
--- 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 4161e5e..0000000
--- a/plugins/behaviors/openlayers_behavior_fullscreen.inc
+++ /dev/null
@@ -1,45 +0,0 @@
-<?php
-/**
- * @file
- * Implementation of OpenLayers behavior.
- */
-
-/**
- * Fullscreen Behavior
- */
-class openlayers_behavior_fullscreen extends openlayers_behavior {
- /**
- * Provide initial values for options.
- */
- function options_init() {
- return array(
- 'activated' => FALSE
- );
- }
-
- /**
- * Provide form for configurations per map.
- */
- function options_form($defaults = array()) {
- return array(
- 'activated' => array(
- '#title' => t('Initially activated'),
- '#type' => 'checkbox',
- '#description' => t('Select to be in fullscreen by default.'),
- '#default_value' => isset($defaults['activated']) ? $defaults['activated'] : FALSE
- )
- );
- }
-
- function 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 56811ee..0000000
--- 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 b9b316c..0000000
--- a/plugins/behaviors/openlayers_behavior_fullscreen.png
+++ /dev/null
Binary files differ
diff --git a/plugins/behaviors/openlayers_behavior_geolocate.inc b/plugins/behaviors/openlayers_behavior_geolocate.inc
deleted file mode 100644
index 11560a6..0000000
--- a/plugins/behaviors/openlayers_behavior_geolocate.inc
+++ /dev/null
@@ -1,68 +0,0 @@
-<?php
-/**
- * @file
- * Implementation of OpenLayers behavior.
- */
-
-/**
- * Geolocate Behavior
- * http://dev.openlayers.org/docs/files/OpenLayers/Control/Geolocate-js.html
- */
-class openlayers_behavior_geolocate extends openlayers_behavior {
- /**
- * Provide initial values for options.
- */
- function options_init() {
- return array(
- 'bind' => TRUE,
- 'watch' => FALSE,
- 'geolocationOptions' => array(
- 'enableHighAccuracy' => FALSE,
- 'maximumAge' => 0,
- 'timeout' => 7000,
- ),
- 'zoom_level' => 12,
- );
- }
-
- function options_form($defaults = array()) {
- $intials = $this->options_init();
-
- return array(
- 'bind' => array(
- '#title' => t('Center when located'),
- '#type' => 'select',
- '#options' => array(
- TRUE => t('Yes'),
- FALSE => t('No'),
- ),
- '#description' => t('When enabled, if the geolocation control finds a location, it will set the center of the map at this point.'),
- '#default_value' => isset($defaults['bind']) ? $defaults['bind'] : $intials['bind'],
- ),
- 'zoom_level' => array(
- '#title' => t('Zoom level'),
- '#type' => 'textfield',
- '#description' => t('An integer zoom level for when a location is found. 0 is the most zoomed out and higher numbers mean more zoomed in (the number of zoom levels depends on your map).'),
- '#default_value' => isset($defaults['zoom_level']) ? $defaults['zoom_level'] : $intials['zoom_level'],
- ),
- 'watch' => array(
- '#title' => t('Watch'),
- '#type' => 'select',
- '#options' => array(
- TRUE => t('Yes'),
- FALSE => t('No'),
- ),
- '#description' => t('When enabled, the map will continue to try to update the location of the device.'),
- '#default_value' => isset($defaults['watch']) ? $defaults['watch'] : $intials['watch'],
- ),
- );
- }
-
- function 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 568e3cb..0000000
--- 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 37084f0..0000000
--- a/plugins/behaviors/openlayers_behavior_graticule.inc
+++ /dev/null
@@ -1,84 +0,0 @@
-<?php
-/**
- * @file
- * Implementation of OpenLayers behavior.
- */
-
-/**
- * Graticule Behavior
- */
-class openlayers_behavior_graticule extends openlayers_behavior {
- /**
- * Provide initial values for options.
- */
- function options_init() {
- return array(
- 'labelled' => TRUE,
- 'numPoints' => 50,
- 'targetSize' => 200,
- 'displayInLayerSwitcher' => TRUE,
- 'lineSymbolizer' => array(
- 'strokeColor' => '#333',
- 'strokeWidth' => 1,
- 'strokeOpacity' => 0.5
- )
- );
- }
-
- function options_form($defaults = array()) {
- return array(
- 'displayInLayerSwitcher' => array(
- '#type' => 'checkbox',
- '#title' => t('Display in layer switcher ?'),
- '#description' => t('Allows the Graticule control to be switched on and off by LayerSwitcher control. Default is true.'),
- '#default_value' => (isset($defaults['displayInLayerSwitcher'])) ? $defaults['displayInLayerSwitcher'] : TRUE,
- ),
- 'labelled' => array(
- '#type' => 'checkbox',
- '#title' => t('Labelled'),
- '#description' => t('Should the graticule lines be labelled ? Default is true.'),
- '#default_value' => (isset($defaults['labelled'])) ? $defaults['labelled'] : TRUE,
- ),
- 'numPoints' => array(
- '#type' => 'textfield',
- '#title' => t('Number of points'),
- '#description' => t('The number of points to use in each graticule line. Higher numbers result in a smoother curve for projected maps.'),
- '#default_value' => (isset($defaults['numPoints'])) ? $defaults['numPoints'] : 50,
- ),
- 'targetSize' => array(
- '#type' => 'textfield',
- '#title' => t('Target size'),
- '#description' => t('The maximum size of the grid in pixels on the map.'),
- '#default_value' => (isset($defaults['targetSize'])) ? $defaults['targetSize'] : 200,
- ),
- 'lineSymbolizer' => array(
- 'strokeColor' => array(
- '#type' => 'textfield',
- '#title' => t('Stroke color'),
- '#description' => t('The color code to use for the lines. Example: #333'),
- '#default_value' => (isset($defaults['lineSymbolizer']['strokeColor'])) ? $defaults['lineSymbolizer']['strokeColor'] : '#333',
- ),
- 'strokeWidth' => array(
- '#type' => 'textfield',
- '#title' => t('Stroke width'),
- '#description' => t('The width of the lines. Example: 1'),
- '#default_value' => (isset($defaults['lineSymbolizer']['strokeWidth'])) ? $defaults['lineSymbolizer']['strokeWidth'] : 1,
- ),
- 'strokeOpacity' => array(
- '#type' => 'textfield',
- '#title' => t('Stroke opacity'),
- '#description' => t('The opacity of the line, from 0 to 1. Example: 0.5'),
- '#default_value' => (isset($defaults['lineSymbolizer']['strokeOpacity'])) ? $defaults['lineSymbolizer']['strokeOpacity'] : 0.5,
- ),
- )
- );
- }
-
- 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 2365d93..0000000
--- 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 4b32ccc..0000000
--- a/plugins/behaviors/openlayers_behavior_hover.inc
+++ /dev/null
@@ -1,47 +0,0 @@
-<?php
-/**
- * @file
- * Implementation of OpenLayers behavior.
- */
-
-/**
- * Hover Behavior
- */
-class openlayers_behavior_hover extends openlayers_behavior {
- /**
- * Provide initial values for options.
- */
- function options_init() {
- return array(
- 'layers' => '',
- );
- }
-
- 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 0ac4f84..0000000
--- 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 3a023bd..0000000
--- a/plugins/behaviors/openlayers_behavior_keyboarddefaults.inc
+++ /dev/null
@@ -1,27 +0,0 @@
-<?php
-/**
- * @file
- * Implementation of OpenLayers behavior.
- */
-
-/**
- * Keyboard Defaults Behavior
- */
-class openlayers_behavior_keyboarddefaults extends openlayers_behavior {
- /**
- * Provide initial values for options.
- */
- function options_init() {
- return array(
- 'keyboarddefaults' => '',
- );
- }
-
- 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 0606631..0000000
--- 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 79ef8b3..0000000
--- a/plugins/behaviors/openlayers_behavior_layerswitcher.inc
+++ /dev/null
@@ -1,100 +0,0 @@
-<?php
-/**
- * @file
- * Implementation of OpenLayers behavior.
- */
-
-/**
- * Layer Switcher Behavior
- */
-class openlayers_behavior_layerswitcher extends openlayers_behavior {
- /**
- * Provide initial values for options.
- */
- function options_init() {
- return array(
- 'layerswitcher' => '',
- 'ascending' => TRUE,
- 'sortBaseLayer' => '0',
- 'roundedCorner' => TRUE,
- 'roundedCornerColor' => '#222222',
- 'maximizeDefault' => FALSE,
- '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 050f47e..0000000
--- 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 acab7df..0000000
--- a/plugins/behaviors/openlayers_behavior_layerzoom.inc
+++ /dev/null
@@ -1,49 +0,0 @@
-<?php
-/**
- * @file
- * Implementation of OpenLayers behavior.
- */
-
-/**
- * Layer Zoom Behavior
- */
-class openlayers_behavior_layerzoom extends openlayers_behavior {
-
- function options_form($defaults = array()) {
- $options = array();
-
- foreach ($this->map['layers'] as $layer) {
- if ($layer != $this->map['default_layer']) {
- $options[$layer] = array(
- 'enable' => array(
- '#type' => 'checkbox',
- '#title' => t('Enable dynamic zoom levels for @layer', array('@layer' => $layer)),
- '#default_value' => isset($this->options[$layer]['enable']) ? $this->options[$layer]['enable'] : 0,
- ),
- 'resolutions' => array(
- '#type' => 'select',
- '#multiple' => TRUE,
- '#options' => array_combine(
- array_map('strval', openlayers_get_resolutions('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 ff4a774..0000000
--- 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 f9b6786..0000000
--- a/plugins/behaviors/openlayers_behavior_mapformvalues.inc
+++ /dev/null
@@ -1,28 +0,0 @@
-<?php
-/**
- * @file
- * Implementation of OpenLayers behavior.
- */
-
-/**
- * Map Form Values Behavior
- */
-class openlayers_behavior_mapformvalues extends openlayers_behavior {
- /**
- * Provide initial values for options.
- */
- function options_init() {
- return array(
- 'center_form' => '#edit-center-initial-centerpoint',
- 'zoom_form' => '#edit-center-initial-zoom'
- );
- }
-
- 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 25f1185..0000000
--- 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 e9d604b..0000000
--- a/plugins/behaviors/openlayers_behavior_mouseposition.inc
+++ /dev/null
@@ -1,70 +0,0 @@
-<?php
-/**
- * @file
- * Implementation of OpenLayers behavior.
- */
-
-/**
- * Mouse Position Behavior
- */
-class openlayers_behavior_mouseposition extends openlayers_behavior {
- /**
- * Provide initial values for options.
- */
- function options_init() {
- return array(
- 'prefix' => '',
- 'separator' => ', ',
- 'suffix' => '',
- 'numDigits' => 4,
- 'emptyString' => '',
- );
- }
-
- function js_dependency() {
- return array('OpenLayers.Control.MousePosition');
- }
-
- function options_form($defaults = array()) {
- return array(
- 'prefix' => array(
- '#title' => t('Prefix'),
- '#type' => 'textfield',
- '#description' => t('A textual prefix to the mouse position.'),
- '#default_value' => isset($defaults['prefix']) ? $defaults['prefix'] : '',
- ),
- 'separator' => array(
- '#title' => t('Separator'),
- '#type' => 'textfield',
- '#description' => t('A textual separator between the first and second value.'),
- '#default_value' => isset($defaults['separator']) ? $defaults['separator'] : ', ',
- ),
- 'suffix' => array(
- '#title' => t('Suffix'),
- '#type' => 'textfield',
- '#description' => t('A textual suffix to the mouse position.'),
- '#default_value' => isset($defaults['suffix']) ? $defaults['suffix'] : '',
- ),
- 'numDigits' => array(
- '#title' => t('Number of Decimal Digits'),
- '#type' => 'textfield',
- '#description' => t('Number of decimal digits to show.'),
- '#default_value' => isset($defaults['numDigits']) ? $defaults['numDigits'] : '',
- ),
- 'emptyString' => array(
- '#title' => t('Empty Value'),
- '#type' => 'textfield',
- '#description' => t('What will be seen if there is no value for the mouse position.'),
- '#default_value' => isset($defaults['emptyString']) ? $defaults['emptyString'] : '',
- ),
- );
- }
-
- 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 dae0885..0000000
--- 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 30d78df..0000000
--- a/plugins/behaviors/openlayers_behavior_navigation.inc
+++ /dev/null
@@ -1,58 +0,0 @@
-<?php
-/**
- * @file
- * Implementation of OpenLayers behavior.
- */
-
-/**
- * Navigation Behavior
- */
-class openlayers_behavior_navigation extends openlayers_behavior {
- /**
- * Provide initial values for options.
- */
- function options_init() {
- return array(
- 'navigation' => '',
- 'zoomWheelEnabled' => TRUE,
- 'zoomBoxEnabled' => TRUE,
- 'documentDrag' => FALSE,
- );
- }
-
- function js_dependency() {
- return array('OpenLayers.Control.Navigation');
- }
-
- function options_form($defaults = array()) {
- return array(
- 'zoomWheelEnabled' => array(
- '#type' => 'checkbox',
- '#title' => t('Enable Zoom Wheel'),
- '#description' => t('Enable zooming via the mouse scroll wheel. This can
- interfere with page scrolling.'),
- '#default_value' => isset($defaults['zoomWheelEnabled']) ? $defaults['zoomWheelEnabled'] : TRUE
- ),
- 'zoomBoxEnabled' => array(
- '#type' => 'checkbox',
- '#title' => t('Enable Zoom Box'),
- '#description' => t('Enable zooming with selecting a box by <em>SHIFT + clicking</em>.'),
- '#default_value' => isset($defaults['zoomBoxEnabled']) ? $defaults['zoomBoxEnabled'] : TRUE
- ),
- 'documentDrag' => array(
- '#type' => 'checkbox',
- '#title' => t('Document Drag'),
- '#description' => t('Allow panning of the map by dragging outside map viewport.'),
- '#default_value' => isset($defaults['documentDrag']) ? $defaults['documentDrag'] : FALSE
- ),
- );
- }
-
- 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 682492e..0000000
--- 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 40f4f0a..0000000
--- a/plugins/behaviors/openlayers_behavior_panzoom.inc
+++ /dev/null
@@ -1,32 +0,0 @@
-<?php
-/**
- * @file
- * Implementation of OpenLayers behavior.
- */
-
-/**
- * Pan Zoom Behavior
- */
-class openlayers_behavior_panzoom extends openlayers_behavior {
- /**
- * Provide initial values for options.
- */
- function options_init() {
- return array(
- 'panzoom' => '',
- );
- }
-
- function options_form($defaults = array()) {
- return array(
- );
- }
-
- 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 84d07dd..0000000
--- 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 4b3c6bc..0000000
--- a/plugins/behaviors/openlayers_behavior_panzoombar.inc
+++ /dev/null
@@ -1,49 +0,0 @@
-<?php
-/**
- * @file
- * Implementation of OpenLayers behavior.
- */
-
-/**
- * Pan Zoom Bar Behavior
- */
-class openlayers_behavior_panzoombar extends openlayers_behavior {
- /**
- * Provide initial values for options.
- */
- function options_init() {
- return array(
- 'zoomWorldIcon' => FALSE,
- 'panIcons' => TRUE,
- );
- }
-
- function js_dependency() {
- return array('OpenLayers.Control.PanZoomBar');
- }
-
- function options_form($defaults = array()) {
- return array(
- 'zoomWorldIcon' => array(
- '#type' => 'checkbox',
- '#title' => t('World Icon'),
- '#description' => t('This puts the world icon in the pan controls. This button will zoom to the max extent when it is pressed.'),
- '#default_value' => isset($defaults['zoomWorldIcon']) ? $defaults['zoomWorldIcon'] : FALSE
- ),
- 'panIcons' => array(
- '#type' => 'checkbox',
- '#title' => t('Pan Icons'),
- '#description' => t('Enable the pan controls. Without it, then the user will only see a zoom bar.'),
- '#default_value' => isset($defaults['panIcons']) ? $defaults['panIcons'] : TRUE
- ),
- );
- }
-
- 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 8dab936..0000000
--- 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 8c12e2f..0000000
--- a/plugins/behaviors/openlayers_behavior_permalink.inc
+++ /dev/null
@@ -1,42 +0,0 @@
-<?php
-/**
- * @file
- * Implementation of OpenLayers behavior.
- */
-
-/**
- * PermaLink Behavior
- */
-class openlayers_behavior_permalink extends openlayers_behavior {
- /**
- * Provide initial values for options.
- */
- function options_init() {
- return array(
- 'anchor' => FALSE,
- );
- }
-
- function js_dependency() {
- return array('OpenLayers.Control.Permalink');
- }
-
- function options_form($defaults = array()) {
- return array(
- 'anchor' => array(
- '#type' => 'checkbox',
- '#title' => t('Anchor'),
- '#description' => t('Permalink is in the form of an anchor (#) instead of a query (?). Also, this means that the URL location will be constantly updated, and no link will appear.'),
- '#default_value' => (isset($defaults['anchor'])) ? $defaults['anchor'] : FALSE,
- ),
- );
- }
-
- 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 4a7de44..0000000
--- 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 1e98cb0..0000000
--- a/plugins/behaviors/openlayers_behavior_popup.inc
+++ /dev/null
@@ -1,77 +0,0 @@
-<?php
-/**
- * @file
- * Implementation of OpenLayers behavior.
- */
-
-/**
- * Popup Behavior
- */
-class openlayers_behavior_popup extends openlayers_behavior {
- /**
- * Provide initial values for options.
- */
- function options_init() {
- return array(
- 'layers' => 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 4c63fd8..0000000
--- 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 += '<div class="openlayers-popup openlayers-tooltip-name">' + feature.attributes.name + '</div>';
- }
- if (feature.attributes.description) {
- output += '<div class="openlayers-popup openlayers-tooltip-description">' + feature.attributes.description + '</div>';
- }
-
- return output;
-};
-
-// Make sure the namespace exists
-Drupal.openlayers.popup = Drupal.openlayers.popup || {};
-
-/**
- * OpenLayers Popup Behavior
- */
-Drupal.openlayers.addBehavior('openlayers_behavior_popup', function (data, options) {
- var map = data.openlayers;
- var layers = [];
- var selectedFeature;
-
- // For backwards compatiability, if layers is not
- // defined, then include all vector layers
- if (typeof options.layers == 'undefined' || options.layers.length == 0) {
- layers = map.getLayersByClass('OpenLayers.Layer.Vector');
- }
- else {
- for (var i in options.layers) {
- var selectedLayer = map.getLayersBy('drupalID', options.layers[i]);
- if (typeof selectedLayer[0] != 'undefined') {
- layers.push(selectedLayer[0]);
- }
- }
- }
-
- // if only 1 layer exists, do not add as an array. Kind of a
- // hack, see https://drupal.org/node/1393460
- if (layers.length == 1) {
- //layers = layers[0];
- }
-
- var popupSelect = new OpenLayers.Control.SelectFeature(layers,
- {
- 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 67d4caa..0000000
--- a/plugins/behaviors/openlayers_behavior_scaleline.inc
+++ /dev/null
@@ -1,35 +0,0 @@
-<?php
-/**
- * @file
- * Implementation of OpenLayers behavior.
- */
-
-/**
- * Scaleline Behavior
- */
-class openlayers_behavior_scaleline extends openlayers_behavior {
- /**
- * Provide initial values for options.
- */
- function options_init() {
- return array(
- 'scaleline' => '',
- );
- }
-
- function js_dependency() {
- return array('OpenLayers.Control.ScaleLine');
- }
-
- function options_form($defaults = array()) {
- return array();
- }
-
- 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 579b305..0000000
--- 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 1d490be..0000000
--- a/plugins/behaviors/openlayers_behavior_tooltip.inc
+++ /dev/null
@@ -1,53 +0,0 @@
-<?php
-/**
- * @file
- * Implementation of OpenLayers behavior for tooltips.
- */
-
-/**
- * Tooltip Behavior
- */
-class openlayers_behavior_tooltip extends openlayers_behavior {
- /**
- * Provide initial values for options.
- */
- function options_init() {
- return array(
- 'attribution' => '',
- 'layers' => array(),
- );
- }
-
- /**
- * Form defintion for per map customizations.
- */
- function options_form($defaults = array()) {
- // Only prompt for vector layers
- $vector_layers = array();
- foreach ($this->map['layers'] as $id => $name) {
- $layer = openlayers_layer_load($id);
- if (isset($layer->data['vector']) && $layer->data['vector'] == TRUE) {
- $vector_layers[$id] = $name;
- }
- }
-
- return array(
- 'layers' => array(
- '#title' => t('Layers'),
- '#type' => 'checkboxes',
- '#options' => $vector_layers,
- '#description' => t('Select layer to apply tooltips to.'),
- '#default_value' => isset($defaults['layers']) ?
- $defaults['layers'] : array(),
- ),
- );
- }
-
- 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 0f0ed43..0000000
--- 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 += '<div class="openlayers-popup openlayers-tooltip-name">' + feature.attributes.name + '</div>';
- }
- if (feature.attributes.description) {
- output += '<div class="openlayers-popup openlayers-tooltip-description">' + feature.attributes.description + '</div>';
- }
-
- return output;
-};
-
-/**
- * OpenLayers Tooltip Behavior
- */
-Drupal.openlayers.addBehavior('openlayers_behavior_tooltip', function (data, options) {
- var map = data.openlayers;
- var layers = [];
-
- // For backwards compatiability, if layers is not
- // defined, then include all vector layers
- if (typeof options.layers == 'undefined' || options.layers.length == 0) {
- layers = map.getLayersByClass('OpenLayers.Layer.Vector');
- }
- else {
- for (var i in options.layers) {
- var selectedLayer = map.getLayersBy('drupalID', options.layers[i]);
- if (typeof selectedLayer[0] != 'undefined') {
- layers.push(selectedLayer[0]);
- }
- }
- }
-
- // if only 1 layer exists, do not add as an array. Kind of a
- // hack, see https://drupal.org/node/1393460
- if (layers.length == 1) {
- layers = layers[0];
- }
-
- // Define feature select events for selected layers.
- var popupSelect = new OpenLayers.Control.SelectFeature(layers,
- {
- hover: true,
- clickout: false,
- multiple: false,
- onSelect: function(feature) {
- // Create FramedCloud popup for tooltip.
- var output = Drupal.theme('openlayersTooltip', feature);
- if (typeof output != 'undefined') {
- popup = new OpenLayers.Popup.FramedCloud(
- 'tooltip',
- feature.geometry.getBounds().getCenterLonLat(),
- null,
- output,
- null,
- true
- );
- feature.popup = popup;
- feature.layer.map.addPopup(popup);
- Drupal.attachBehaviors();
- }
- },
- onUnselect: function(feature) {
- // Remove popup.
- if (typeof feature.popup != 'undefined') {
- feature.layer.map.removePopup(feature.popup);
- feature.popup.destroy();
- feature.popup = null;
- }
- }
- }
- );
- 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 a806574..0000000
--- a/plugins/behaviors/openlayers_behavior_touch_navigation.inc
+++ /dev/null
@@ -1,42 +0,0 @@
-<?php
-/**
- * @file
- * Implementation of OpenLayers behavior.
- */
-
-/**
- * Touch Navigation Behavior
- */
-class openlayers_behavior_touch_navigation extends openlayers_behavior {
- /**
- * Provide initial values for options.
- */
- function options_init() {
- return array(
- 'documentDrag' => FALSE,
- );
- }
-
- function js_dependency() {
- return array('OpenLayers.Control.TouchNavigation');
- }
-
- function options_form($defaults = array()) {
- return array(
- 'documentDrag' => array(
- '#type' => 'checkbox',
- '#title' => t('Document Drag'),
- '#description' => t('Allow panning of the map by dragging outside map viewport.'),
- '#default_value' => isset($defaults['documentDrag']) ? $defaults['documentDrag'] : FALSE
- ),
- );
- }
-
- 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 6ad4ccf..0000000
--- 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 e697048..0000000
--- a/plugins/behaviors/openlayers_behavior_zoombox.inc
+++ /dev/null
@@ -1,27 +0,0 @@
-<?php
-/**
- * @file
- * Implementation of OpenLayers behavior.
- */
-
-/**
- * Zoom Box Behavior
- */
-class openlayers_behavior_zoombox extends openlayers_behavior {
- /**
- * Provide initial values for options.
- */
- function options_init() {
- return array(
- 'zoombox' => '',
- );
- }
-
- 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 bb468d6..0000000
--- 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 0db5958..0000000
--- a/plugins/behaviors/openlayers_behavior_zoompanel.inc
+++ /dev/null
@@ -1,27 +0,0 @@
-<?php
-/**
- * @file
- * Implementation of OpenLayers behavior.
- */
-
-/**
- * Zoom Panel Behavior
- */
-class openlayers_behavior_zoompanel extends openlayers_behavior {
- /**
- * Provide initial values for options.
- */
- function options_init() {
- return array(
- 'panzoom' => '',
- );
- }
-
- 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 2018cf7..0000000
--- 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 73075a6..0000000
--- a/plugins/behaviors/openlayers_behavior_zoomtolayer.inc
+++ /dev/null
@@ -1,53 +0,0 @@
-<?php
-/**
- * @file
- * Implementation of OpenLayers behavior.
- */
-
-/**
- * Zoom To Layer Behavior
- */
-class openlayers_behavior_zoomtolayer extends openlayers_behavior {
- /**
- * Provide initial values for options.
- */
- function options_init() {
- return array(
- 'point_zoom_level' => '5',
- 'zoomtolayer_scale' => 1,
- );
- }
-
- function options_form($defaults = array()) {
- return array(
- 'zoomtolayer' => array(
- '#type' => 'checkboxes',
- '#options' => $this->map['layers'],
- '#description' => t('Select layer(s) to which to zoom when the map is loaded.'),
- '#default_value' => isset($defaults['zoomtolayer']) ? $defaults['zoomtolayer'] : array(),
- ),
- 'point_zoom_level' => array(
- '#title' => t('Point Zoom Level'),
- '#type' => 'textfield',
- '#default_value' => (isset($defaults['point_zoom_level'])) ?
- $defaults['point_zoom_level'] : 5,
- '#size' => 5,
- ),
- 'zoomtolayer_scale' => array(
- '#title' => t('Zoom to Layer Scale'),
- '#type' => 'textfield',
- '#size' => 5,
- '#description' => t('Additional scaling to apply to the calculated bounds before zooming. See <a href="http://dev.openlayers.org/docs/files/OpenLayers/BaseTypes/Bounds-js.html#OpenLayers.Bounds.scale">OpenLayers docs</a>.'),
- '#default_value' => isset($defaults['zoomtolayer_scale']) ? $defaults['zoomtolayer_scale'] : 1
- ),
- );
- }
-
- 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 db8506b..0000000
--- 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 f0c050c..0000000
--- a/plugins/behaviors/openlayers_behavior_zoomtomaxextent.inc
+++ /dev/null
@@ -1,27 +0,0 @@
-<?php
-/**
- * @file
- * Implementation of OpenLayers behavior.
- */
-
-/**
- * Zoom to Max Extent Behavior
- */
-class openlayers_behavior_zoomtomaxextent extends openlayers_behavior {
- /**
- * Provide initial values for options.
- */
- function options_init() {
- return array(
- 'zoomtomaxextent' => '',
- );
- }
-
- 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 24f3e05..0000000
--- a/plugins/behaviors/openlayers_behavior_zoomtomaxextent.js
+++ /dev/null
@@ -1,15 +0,0 @@
-/**<