function leaflet_demo_output_maps in Leaflet More Maps 7
Outputs the HTML for all available Leaflet maps, centered on supplied coords.
Parameters
string $latitude: the latitude
string $longitude: the longitude
Return value
string the map string as rendered html
1 call to leaflet_demo_output_maps()
- leaflet_demo_map_parameters_form in leaflet_demo/
leaflet_demo.module - Create the demo map parameters form.
File
- leaflet_demo/
leaflet_demo.module, line 156 - "Leaflet Demo" showcases in a block all Leaflet-powered maps enabled on your Drupal site.
Code
function leaflet_demo_output_maps($latitude = LEAFLET_DEMO_DEFAULT_LAT, $longitude = LEAFLET_DEMO_DEFAULT_LNG, $zoom = LEAFLET_DEMO_DEFAULT_ZOOM) {
if (!is_numeric($latitude) || !is_numeric($longitude) || !is_numeric($zoom)) {
return '';
}
$center = array(
'lat' => $latitude,
'lon' => $longitude,
);
$features = array(
array(
'type' => 'point',
'lat' => $latitude,
'lon' => $longitude,
'popup' => 'Your auto-retrieved or manually entered location',
),
);
$output = '<div class="leaflet-gallery">';
$map_info = leaflet_map_get_info();
foreach ($map_info as $map_id => $map) {
$map['settings']['zoom'] = $zoom;
$map['center'] = $center;
$features[0]['leaflet_id'] = "demo-{$map_id}";
$title = $map_info[$map_id]['label'];
$built_map = leaflet_build_map($map, $features, '300px');
$output .= '<div class="leaflet-gallery-map">' . "<div>{$title}</div>" . render($built_map) . '</div>';
}
$output .= '</div>';
return $output;
}