function BV_RouteMap()
{
  // variable to hold a GMap2 instance
  var map = null;
    
  // variable to hold a GClientGeocoder instance
  var geocoder = null;

  // variable to hold a reference to the container html element
  var container = document.getElementById("map");
  
  // variables to be passed in to the map
  var map_key_title = null;
  var map_id = 'map';
  var map_center_address = "EH1";
  var map_control_large = 1;
  var map_control_small = 1;
  var map_geocoder_fallback = 0;
  var map_height = '500px';
  var map_popup_on_open = 0;
  var map_title = 'Location';
  var map_width = '600px';
  var map_zoom_level = 12;
  var map_markers = new Array();
  var func_parent = this;


  // }}}
  // {{{ geocoder_callback_getLatLng() function
  

  /** 
   * callback function for geocoder.getLatLng function
   */
  geocoder_callback_getLatLng = function(point) 
  {
  	if (!point) {
      alert('the address has not been recognised');
    } else {
      map.setCenter(point, map_zoom_level);
      
      // add map controls
      if (map_control_large == 1) {
        map.addControl(new GLargeMapControl());
        map.addControl(new GMapTypeControl());
      } else if (map_control_small == 1) {
        map.addControl(new GSmallMapControl());
      }
      
      map.clearOverlays();
      func_parent.draw_route();
      func_parent.draw_stops();
    }
  }
  
  // }}}
  // {{{ load_map() function
  
  /**
   * if the browser is compatible, loads an instance of the GMap2 and GClientGeocoder instances, and sets appropriate callbacks
   */
  this.load_map = function() {
    if (GBrowserIsCompatible()) {
      geocoder = new GClientGeocoder();
      map = new GMap2(document.getElementById(map_id));
      
      geocoder.getLatLng(map_center_address, geocoder_callback_getLatLng);
    }
  }
  
  // }}}
  // {{{ add_marker()
  
  /**
   * adds a marker to the map
   */
  this.add_marker = function(point, tram_stop) {
  	var stop_marker_icon = new GIcon(G_DEFAULT_ICON);
  	stop_marker_icon.image = "http://www.edinburghtrams.com/include/img/ui/gmap_stop.png";
    stop_marker_icon.iconSize = new GSize(20,20);
    stop_marker_icon.iconAnchor = new GPoint(10,10);
    stop_marker_icon.shadow = false;

  	if (point) {
      if (point instanceof GLatLng) {
      	var marker_options = {icon:stop_marker_icon};
        var tmp_marker = new GMarker(point, marker_options);
        
        if (tmp_marker instanceof GOverlay) {
        	var marker_html = "<html><h3>"+tram_stop.tram_stop_title+"</h3>";
        	marker_html += tram_stop.local_update_title ? "<p>"+tram_stop.local_update_title+"</p><p class='no-gap'><a href='/index.php/local_update/by_tram_stop/?tram_stop="+tram_stop.tram_stop_title+"'>link to update</a></p>" : '';
        	marker_html += "</html>";
        	
          GEvent.addListener(tmp_marker, "click", function() {tmp_marker.openInfoWindow(marker_html);});
          map.addOverlay(tmp_marker);
        }
      }
    }
  }
        // }}}
  // {{{ draw_route
  
  /**
   * draws the tram route
   */
  this.draw_route = function(route_string) {
  	var edinburgh_west_points = [[55.94762585968953, -3.3605074882507324], [55.94599175337298, -3.3592844009399414],[55.94521072232269, -3.358640670776367],[55.944609918488176, -3.3580827713012695],[55.94328811724263, -3.3570313453674316],[55.942843501229746, -3.356795310974121],[55.94138945106074, -3.356301784515381],[55.94044008306542,-3.3559584617614746], [55.94025982069083,-3.3556365966796875], [55.940067539899935,-3.355271816253662], [55.9399473639209,-3.3548426628112793], [55.93999543435724,-3.354198932647705], [55.94036797821624,-3.352653980255127], [55.94048815289028,-3.3517098426818848], [55.940307890739426,-3.336024284362793], [55.940211750582584,-3.335123062133789], [55.93989929342489,-3.334479331970215], [55.93917822882575,-3.3336639404296875], [55.93831293358829,-3.3338356018066406], [55.93800046111334,-3.3335351943969727], [55.93783220565971,-3.3330631256103516], [55.93792835172271,-3.332247734069824], [55.938841727419145,-3.329286575317383], [55.939034014295146,-3.3270978927612305], [55.939538762803174,-3.3246517181396484], [55.940211750582584,-3.3231067657470703], [55.940428065599875,-3.3210039138793945], [55.94040403065762,-3.3205747604370117], [55.940211750582584,-3.3201026916503906], [55.939538762803174,-3.3196306228637695], [55.93869751163572,-3.319845199584961], [55.937952388201175,-3.3182573318481445], [55.937519729306906,-3.3175277709960938], [55.935380400423064,-3.3168411254882812], [55.93389001160688,-3.3162832260131836], [55.93131775411201,-3.3147811889648438], [55.92780766933176,-3.3123779296875], [55.92761532673046,-3.311905860900879], [55.92730276796719,-3.3109617233276367], [55.92718255238699,-3.3096742630004883], [55.92747106915297,-3.3069276809692383], [55.928937662834336,-3.293581008911133], [55.929394459365554,-3.289804458618164], [55.92975508440228,-3.2874441146850586], [55.93011570608279,-3.285684585571289], [55.93078885757336,-3.282809257507324], [55.931413916343374,-3.2802772521972656], [55.931822603164214,-3.2783889770507812], [55.93232744563846,-3.27542781829834], [55.93249572500143,-3.274354934692383], [55.93276016252373,-3.27242374420166], [55.93321691399302,-3.26993465423584], [55.933553464261685,-3.2683467864990234], [55.933817894564726,-3.267488479614258], [55.93410636192787,-3.2669734954833984], [55.93499578944325,-3.266587257385254], [55.935404438482514,-3.2657718658447266], [55.9360053851215,-3.262038230895996], [55.9368466947551,-3.258218765258789], [55.93756780275603,-3.2549142837524414], [55.93812064313276,-3.2522106170654297], [55.93876961959457,-3.2491636276245117], [55.939250335889696,-3.2470178604125977], [55.93965894004996,-3.245387077331543], [55.940139645308385,-3.242983818054199], [55.940860692010276,-3.2399797439575195], [55.94124524476286,-3.2384347915649414], [55.941984296364254,-3.2371902465820312],[55.941984296364254,-3.2371902465820312], [55.94253106530222,-3.236128091812134], [55.942825476148606,-3.2352912425994873], [55.942915601470474,-3.233671188354492], [55.94310786812289,-3.2322120666503906], [55.94328811724263,-3.229851722717285], [55.94338424976352,-3.2287144660949707], [55.94367264589437,-3.2273411750793457], [55.94426144799335,-3.2245302200317383], [55.944838225043306,-3.2218480110168457], [55.9452708021935,-3.2213973999023438], [55.9454390253359,-3.221161365509033], [55.945583216019195,-3.2207322120666504], [55.945787485234824,-3.220539093017578], [55.9457995010375,-3.219723701477051], [55.9457995010375, -3.2188868522644043]];	
  	var city_centre_points = [[55.9457995010375, -3.2188868522644043], [55.94588361155169,-3.2178354263305664], [55.946244083114905,-3.21699857711792], [55.94672470664625,-3.215925693511963], [55.9473735389513,-3.214445114135742], [55.94841885702034,-3.2120847702026367], [55.949235867587824,-3.2102608680725098], [55.94994473043635,-3.2086730003356934], [55.950088904342806,-3.2082009315490723], [55.95046135111642,-3.205733299255371], [55.95150658582889,-3.199596405029297], [55.951710823798976,-3.1984591484069824], [55.952407627588634,-3.1943178176879883], [55.952756024780655,-3.1923651695251465], [55.95288817461955,-3.191699981689453], [55.95297226973671,-3.1915712356567383], [55.953152472944105,-3.1915283203125], [55.953741130909584,-3.191807270050049], [55.95461809454369,-3.1923651695251465], [55.95569925524213,-3.192923069000244], [55.95581938234472,-3.192880153656006], [55.95631189956801,-3.190004825592041], [55.95656416206049,-3.188502788543701], [55.95679239813717,-3.1874942779541016], [55.95692453419805,-3.18678617477417]];
  	var edinburgh_north_points = [[55.95692453419805,-3.18678617477417], [55.95705666980788,-3.1859493255615234], [55.95771734109132,-3.184983730316162], [55.95843806054009,-3.184382915496826], [55.959098708246145,-3.1837821006774902], [55.959675264302305,-3.182988166809082], [55.960828350649734,-3.1815075874328613], [55.96180124053477,-3.180241584777832], [55.96283415858417,-3.1789326667785645], [55.963590813614154,-3.1779885292053223], [55.964959961301325,-3.1766152381896973], [55.96582466119842,-3.1758856773376465], [55.96690550889822,-3.1749415397644043], [55.96859877626237,-3.173503875732422], [55.96889899323855,-3.173203468322754], [55.96966753808287,-3.172602653503418], [55.970291969528134,-3.1720876693725586], [55.97056815714514,-3.171851634979248], [55.97096442289103,-3.170907497406006], [55.971468755243095, -3.170006275177002], [55.97178095769022,-3.1695556640625], [55.97205713467794,-3.1692981719970703], [55.97284963160981,-3.1685900688171387], [55.973329924879664,-3.168160915374756], [55.973714155202245,-3.1677961349487305], [55.97455464572809,-3.167281150817871], [55.9750589312782,-3.1668734550476074], [55.9754791642148,-3.166530132293701], [55.97657174848467,-3.1657791137695312], [55.9766677983733,-3.1656289100646973], [55.97734014091544,-3.165113925933838], [55.977496218762724,-3.1650924682617188], [55.977652295980235,-3.1651782989501953], [55.977928431052995,-3.1659507751464844], [55.97842066694559,-3.167238235473633], [55.97873281329017,-3.167753219604492], [55.97884086336095,-3.1682252883911133], [55.97902094614153,-3.1688904762268066], [55.9792610552113,-3.1708216667175293], [55.97948915744691,-3.172173500061035], [55.97964522662248,-3.172881603240967], [55.98004139939356,-3.1740832328796387], [55.98048558828077,-3.1750059127807617], [55.980905762262545,-3.1757140159606934], [55.98106182572166,-3.176100254058838], [55.98098979651109,-3.1763792037963867], [55.98026949702693,-3.177645206451416], [55.97958520009102,-3.178868293762207], [55.97954918412743,-3.1792116165161133], [55.97953717879878,-3.1795120239257812], [55.98001738903812,-3.1804990768432617], [55.980065409734124,-3.1807994842529297], [55.979945357882315,-3.184683322906494], [55.97987332659237,-3.1868505477905273], [55.979921347467226,-3.188202381134033], [55.98007741489881,-3.1894898414611816], [55.98036553773327,-3.1905412673950195]];
  	var route_points = [];
  	
  	map.clearOverlays();
  	map.setCenter(new GLatLng(55.956853, -3.26798), 12);
  	
  	switch (route_string) {
  	  case 'edinburgh_west' :
  	    route_points = edinburgh_west_points;
  	    break;
  	  case 'city_centre' :
  	    route_points = city_centre_points;
  	    break;
  	  case 'edinburgh_north' :
  	    route_points = edinburgh_north_points;
  	    break;
  	  default :
  	    route_points = route_points.concat(edinburgh_west_points, city_centre_points, edinburgh_north_points);  
        break;
    }
  	
  	var route_glatlng = [];
    
    for (var i in route_points) {route_glatlng.push(new GLatLng(route_points[i][0], route_points[i][1]));}
  	
    var polyOptions = {geodesic:true};
    var polyline = new GPolyline(route_glatlng, "#ff0000", 2, 1, polyOptions);
    map.addOverlay(polyline);  
  } 
  
  // }}}
  // {{{ draw_stops
  
  /**
   * draws the tram stops as points
   */
  this.draw_stops = function(route_string)
  {
  	var edinburgh_west_tram_stops = ['Edinburgh Airport', 'Ingliston Park & Ride', 'Gogarburn', 'Gyle Centre', 'Edinburgh Park Central', 'Edinburgh Park Station', 'Bankhead', 'Saughton', 'Balgreen', 'Murrayfield Stadium', 'Haymarket'];
  	var city_centre_tram_stops = ['Haymarket', 'Shandwick Place', 'Princes Street', 'St Andrew Square', 'Picardy Place'];
  	var edinburgh_north_tram_stops = ['Picardy Place', 'McDonald Road', 'Balfour Street', 'Foot of the Walk', 'Bernard Street', 'Port of Leith', 'Ocean Terminal', 'Newhaven'];
  	var route_points = [];
  	
  	switch (route_string) {
  	  case 'edinburgh_west' :
  	    route_points = edinburgh_west_tram_stops;
  	    break;
  	  case 'city_centre' :
  	    route_points = city_centre_tram_stops;
  	    break;
  	  case 'edinburgh_north' :
  	    route_points = edinburgh_north_tram_stops;
  	    break;
  	  default:
  	    route_points = route_points.concat(edinburgh_west_tram_stops, city_centre_tram_stops, edinburgh_north_tram_stops);  
        break;
    }
    
  	// foreach of the tram stops
    for (var i in tram_stops) {
      for (var a in route_points) {
        if (tram_stops[i].tram_stop_title == route_points[a]) {
          if (tram_stops[i].gmap_point_lat!='' && tram_stops[i].gmap_point_lng!='undefined') {
            var tmp_glat_lng = new GLatLng(tram_stops[i].gmap_point_lat, tram_stops[i].gmap_point_lng);
            this.add_marker(tmp_glat_lng, tram_stops[i]);
          }
          break;
        }
      }  
    }
  }
  
  // }}}
  // {{{
  
  /**
   *
   */
  this.isLoaded = function() {
    return map.isLoaded();
  }
  // }}}
}