// JavaScript Document
function MapAreaMarkerShowControl() {
}
MapAreaMarkerShowControl.prototype = new GControl();
MapAreaMarkerShowControl.prototype.initialize = function(map) {
  var container = document.createElement("div");

  var showArea = document.createElement("span");
  this.setButtonStyle_(showArea);
  container.appendChild(showArea);
  showArea.appendChild(document.createTextNode("显示地图范围内的信息"));

  GEvent.addDomListener(showArea, "click", function() {
	ml.clearMarkers();
	ml = new ML({page:1, fix: false},{url:"/ajax/getmarks", parameters:"act=area&bounds="+UI.map.getBounds()+"&page=1"},{listStyle: listTemplate, winStyle: winTemplate, listDiv: $("ml_list"), tailDiv: $("ml_tail")});
	ml.request();
	//window.location = "http://" + window.location.hostname + '/area?bounds='+UI.map.getBounds() + '&zoom='+UI.map.getZoom();
  });
  map.getContainer().appendChild(container);
  return container;
}

// 地图控件位置
MapAreaMarkerShowControl.prototype.getDefaultPosition = function() {
  return new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(10, 20));
}

// 地图控件样式
MapAreaMarkerShowControl.prototype.setButtonStyle_ = function(button) {
	button.className = "mapbutton";
}

function MapAddControl() {
}
MapAddControl.prototype = new GControl();
MapAddControl.prototype.initialize = function(map) {
  var container = document.createElement("div");

  this.setButtonStyle_(UI.spans.addTopic);
  container.appendChild(UI.spans.addTopic);
  
  GEvent.addDomListener(UI.spans.addTopic, "click", function() {
	window.location = "http://" + window.location.hostname + '/addmap?lat='+UI.map.getCenter().lat()+'&lng='+UI.map.getCenter().lng() + '&zoom='+UI.map.getZoom();
  });

  UI.map.getContainer().appendChild(container);
  return container;
}

// 地图控件位置
MapAddControl.prototype.getDefaultPosition = function() {
  return new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(80, 50));
}

// 地图控件样式
MapAddControl.prototype.setButtonStyle_ = function(button) {
	button.className = "mapbutton";
}

function PointAddControl() {
}
PointAddControl.prototype = new GControl();
PointAddControl.prototype.initialize = function(map) {
  var container = document.createElement("div");

  this.setButtonStyle_(UI.spans.addPoint);
  container.appendChild(UI.spans.addPoint);

  GEvent.addDomListener(UI.spans.addPoint, "click", function() {
	UI.showDiv("info_box_b");
	UI.getContent("info_box_b", "/ajax/addpoint", "backUrl=" + encodeURI(window.location), LOADING);
	//window.location = "http://" + window.location.hostname + '/addpoint?lat='+UI.map.getCenter().lat()+'&lng='+UI.map.getCenter().lng() + '&zoom='+UI.map.getZoom();
  });
  UI.map.getContainer().appendChild(container);
  return container;
}

// 地图控件位置
PointAddControl.prototype.getDefaultPosition = function() {
  return new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(80, 20));
}

// 地图控件样式
PointAddControl.prototype.setButtonStyle_ = function(button) {
	button.className = "mapbutton";
	button.style.backgroundColor = "#990000";
}
