var map = null;
var geocoder = null;
function loadMap() {
  if(GBrowserIsCompatible()) {
	  map = new GMap2(document.getElementById("topMap"),{"size":new GSize(312,296)});
		map.setCenter(new GLatLng(37.50, 136.50), 4);
		GDownloadUrl("/semi/data/top.dat", loadTopMaker);
  }
}
function loadTopMaker(jsondata, statusCode) {
	var json = eval("(" + jsondata + ")");
	for (var i = 0; i < json.top.length; i++) {
		var semi = json.top[i].semi;
		var lat = json.top[i].lat;
		var lon = json.top[i].lon;
		var marker = descTopMarker(semi, lat, lon);
		map.addOverlay(marker);
  }
}
function descTopMarker(semi, lat, lon){
	var gmarkeroptions = new Object();
	gmarkeroptions.icon = new GIcon();

	if ( semi == "ニイニイゼミ" ) //BLUE
		gmarkeroptions.icon.image = "../images/gicons/semi_blue8.png";
	else if ( semi == "アブラゼミ" ) //RED
		gmarkeroptions.icon.image = "../images/gicons/semi_red8.png";
	else if ( semi == "クマゼミ" ) //ORANGE
		gmarkeroptions.icon.image = "../images/gicons/semi_orange8.png";
	else if ( semi == "ツクツクボウシ" ) //YELLOW
		gmarkeroptions.icon.image = "../images/gicons/semi_yellow8.png";
	else if ( semi == "ミンミンゼミ" ) //GREEN
		gmarkeroptions.icon.image = "../images/gicons/semi_green8.png";
	else 
		gmarkeroptions.icon.image = "../images/gicons/semi_gray8.png"; //ヒグラシ GRAY

	gmarkeroptions.draggable = false;
	gmarkeroptions.icon.iconSize = new GSize(15, 20);
	gmarkeroptions.icon.iconAnchor = new GPoint(0, 20);
	gmarkeroptions.icon.infoWindowAnchor = new GPoint(10,10);
	var mark = new GMarker(new GLatLng(lat, lon), gmarkeroptions);
	GEvent.addListener(mark, "click", function(){
		mark.openInfoWindowHtml(message);
	});
	return mark;
}

