? .DS_Store ? cloudmade.js Index: mapstraction.admin.inc =================================================================== RCS file: mapstraction.admin.inc diff -N mapstraction.admin.inc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ mapstraction.admin.inc 18 Feb 2009 19:55:44 -0000 @@ -0,0 +1,27 @@ + 'radios', + '#title' => t('Mapstraction API'), + '#description' => t('Select a mapstraction provider'), + '#options' => array( + t('gmap'), + t('yahoo'), + t('Microsoft'), + // t('MapQuest'), mapquest has 4 src files in the script url - we'll deal with this later + t('OpenLayers'), + t('OpenStreetMap') + ), + '#default_value' => variable_get('mapstraction_provider', 0) // defaults to gmap + ); + + $form['#submit'] = array( + 'mapstraction_admin_settings_submit' => array($extra_info) + ); + return system_settings_form($form); +} + +function mapstraction_admin_settings_submit($form_id, &$form_values) { + variable_set('mapstraction_provider',$form_values['mapstraction_provider']); +} \ No newline at end of file Index: mapstraction.apis.inc =================================================================== RCS file: mapstraction.apis.inc diff -N mapstraction.apis.inc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ mapstraction.apis.inc 18 Feb 2009 19:55:44 -0000 @@ -0,0 +1,96 @@ + 'textfield', + '#title' => t('Google Maps API Key'), + '#size' => 40, + '#maxlength' => 255, + '#default_value' => $settings['api_key'], + ); + + return $form; +} + +function mapstraction_google_render($settings) { + $src = 'http://maps.google.com/maps?file=api&v=2&key=' . $settings['api_key']; + return ''; +} + +function mapstraction_yahoo_settings_form($settings) { + $form = array(); + $form['appid'] = array( + '#type' => 'textfield', + '#title' => t('Yahoo Maps App ID'), + '#size' => 40, + '#maxlength' => 255, + '#default_value' => $settings['appid'], + ); + + return $form; +} + +function mapstraction_yahoo_render($settings) { + $src = 'http://api.maps.yahoo.com/ajaxymap?v=3.0&appid=' . $settings['appid']; + return ''; +} + +function mapstraction_mapquest_render() { + $src = 'http://btilelog.beta.mapquest.com/tilelog/transaction?transaction=script&key=mjtd%7Clu6t210anh%2Crn%3Do5-labwu&itk=true&v=5.3.0_RC5&ipkg=controls1'; + return ''; +} + +function mapstraction_microsoft_render() { + $src = 'http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6'; + return ''; +} + +function mapstraction_freeearth_render() { + $src = 'http://freeearth.poly9.com/api.js'; + return ''; +} + +function mapstraction_cloudmade_settings_form($settings) { + $form = array(); + $form['api_key'] = array( + '#type' => 'textfield', + '#title' => t('CloudMade API Key'), + '#size' => 40, + '#maxlength' => 255, + '#default_value' => $settings['api_key'], + ); + + $form['style_id'] = array( + '#type' => 'textfield', + '#title' => t('Map Style ID'), + '#size' => 40, + '#maxlength' => 255, + '#default_value' => $settings['style_id'], + ); + + return $form; +} + +function mapstraction_cloudmade_render($settings, $id) { + $output = mapstraction_openlayers_render($settings); + $src = drupal_get_path('module', 'mapstraction') . '/cloudmade.js'; + $output .= "\n"; + $js = ' + $(document).ready(function() { + var cloudmade = new OpenLayers.Layer.CloudMade("CloudMade", { + key: "' . $settings['api_key'] . '", + styleId: ' . $settings['style_id'] . ', + }); + Drupal.mapstraction["' . $id . '"].maps["openlayers"].addLayer(cloudmade); + });'; + + drupal_add_js($js, 'inline', 'footer'); + + return $output; +} + +function mapstraction_openlayers_render($settings) { + $src = 'http://openlayers.org/api/OpenLayers.js'; + return "\n"; +} \ No newline at end of file Index: mapstraction.drupal.js =================================================================== RCS file: mapstraction.drupal.js diff -N mapstraction.drupal.js --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ mapstraction.drupal.js 18 Feb 2009 19:55:44 -0000 @@ -0,0 +1,21 @@ +$(document).ready(function() { + Drupal.mapstraction = []; + $(Drupal.settings.mapstraction).each(function(index) { + var id = 'mapstraction-' + this.viewName + '-' + this.currentDisplay; + Drupal.mapstraction[id] = new Mapstraction(id, this.apiName); + + // Set start point + var startPoint = new LatLonPoint(38.92, -77.04); + Drupal.mapstraction[id].setCenterAndZoom(startPoint, 13); + + // Set up controls + Drupal.mapstraction[id].addControls(this.controls); + + // Set up markers & info bubbles + $(this.markers).each(function(index) { + marker = new Marker(new LatLonPoint(this.lat, this.lon)); + marker.setInfoBubble(this.title); + Drupal.mapstraction[id].addMarker(marker); + }); + }); +}); Index: mapstraction.info =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/mapstraction/mapstraction.info,v retrieving revision 1.1 diff -u -u -p -r1.1 mapstraction.info --- mapstraction.info 9 May 2008 11:26:14 -0000 1.1 +++ mapstraction.info 18 Feb 2009 19:55:44 -0000 @@ -1,11 +1,5 @@ ; $Id: mapstraction.info,v 1.1 2008/05/09 11:26:14 liorkesos Exp $ name = Mapstraction -package = Location -description = The Mapstraction module encompassed mapstraction which is a javascript libarary that lets; you abstract mapping services. - - -; Information added by drupal.org packaging script on 2007-10-31 -version = "5.x-1.x-dev" -project = "mapstraction" -datestamp = "1193832285" - +core = 6.x +description = Mapstraction allows you to display maps using a number of different mapping APIs. +dependencies[] = views \ No newline at end of file Index: mapstraction.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/mapstraction/mapstraction.module,v retrieving revision 1.1 diff -u -u -p -r1.1 mapstraction.module --- mapstraction.module 9 May 2008 11:26:14 -0000 1.1 +++ mapstraction.module 18 Feb 2009 19:55:44 -0000 @@ -1,107 +1,158 @@ 'admin/settings/mapstraction', - 'title' => t('Mapstraction settings'), - 'description' => t('Mapstraction settings'), - 'callback' => 'drupal_get_form', - 'callback arguments' => array('mapstraction_admin_settings'), - 'access' => user_access('administer site configuration') - ); - $items[] = array( - 'path' => 'mapstraction/node', - 'type' => MENU_NORMAL_ITEM, - 'title' => t('Node locations'), - 'access' => TRUE, - 'callback' => 'mapstraction_node_page', - ); - return ($items); - }else { - $path = drupal_get_path('module', 'mapstraction'); - drupal_add_js($path . '/mapstraction.js'); - } -} - -function mapstraction_admin_settings() { - $form['mapstraction_provider'] = array( - '#type' => 'radios', - '#title' => t('Mapstraction providers'), - '#description' => t('Select a mapstraction provider'), - '#options' => array( - t('gmap'), - t('yahoo'), - t('Microsoft'), - // t('MapQuest'), mapquest has 4 src files in the script url - we'll deal with this later - t('OpenLayers'), - t('OpenStreetMap') - ), - '#default_value' => variable_get('mapstraction_provider', 0) // defaults to gmap +function mapstraction_menu(){ + $items = array(); + $items['admin/settings/mapstraction'] = array( + 'title' => t('Mapstraction settings'), + 'description' => t('Mapstraction settings'), + 'page callback' => 'drupal_get_form', + 'page arguments' => array('mapstraction_admin_settings'), + 'access arguments' => array('administer site configuration'), + 'file' => 'mapstraction.admin.inc', ); - - $form['#submit'] = array( - 'mapstraction_admin_settings_submit' => array($extra_info) - ); - return system_settings_form($form); + + return ($items); } +/** + * Implementation of hook_theme(). + */ +function mapstraction_theme() { + return array( + 'mapstraction_map' => array( + 'arguments' => array('points' => array(), + 'map' => array(), 'width' => 200, 'height' => 200), + ), + ); +} -function mapstraction_admin_settings_submit($form_id, &$form_values) { - variable_set('mapstraction_provider',$form_values['mapstraction_provider']); +/** + * Implementation of hook_views_api(). + */ +function mapstraction_views_api() { + return array('api' => 2); +} + +/** + * Implementation of hook_views_plugins(). + */ +function mapstraction_views_plugins() { + return array( + 'module' => 'mapstraction', + 'style' => array( + 'mapstraction' => array( + 'title' => 'Mapstraction', + 'help' => 'Displays nodes as a Maptraction map.', + 'handler' => 'mapstraction_style_map', + 'theme' => 'mapstraction_map', + 'theme file' => 'mapstraction.module', + 'uses fields' => TRUE, + 'uses options' => TRUE, + 'type' => 'normal', + ), + ), + ); } -function mapstraction_add_marker($nid,$lat,$long,$title='',$body=''){ - $out = "var myPoint_$nid = new LatLonPoint($lat,$long);"; -// display the map centered on a latitude and longitude (Google zoom levels) - $out .= "mapstraction.setCenterAndZoom(myPoint_$nid, 10);"; - $out .= "mapstraction.addControls({ pan: true, zoom: 'small', map_type: true });"; -// create a marker positioned at a lat/lon - $out .= "my_marker_$nid = new Marker(myPoint_$nid);"; - $out .= "my_marker_$nid.setIcon('icon.gif');"; - $out .= "mapstraction.addMarker( new Marker( new LatLonPoint($lat,$long)));"; -// add a label to the marker - $out .= "my_marker_$nid.setLabel(\"$title\");"; - $out .= "var text = \"$body\";"; -// add info bubble to the marker - $out .= "my_marker_$nid.setInfoBubble(text);"; - $out .= "mapstraction.addMarker(my_marker_$nid);"; -//mapstraction.addEventListener('click', function(p) { alert('Mapstraction Event Handling - Mouse clicked at ' + p) }); -// open the marker - $out .= "my_marker_$nid.openBubble();"; -// $out .= "ufoo = function() { mapstraction.removeMarker(my_marker_$nid); }"; - return $out; +/** + * Provides information about the available mapping API's. API defiitions + * are stored in mapstraction.apis.inc. + * + * @param $full + * Whether to return the full API definition or just an array for use as the + * value for a Form API #options. + */ +function mapstraction_apis($full = FALSE) { + $apis = array( + 'google' => array( + 'title' => t('Google Maps'), + 'settings form' => 'mapstraction_google_settings_form', + 'render' => 'mapstraction_google_render', + ), + 'yahoo' => array( + 'title' => t('Yahoo Maps'), + 'settings form' => 'mapstraction_yahoo_settings_form', + 'render' => 'mapstraction_yahoo_render', + ), + 'mapquest' => array( + 'title' => t('MapQuest'), + 'render' => 'mapstraction_mapquest_render', + ), + 'microsoft' => array( + 'title' => t('Microsoft Virtual Earth'), + 'render' => 'mapstraction_microsoft_render', + ), + 'openlayers' => array( + 'title' => t('OpenLayers'), + 'render' => 'mapstraction_openlayers_render', + ), + 'freeearth' => array( + 'title' => t('FreeEarth'), + 'render' => 'mapstraction_freeearth_render', + ), + 'cloudmade' => array( + 'title' => t('CloudMade'), + 'api' => 'openlayers', + 'settings form' => 'mapstraction_cloudmade_settings_form', + 'render' => 'mapstraction_cloudmade_render', + ), + ); + + if (!$full) { + foreach ($apis as $key => $api) { + $apis[$key] = $api['title']; + } + } + + return $apis; } -function mapstraction_create_map(){ - $provider = variable_get('mapstraction_provider',0); - $mapstraction_settings = array( - 0 => array ('type'=>'google','src' => 'http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAYfI_xw3MwUbmAScWsa72VBSeiHve5IwsMuqAjxrbixTJ6mqDsxTZLbNcpVxq9PneOXm7mkBjelEQpw'), - 1 => array ('type'=>'yahoo','src' => 'http://api.maps.yahoo.com/ajaxymap?v=3.0&appid=MapstractionDemo'), - 2 => array ('type'=>'microsoft','src' => 'http://dev.virtualearth.net/mapcontrol/v3/mapcontrol.js'), - 3 => array ('type'=>'openlayers','src' => 'http://openlayers.org/api/OpenLayers.js'), - 4 => array ('type'=>'openstreetmap','src' => 'http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAYfI_xw3MwUbmAScWsa72VBSeiHve5IwsMuqAjxrbixTJ6mqDsxTZLbNcpVxq9PneOXm7mkBjelEQpw') + +/** + * Theme a map from Mapstraction view. + */ +function theme_mapstraction_map($view, $options, $rows) { + drupal_add_js(drupal_get_path('module', 'mapstraction') . '/mapstraction.js'); + drupal_add_js(drupal_get_path('module', 'mapstraction') . '/mapstraction.drupal.js'); + + $api_name = $view->style_plugin->options['api']; + $apis = mapstraction_apis(TRUE); + $api = $apis[$api_name]; + + // Allow the API definition to override the API name. + $api_settings = $options['api_settings'][$api_name]; + $api_name = $api['api'] ? $api['api'] : $api_name; + + // Clean up controls for JS + foreach ($options['controls'] as $control => $value) { + if ($control == 'zoom') { + $controls[$control] = $value; + } + elseif ($value) { + $controls[$control] = TRUE; + } + } + + $map = array( + 'viewName' => $view->name, + 'currentDisplay' => $view->current_display, + 'apiName' => $api_name, + 'markers' => $view->style_plugin->map_points($rows), + 'controls' => $controls, ); - $out = ""; - $out .= '
'; - $out .= ''; - $out .= ''; // *** yahoo *** - $out .= ''; - $out .= ''; - return $out; -} -function mapstraction_node_page(){ - $out .= mapstraction_create_map(); - $out .= mapstraction_add_marker(6,"31.47","35.13"); - $out .= mapstraction_close_map(); - return $out; -} + return $output; +} \ No newline at end of file Index: mapstraction_style_map.inc =================================================================== RCS file: mapstraction_style_map.inc diff -N mapstraction_style_map.inc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ mapstraction_style_map.inc 18 Feb 2009 19:55:44 -0000 @@ -0,0 +1,132 @@ + '600x400'); + $this->options['controls'] = array(); + + return $options; + } + + function options_form(&$form, &$form_state) { + $form['api'] = array( + '#type' => 'select', + '#title' => t('Mapping API'), + '#description' => t('Select the Mapstraction API to use for this view.'), + '#options' => mapstraction_apis(), + '#default_value' => $this->options['api'], + ); + + foreach (mapstraction_apis(TRUE) as $key => $api) { + module_load_include('inc', 'mapstraction', 'mapstraction.apis'); + if (function_exists($api['settings form'])) { + $form['api_settings'][$key] = $api['settings form']($this->options['api_settings'][$key]); + } + } + + $form['dimensions'] = array( + '#type' => 'textfield', + '#title' => t('Dimensions'), + '#size' => 10, + '#maxlength' => 255, + '#default_value' => $this->options['dimensions'], + ); + + $form['controls'] = array( + '#type' => 'checkboxes', + '#title' => t('Controls'), + '#description' => t('Select which controls should be displayed on the map.'), + '#options' => array( + 'pan' => t('Pan'), + 'overview' => t('Overview'), + 'scale' => t('Scale'), + 'map_type' => t('Map type')), + '#default_value' => $this->options['controls'], + ); + + $form['zoom_control'] = array( + '#type' => 'select', + '#title' => t('Zoom Control'), + '#options' => array( + 0 => t('None'), + 'large' => t('Large'), + 'small' => t('Small'), + ), + '#default_value' => $this->options['controls']['zoom'], + ); + + $handlers = $this->display->handler->get_handlers('field'); + if (empty($handlers)) { + $form['error_markup'] = array( + '#value' => t('You need at least one field before you can configure your field settings'), + '#prefix' => '