LMI.Mapping.WDDetailsPoi=(function(){var _E=LMI.Element,$each=LMI.Lang.forEach,$D=YAHOO.util.Dom;function WDDetailsPoi(listing){this.init(listing);}
YAHOO.lang.extend(WDDetailsPoi,LMI.Mapping.DSIcon,{ICON_BLANK:'img/pixel_trans.gif',ICON_NORMAL:'img/mapping/map_node_red_star.png',ICON_DOT:'img/map_nodes/circles/dot.png',RADII:{STREET:200,CITY:500,REGION:750},getRadius:function(){return this.RADII[this.precision]||0;},metersToPixels:function(m){var mpp=this.map.tileManager.getScale();return m/mpp;},showCircle:function(radius){var pxRadius=this.metersToPixels(radius),numDots=Math.max(Math.ceil(2*Math.PI*pxRadius/10),4),angle=2*Math.PI/numDots,el=this.element,that=this,x,y;if(!this.dots){this.dots=[];}
while(this.dots.length>numDots){_E.destroy(this.dots.pop());}
while(this.dots.length<numDots){this.dots.push(_E.create('img',this.element.parentNode,{src:LMI.Urls.get(this.ICON_DOT)}));}
$each(this.dots,function(dot,i){x=pxRadius*Math.cos(i*angle);y=pxRadius*Math.sin(i*angle);$D.setStyle(dot,'display','');$D.setStyle(dot,'position','absolute');$D.setStyle(dot,'z-index',el.style.zIndex);$D.setStyle(dot,'left',el.offsetLeft+that.getXOffset()+x+'px');$D.setStyle(dot,'top',el.offsetTop+that.getYOffset()+y+'px');});},hideCircle:function(){if(this.dots){$each(this.dots,function(dot){$D.setStyle(dot,'display','none');});}},getRecommendedIconSrc:function(){return this.ICON_BLANK;},update:function(map){if(this.shownOnMap&&map.getCenterPoint()&&map.zoomLevel!==this.previousMapZoom){this.previousMapZoom=map.zoomLevel;var radius=this.getRadius(),icon,img=this.element;if(radius>0){icon=this.ICON_BLANK;this.showCircle(radius);}else{icon=this.ICON_NORMAL;this.hideCircle();}
img.style.width=img.style.height='auto';_E.setImageSrc(img,icon);}
WDDetailsPoi.superclass.update.apply(this,arguments);},init:function(listing){WDDetailsPoi.superclass.init.call(this,listing);this.precision=listing.geocodePrecision;this.previousMapZoom=-1;}});return WDDetailsPoi;})();
