包含 Drupal、GMap 和位置的覆盖图

发布于 2024-10-06 20:59:26 字数 214 浏览 0 评论 0原文

我在 Drupal 站点上使用 GMap、位置和用户位置模块。我想要一张可以显示我的用户的“覆盖范围”的地图。覆盖半径存储在参考用户的自定义内容类型中。

如何在地图上仅显示用户的覆盖范围?我在使用 GMap 宏时看到了这样的显示类型,所以我认为可以通过这种方式使用 GMap。

我想 GMap 模块很可能不支持开箱即用。不管怎样,如果有人能指出我正确的方向,我会非常高兴......

I'm using the GMaps, Location and User locations module on my Drupal site. I would like to have a map which can display the "coverage" of my users. The coverage radius is stored in a custom content type with reference to the user.

How is it possible to display users with only their coverage circle on a map? I saw a display type like this when playing with the GMap macros, so I think it would be possible to use GMaps that way.

I suppose most likely this isn't supported out-of-the-box with the GMap module. Anyway, I would be really glad if anybody could point me into the right direction...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

毁我热情 2024-10-13 20:59:26

毕竟,在匈牙利社区的帮助下,我成功地做到了这一点。 (我很乐意链接原始线程,但它似乎已被删除。)

基本上,“技巧”是制作一个带有钩子的小自定义模块:

function MODULENAME_preprocess_gmap_view_gmap(&$vars) {
  if ( $vars['view']->name == "my_gmap_view" ) {
    $map_object = $vars['map_object'];
    $map_object['id'] = 'my_view_id';
    foreach ($vars['view']->result as $key => $row) {
      $shapes[$key]['type'] = 'circle';

      // we have a profile field for the radius, but it could be anything...
      $shapes[$key]['radius'] = $row->profile_values_profile_radius_value;

      // center the circles on the coord
      $shapes[$key]['center'][0] = $row->location_latitude;
      $shapes[$key]['center'][1]= $row->location_longitude;
    }

    // we don't need any markers, just the circles
    $map_object['markers'] = NULL;
    $map_object['shapes'] = $shapes;
    $vars['map'] = theme('gmap', array('#settings' => $map_object));
  }
}

I've managed to do this after all with the help of the Hungarian community. (I would be happy to link the original thread, but it seems it got deleted.)

Basically the "trick" was to make a little custom module with a hook:

function MODULENAME_preprocess_gmap_view_gmap(&$vars) {
  if ( $vars['view']->name == "my_gmap_view" ) {
    $map_object = $vars['map_object'];
    $map_object['id'] = 'my_view_id';
    foreach ($vars['view']->result as $key => $row) {
      $shapes[$key]['type'] = 'circle';

      // we have a profile field for the radius, but it could be anything...
      $shapes[$key]['radius'] = $row->profile_values_profile_radius_value;

      // center the circles on the coord
      $shapes[$key]['center'][0] = $row->location_latitude;
      $shapes[$key]['center'][1]= $row->location_longitude;
    }

    // we don't need any markers, just the circles
    $map_object['markers'] = NULL;
    $map_object['shapes'] = $shapes;
    $vars['map'] = theme('gmap', array('#settings' => $map_object));
  }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文