Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 12th, 2012  |  syntax: None  |  size: 2.07 KB  |  hits: 8  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Timemap and mapstraction geocode
  2. tm = TimeMap.init({
  3.         mapId: "map",               // Id of map div element (required)
  4.         timelineId: "timeline",     // Id of timeline div element (required)
  5.         datasets: [
  6.             {
  7.                 id: "fdmdata",
  8.                 title: "FDM Data",
  9.                 theme: "green",
  10.                 type: "remote", // or is it type: "jsonp"
  11.                 options: {    
  12.                     //query: fdmMapQuery,
  13.                     url: "loadFdmMapData.ge?" +
  14.                     "orderby=starttime&sortorder=ascending&callback=?",
  15.                     preloadFunction: preloadData,                        
  16.                     transformFunction: transformData,
  17.                 }
  18.             },
  19.         ],
  20.         bandInfo: [    
  21.             {
  22.                      width:          "85%",
  23.                      intervalUnit:   Timeline.DateTime.MONTH,
  24.                      intervalPixels: 200,
  25.                      theme:          theme
  26.             },
  27.             {
  28.                      width:          "15%",
  29.                      intervalUnit:   Timeline.DateTime.DAY,
  30.                      intervalPixels: 300,
  31.                      overview:       true
  32.             }
  33.         ]
  34.     });
  35. });
  36.  
  37.  
  38. function transformData(data) {      
  39.     var title, description, start, end, lat, lon, infoHtml;
  40.     var newData = {
  41.         "title" : title,
  42.         "start" : start,
  43.         "end" : end,
  44.         "options" : {
  45.             "description" : description
  46.         }
  47.     };
  48.     newData["point"] = {
  49.        "lat" : lat,
  50.         "lon" : lon
  51.     };            
  52.     newData["options"]["infoHtml"] = infoHtml;
  53.     return newData;
  54. }
  55.  
  56. function preloadData(result) {
  57.     var entries = (result.feed.entry);
  58.     var events = [];
  59.     // delete events without geotags
  60.     for (var x=0; x<entries.length; x++) {
  61.         entry = entries[x];
  62.         var location = entry['gd$where'][0].valueString;
  63.         var pattern = new RegExp(/@s*([-0-9.]+)s*,s*([-0-9.]+)s*/);
  64.         var matches = pattern.exec(location);
  65.         if (matches != null) events.push(entry);
  66.     }
  67.     return events;
  68. }