
// ===== Begin Map Type ========== //
var mtUnique;

function MapTypeControl() {
    if (mtUnique == null)
        mtUnique = 0;
    else
        mtUnique += 1;
    this.unique = mtUnique.toString();
}

MapTypeControl.prototype = new GControl();

MapTypeControl.prototype.initialize = function(map) {
  var container = document.createElement("div");
  container.style.fontFamily = 'Arial';
  container.style.fontSize = 'x-small';
  
  var cboMap = document.createElement("SELECT");
  cboMap.id = "cboMap" + this.unique;
  var mts = map.getMapTypes();
  for(var i=0;i < mts.length; i++) {
    var o = document.createElement("OPTION");
    o.text = mts[i].getName();
    o.value = i;
    cboMap.options.add(o); 
  }
  cboMap.selectedIndex = maptypidx;
  cboMap.title = "Select background map type.";
  container.appendChild(cboMap);
      
  var unique = this.unique;
      
  GEvent.addDomListener(cboMap, "change", function() {
    var sel = document.getElementById("cboMap" + unique); 
    var mt1 = map.getMapTypes()[sel.options[sel.selectedIndex].value];
    map.setMapType(mt1);
  });
  map.getContainer().appendChild(container);
  return container;
}
MapTypeControl.prototype.getDefaultPosition = function() {
  return new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(10, 10));
}
// ===== End Map Type ==== //
