var LabeledMarker,Tooltip,MoreControl,LayerControl,toggleLayer;
(function(){
if(!window.GMarker||!window.GOverlay||!window.GControl){
setTimeout(arguments.callee,10);
return;
}
LabeledMarker=function(_1,_2){
this.latlng_=_1;
this.opts_=_2;
this.labelText_=_2.labelText||"";
this.labelClass_=_2.labelClass||"LabeledMarker_markerLabel";
this.labelOffset_=_2.labelOffset||new GSize(0,0);
this.clickable_=_2.clickable||true;
this.title_=_2.title||"";
this.labelVisibility_=true;
if(_2.draggable){
_2.draggable=false;
}
GMarker.apply(this,arguments);
};
LabeledMarker.prototype=new GMarker(new GLatLng(0,0));
LabeledMarker.prototype.initialize=function(_3){
GMarker.prototype.initialize.apply(this,arguments);
this.map_=_3;
this.div_=document.createElement("div");
this.div_.className=this.labelClass_;
this.div_.innerHTML=this.labelText_;
this.div_.style.position="absolute";
this.div_.style.paddingLeft="6px";
this.div_.style.paddingTop="2px";
this.div_.style.cursor="pointer";
this.div_.title=this.title_;
_3.getPane(G_MAP_MARKER_PANE).appendChild(this.div_);
if(this.clickable_){
function newEventPassthru(_4,_5){
return function(){
GEvent.trigger(_4,_5);
};
}
var _6=["click","dblclick","mousedown","mouseup","mouseover","mouseout"];
for(var i=0;i<_6.length;i++){
var _8=_6[i];
GEvent.addDomListener(this.div_,_8,newEventPassthru(this,_8));
}
}
};
LabeledMarker.prototype.redraw=function(_9){
GMarker.prototype.redraw.apply(this,arguments);
this.redrawLabel_();
};
LabeledMarker.prototype.redrawLabel_=function(){
var p=this.map_.fromLatLngToDivPixel(this.latlng_);
var z=GOverlay.getZIndex(this.latlng_.lat());
this.div_.style.left=(p.x+this.labelOffset_.width)+"px";
this.div_.style.top=(p.y+this.labelOffset_.height)+"px";
this.div_.style.zIndex=z;
};
LabeledMarker.prototype.remove=function(){
GEvent.clearInstanceListeners(this.div_);
if(this.div_.outerHTML){
this.div_.outerHTML="";
}
if(this.div_.parentNode){
this.div_.parentNode.removeChild(this.div_);
}
this.div_=null;
GMarker.prototype.remove.apply(this,arguments);
};
LabeledMarker.prototype.copy=function(){
return new LabeledMarker(this.latlng_,this.opts_);
};
LabeledMarker.prototype.show=function(){
GMarker.prototype.show.apply(this,arguments);
if(this.labelVisibility_){
this.showLabel();
}else{
this.hideLabel();
}
};
LabeledMarker.prototype.hide=function(){
GMarker.prototype.hide.apply(this,arguments);
this.hideLabel();
};
LabeledMarker.prototype.setLatLng=function(_c){
this.latlng_=_c;
GMarker.prototype.setLatLng.apply(this,arguments);
this.redrawLabel_();
};
LabeledMarker.prototype.setLabelVisibility=function(_d){
this.labelVisibility_=_d;
if(!this.isHidden()){
if(this.labelVisibility_){
this.showLabel();
}else{
this.hideLabel();
}
}
};
LabeledMarker.prototype.getLabelVisibility=function(){
return this.labelVisibility_;
};
LabeledMarker.prototype.hideLabel=function(){
this.div_.style.visibility="hidden";
};
LabeledMarker.prototype.showLabel=function(){
this.div_.style.visibility="visible";
};
Tooltip=function(_e,_f,_10){
this.marker_=_e;
this.node_=_f;
this.padding_=_10;
};
Tooltip.prototype=new GOverlay();
Tooltip.prototype.initialize=function(map){
var div=document.createElement("div");
div.innerHTML=this.node_;
div.className="tooltip";
div.style.position="absolute";
div.style.visibility="hidden";
div.style.whiteSpace="nowrap";
map.getPane(G_MAP_FLOAT_PANE).appendChild(div);
this.map_=map;
this.div_=div;
};
Tooltip.prototype.remove=function(){
this.div_.parentNode.removeChild(this.div_);
};
Tooltip.prototype.copy=function(){
return new Tooltip(this.marker_,this.node_,this.padding_);
};
Tooltip.prototype.redraw=function(_13){
if(!_13){
return;
}
var _14=this.map_.fromLatLngToDivPixel(this.marker_.getPoint());
var _15=this.marker_.getIcon().iconAnchor;
var _16=Math.round(_14.x-this.div_.clientWidth/2);
var _17=_14.y-_15.y-this.div_.clientHeight-this.padding_;
this.div_.style.top=_17+"px";
this.div_.style.left=_16+"px";
};
Tooltip.prototype.show=function(){
this.div_.style.visibility="visible";
};
Tooltip.prototype.hide=function(){
this.div_.style.visibility="hidden";
};
var _18=[];
_18[0]=new GLayer("com.panoramio.all");
_18[0].Visible=false;
_18[0].Added=false;
_18[1]=new GLayer("org.wikipedia.en");
_18[1].Visible=false;
_18[1].Added=false;
var _19=null;
MoreControl=function(){
};
MoreControl.prototype=new GControl();
var _1a=null;
var _1b=false;
MoreControl.prototype.initialize=function(map){
var _1d=new Element("div",{"id":"layers_button","title":"Show layers menu"});
_1d.innerHTML="More...";
map.getContainer().appendChild(_1d);
_19=new LayerControl(["Photos","Wikipedia"]);
_1a=map;
GEvent.addDomListener(_1d,"click",function(){
if(!_1b){
map.addControl(_19);
for(var chk=0;chk<_18.length;chk++){
if(_18[chk].Visible){
$("menuchk-"+chk).setAttribute("checked",true);
}
}
_1b=true;
}
});
GEvent.addDomListener(map,"click",function(){
map.removeControl(_19);
_1b=false;
});
return _1d;
};
MoreControl.prototype.getDefaultPosition=function(){
return new GControlPosition(G_ANCHOR_TOP_RIGHT,new GSize(100,7));
};
LayerControl=function(_1f){
this.opts=_1f;
};
LayerControl.prototype=new GControl();
LayerControl.prototype.initialize=function(map){
var _21=new Element("div",{"id":"layers_menu"});
var _22=new Element("div",{"id":"layers_header"}).update(new Element("div",{"id":"menu_header","title":"Hide layers menu"}).update("More..."));
var _23=new Element("div",{"id":"layers_trans_area"}).update("&nbsp;");
_21.appendChild(_23);
_21.appendChild(_22);
var _24=new Element("div",{"id":"layers_options"});
var _25=0;
for(var i=0;i<this.opts.length;i++){
var _27=new Element("label",{"id":"menulbl-"+i,"name":this.opts[i].toLowerCase(),"title":(_18[i].Visible?"Remove ":"Add ")+this.opts[i].toLowerCase()+" layer"});
var _28=new Element("input",{"id":"menuchk-"+i,"type":"checkbox","onclick":"javascript:toggleLayer("+i+")"});
_27.appendChild(_28);
_27.innerHTML+=this.opts[i];
_24.appendChild(new Element("div").update(_27));
if(_18[i].Visible){
_25++;
}
}
_21.appendChild(_24);
var _29=new Element("div",{"id":"hide_layers_div"});
var _2a=new Element("div").update(new Element("a",{"id":"hideLayers","href":"javascript:toggleLayer(-1)"}).update("Hide all"));
_29.appendChild(_2a);
_21.appendChild(_29);
map.getContainer().appendChild(_21);
GEvent.addDomListener(_22,"click",function(){
setTimeout(function(){
_1a.removeControl(_19);
_1b=false;
},100);
});
if(_25){
$("menu_header").innerHTML="<b>More... ("+_25+")</b>";
$("hideLayers").removeClassName("inactive");
$("hideLayers").setAttribute("title","Hide all the layers");
}else{
$("menu_header").innerHTML="More...";
$("hideLayers").addClassName("inactive");
$("hideLayers").setAttribute("title","No layers added");
}
return _21;
};
LayerControl.prototype.getDefaultPosition=function(){
return new GControlPosition(G_ANCHOR_TOP_RIGHT,new GSize(72,7));
};
toggleLayer=function(i){
if(i===-1){
var _2c=0;
for(var _2d=0;_2d<_18.length;_2d++){
if(_18[_2d].Visible){
_2c++;
_18[_2d].hide();
_18[_2d].Visible=false;
$("menuchk-"+_2d).setAttribute("checked",false);
}
}
if(_2c){
$("menu_header").innerHTML="More...";
$("layers_button").innerHTML="More...";
$("hideLayers").addClassName("inactive");
$("hideLayers").setAttribute("title","No layers added");
setTimeout(function(){
_1a.removeControl(_19);
_1b=false;
},250);
}
return;
}
if(_18[i].Visible){
_18[i].hide();
}else{
if(_18[i].Added){
_18[i].show();
}else{
_1a.addOverlay(_18[i]);
_18[i].Added=true;
}
}
_18[i].Visible=!_18[i].Visible;
var _2e=0;
for(var itr=0;itr<_18.length;itr++){
if(_18[itr].Visible){
_2e++;
}
$("menulbl-"+itr).setAttribute("title",(_18[itr].Visible?"Remove ":"Add ")+$("menulbl-"+itr).readAttribute("name")+" layer");
}
if(_2e){
$("menu_header").innerHTML="<b>More... ("+_2e+")</b>";
$("layers_button").innerHTML="<b>More... ("+_2e+")</b>";
$("hideLayers").removeClassName("inactive");
$("hideLayers").setAttribute("title","Hide all the layers");
}else{
$("menu_header").innerHTML="More...";
$("layers_button").innerHTML="More...";
$("hideLayers").addClassName("inactive");
$("hideLayers").setAttribute("title","No layers added");
}
};
})();
