function ip_geoloc_generator_ip_geoloc_marker_locations_alter in IP Geolocation Views & Maps 7
Same name and namespace in other branches
- 8 modules/ip_geoloc_generator/src/Form/ip_geoloc_generator.module \ip_geoloc_generator_ip_geoloc_marker_locations_alter()
Implements hook_ip_geoloc_marker_locations_alter().
File
- ip_geoloc_generator/
ip_geoloc_generator.module, line 24 - ip_geoloc_generator.module
Code
function ip_geoloc_generator_ip_geoloc_marker_locations_alter(&$marker_locations, &$view) {
$enabled_views = variable_get('ip_geoloc_generator_views', array());
if (!in_array($view->name, $enabled_views)) {
return;
}
$center_lat = variable_get('ip_geoloc_generator_center_lat');
if (empty($center_lat)) {
$center_lat = IP_GEOLOC_GENERATOR_GREENWICH_OBSERVATORY_LAT;
}
$center_lon = variable_get('ip_geoloc_generator_center_lon');
if (empty($center_lon)) {
$center_lon = IP_GEOLOC_GENERATOR_GREENWICH_OBSERVATORY_LON;
}
$range_lat = variable_get('ip_geoloc_generator_range_lat', 0.02);
$range_lon = variable_get('ip_geoloc_generator_range_lon', 0.12);
$no_points = variable_get('ip_geoloc_generator_no_points', 10);
$separator = filter_xss_admin(variable_get('ip_geoloc_balloon_separator', '<br/>'));
for ($i = 1; $i <= $no_points; $i++) {
$marker = new stdClass();
//$marker->id = $i;
//$marker->type = 'point';
//$marker->marker_color = 'yellow';
$marker->latitude = $center_lat + $range_lat * (mt_rand() / mt_getrandmax() - 0.5);
$marker->longitude = $center_lon + $range_lon * (mt_rand() / mt_getrandmax() - 0.5);
$marker->balloon_text = "Random #{$i}{$separator}(" . $marker->latitude . ', ' . $marker->longitude . ')';
$marker_locations[] = $marker;
}
}