array( 'name' => t('Mapstraction View'), 'theme' => 'views_view_mapstraction', 'needs_fields' => true, 'validate' => 'mapstractions_views_validate', ) ); } /** * Validate a Mapstraction View. * Mapstracition Views requires one of the following: * - Location: Lat and Location: Lon * - Two columns, one titled t('Latitude'), one titled t('Longitude') * - A module that can transform a field into lat, long coordinates */ function mapstraction_views_validate($type, $view, $form) { $ids = _gmap_views_find_coords_ids($view); if (!($ids['lat'] && $ids['lon']) && !(isset($ids['module']))) { form_error($form["$type-info"][$type .'_type'], t('GMap View requires: either "Location: Latitude" and "Location: Longitude" or a field titled "Latitude" and a field titled "Longitude"')); } return views_ui_plugin_validate_list($type, $view, $form); } function theme_views_view_mapstraction($view, $results){ $fields = _views_get_fields(); // find the ids of the column we want to use // $point_ids = _mapstraction_views_find_coords_ids($view); $out = mapstraction_create_map(); foreach( $results as $marker){ $title = $marker->node_title? $marker->node_title:'Add title field to view to replace this text'; $out .= mapstraction_add_marker($marker->nid,$marker->location_latitude,$marker->location_longitude,$title); } $out .= mapstraction_close_map(); return $out; }