var mapCreater = function(config){
	this.config = {
		mapAreaObject:null,//htmlDomObject
		zoomLevel:10,
		width:100,
		height:100
	};
	this.config = config;
	this.config.mapAreaObject.style.width = this.config.width;
	this.config.mapAreaObject.style.height = this.config.height;
	this.markerConfigs = [];
	this.mapCom = new GMap2(this.config.mapAreaObject);
};
//アイコンを設置
mapCreater.prototype.setMarker = function(markerConfig){
	this.markerConfigs.push(markerConfig);
};
//コントローラーを埋め込み
mapCreater.prototype.addControl = function (mapAddControlObject){
	this.mapCom.addControl(mapAddControlObject);
};
/**
 * アイコンオブジェクト生成
 * iconConfBn = {
 * markerObjectName : 'marker_ms_nn_nn',
 * 	lng:139.708588,
 * lat:35.732677,
 * iconImage:'http:.....',
 * iconSize:{w:40,h:50},
 * iconAnchor:GPointObject,
 * infoWindowAnchor:GPointObject,
 * setClickEvent:function,
 * setMonseoverEvent:function
 * }
 */
mapCreater.prototype.createMarker = function(markerConfBn){
	var point = new GPoint(markerConfBn.lng , markerConfBn.lat);
	var icon = new GIcon();
	icon.image = markerConfBn.iconImage;
	icon.iconSize = new GSize(markerConfBn.iconSize.w,markerConfBn.iconSize.h);
	if(markerConfBn.iconAnchor == undefined){
		icon.iconAnchor = new GPoint(0,0);
	}else{
		icon.iconAnchor = markerConfBn.iconAnchor;
	}
	if(markerConfBn.infoWindowAnchor == undefined){
		icon.infoWindowAnchor = new GPoint(18,18);
	}else{
		icon.infoWindowAnchor = markerConfBn.infoWindowAnchor;
	}
	mapMarkerContenner[markerConfBn.markerObjectName] = new GMarker(point , {icon:icon});
	if(markerConfBn.setClickEvent != undefined){
		GEvent.addListener(mapMarkerContenner[markerConfBn.markerObjectName] , 'click' , markerConfBn.setClickEvent);
	}
	if(markerConfBn.setMonseoverEvent != undefined){
		GEvent.addListener(mapMarkerContenner[markerConfBn.markerObjectName] , 'mouseover' , markerConfBn.setMonseoverEvent);
	}
	this.mapCom.addOverlay(mapMarkerContenner[markerConfBn.markerObjectName]);
};
mapCreater.prototype.createMap = function(){
	//地図生成
	var lat = 0;
	var lng = 0;
	for(var i=0; i<this.markerConfigs.length; i++){
		this.createMarker(this.markerConfigs[i]);
		lat = lat + this.markerConfigs[i].lat;
		lng = lng + this.markerConfigs[i].lng;
	}
	//中央
	lat = lat / this.markerConfigs.length;
	lng = lng / this.markerConfigs.length;
	this.mapCom.setCenter(new GLatLng(lat,lng), this.config.zoomLevel);
}
