function leaflet_geojson_add_bbox_strategy in Leaflet GeoJSON 7.2
Same name and namespace in other branches
- 7 leaflet_geojson.module \leaflet_geojson_add_bbox_strategy()
Add a Bounding Box Strategy
Parameters
$source_info: The source info as specified in hook_leaflet_geojson_source_info().
3 calls to leaflet_geojson_add_bbox_strategy()
- hook_leaflet_geojson_bean_view_features_alter in modules/
leaflet_geojson_bean/ leaflet_geojson_bean.api.php - Alter a leaflet geojson features array before being viewed in a bean.
- leaflet_geojson_bean_leaflet_geojson_bean_view_features_alter in modules/
leaflet_geojson_bean/ leaflet_geojson_bean.module - Implements hook_leaflet_geojson_bean_view_features_alter().
- leaflet_geojson_map_pane_render_layered_map in plugins/
content_types/ leaflet_geojson.map_pane.inc - Helper function to generate the map markup based on the pane config.
File
- ./
leaflet_geojson.module, line 14 - API Extension for using Leaflet with GeoJSON that currently just allows to add a bbox strategy.
Code
function leaflet_geojson_add_bbox_strategy($source_info) {
// Add bounding box javascript.
drupal_add_js(drupal_get_path('module', 'leaflet_geojson') . '/leaflet.bbox.js', array(
'weight' => 5,
));
// Add custom settings.
// The JS now expects an array even if there's only one layer, so be sure
// the single layer is nested properly (the keyname is not important).
// @TODO fix this.
if (isset($settings['view_display'])) {
// Create the base settings to be compatible with the new Views GeoJSON.
// This will happen when the map block is built by leaflet_geojson_bean.
$settings = $source_info;
// Then add a copy in leaflet_1 for bean.
$settings['leaflet_1'] = $source_info;
}
else {
// This will happen when the block is placed by the ctools (panels) plugin.
$settings = $source_info;
}
drupal_add_js(array(
'leafletBBox' => $settings,
), 'setting');
}