OK, so here's my scenario:
Each user has a location. to achive this I got the content_profile installed. This way, I could assign an OpenLayers Geocoder CCK field to users using a new content type.
Next, I want to display in a map the users that are near the user viewing the map. To do this I setup a view that displays all users on a map.
Next I wrote this:

<?php
global $user;
$sql = db_query("SELECT node.uid, content_type_profile.field_location_wkt_openlayers_wkt AS userlocation
FROM node
INNER JOIN content_type_profile ON node.nid = content_type_profile.nid WHERE node.uid = %d", $user->uid);
while ($row = db_fetch_object($sql)) {
  $output .= $row->userlocation;
}
echo $output;
?>

that actually outputs the location of the current user in the form of
GEOMETRYCOLLECTION(POINT(X Y)) where X and Y are the coordinates.

What I need to do now is filter my view using the proximity filter and on the "Configure filter Proximity: Great-circle" page, declare as a location the one that the above code returns.
I couldn't find a way to do it... can anyone help?

Comments

aristeides’s picture

correction... the view is not a user view but a node view that displays profiles.

aristeides’s picture

Ok, I realize this can't be done using the UI of OL Proximity filter, but still, it could be done by hacking the OL Proximity module file, right?

aristeides’s picture

Anyone? I could really use some help here...

scalp’s picture

aristeides,

The only way I've tried doing something similar to this is by building the view through something like "Advanced Front Page" module. That way you can use something like:

<?php
global $user;
$profile = content_profile_load(provider_profile, $user->uid);
$view = views_get_view('yourviewname'); // fetch the view
$display_id = 'default'; // chose the display type
$view->set_display($display_id);
$view->is_cacheable = FALSE;
$item = $view->get_item($display_id, 'filter', 'circle');// telling the view that we are fetching filter.  circle is the filter name. We can check the filter name from view export as well.
$item['value'] = array('value' => '30', 'min' => '', 'max' => '', 'location' => '', 'node' => $profile->nid, 'unit' => 'miles'); // passing values to all the exposed filter. We can pass other options like operator etc (not just value) as well.
$view->set_item($display_id, 'filter', 'circle', $item); // set item
$view->is_cacheable = FALSE;
$view->pre_execute();
$output = $view->render(); // render
print $output; // display output
?>

This will set up the view to show results that are in a 30 mile circle from the logged in user's content profile location.

At least that got it working for me.

scottrigby’s picture

Title: proximity from user's location... almost there? » user type view & content_profile

Is there any interest in supporting user type views?

The ideal way to do this in views normally is a user type view (allows exposed filters on fields from multiple content_profile types). Currently a user view gives results like:

warning: Illegal offset type in /openlayers_proximity/views/openlayers_proximity_handler_filter.inc on line 271 Edit: this part was because i had the filter in twice.

user warning: Unknown column 'node_users__openlayers_proximity_filter_circle.distance' in 'field list'in /views/plugins/views_plugin_pager.inc on line 141 and in /views/plugins/views_plugin_query_default.inc on line 1150.

petednz’s picture

not for me - but this is the only thread i see that seems to raise the issue of using proximity with Views types other than nodes. My goal would be to have it work with civievent (civicrm) type since these have their own Lat Long fields. So are we both asking about what is involved in having Proximity work with non-node view types?
I should have said that problem I am finding is the Proximity just doesn't show under 'Groups' in Filters at all. So I should probably fire this off as a separate issue.