Draw circle overlay in all points in gmap from Radius in a CCK field | Dynamic gmap Macro in Views

Lately I needed to add a circle in every marker in a gmap provided by Views.

So in order to achieve this, I filled in the Macro textarea of the Style:Gmap settings of the View with the following code. But first, I added the field that contains the Radius value and excluded it from Display, to make the value available in the view result set. This value was in miles, so I made the conversion from km as well.

= array();
$view = views_get_current_view();
foreach (
$view->result as $result) {
$lat = $result->gmap_lat ;
$lon = $result->gmap_lon;
$radius = $result->the_cck_field_holding_the radius;
$radius = $radius*0.621371192;
array_push($circles, "circle=".$lat." ,".$lon." + ".$radius);
"[gmap ".implode('|', $circles)."]";

However, for this to work, I needed to change the input format of this textarea in order to accept PHP, by editing the gmap.module file.

So according to http://drupal.org/node/954384 :

I needed to change

function gmap_parse_macro($instring, $ver = 2) {
drupal_get_path('module', 'gmap') . '/gmap_parse_macro.inc';


function gmap_parse_macro($instring, $ver = 2) {
$instring=check_markup($instring, 3, FALSE);
drupal_get_path('module', 'gmap') . '/gmap_parse_macro.inc';

Drupal 6, Drupal Quick Tips, Views

Recent Comments

Forward by Dries Buytaert, Founder and Project Lead, Drupal; CTO Acquia.

Order now from:

Managing Expectations Podcast with DrupalEasy

Author Interview http://tinyurl.com/8a8nxno

We provide the most Shiny Drupal Bits & Pixels

Since Drupal 4.x