LDMapMarkerCtl.Bounds=function(mm){this.mm=mm;this.markers=[];this.reqState=0;this.init();};LDMapMarkerCtl.Bounds.prototype=$.extend({},LDMapBase.prototype,{config:{maxSummaryCount:20},domEl:{summary:$("#markerSummary > .summary")},init:function(){this.summaryPane=this.domEl.summary;},isSelectedTab:function(){return/^bounds$/.test(this.getUrlParam("tab"))?true:false;},closeInfoWindow:function(){this.mm.closeInfoWindow();},setMarkers:function(category){var self=this;if(this.reqState)return;var mm=this.mm;var mObj=/^ldgourmet$/.test(category)?new LDMapMarkerCtl.Bounds.Gourmet(mm):/^fon$/.test(category)?new LDMapMarkerCtl.Bounds.Fon(mm):/^travel_hotel$/.test(category)?new LDMapMarkerCtl.Bounds.TravelHotel(mm):/^trackback$/.test(category)?new LDMapMarkerCtl.Bounds.Trackback(mm):/^event$/.test(category)?new LDMapMarkerCtl.Bounds.Event(mm):new LDMapMarkerCtl.Bounds.Landmark(mm,category);if(mObj.minZoomLevel()&&mm.getZoomLevel()<mObj.minZoomLevel){this.removeMarkers();return;}var reqUrl=mObj.getReqUrl();this.reqState=1;this.summaryReady();$.getJSON(reqUrl,function(data){if(!data.entries){self.reqState=0;self.summaryFail();return;}var newMarkers=[];var il=data.entries.length;for(var i=0;i<il;i++){var marker=mObj.genMarker(data.entries[i],category);marker.create();newMarkers.push(marker);}self.callee().selectTrigger(category);self.removeMarkers();self.showMarkers(newMarkers);self.updateSummary();self.reqState=0;});},removeMarkers:function(){var mm=this.mm;var markers=this.markers;var len=markers.length;for(var i=0;i<len;i++){var m=markers.pop();m.removeListener();mm.removeOverlay(m.get());m.destroy();m=null;}this.markers=[];this.summaryPane.empty();},showMarkers:function(newMarkers){var mm=this.mm;var markers=this.markers;var mCount=newMarkers.length;for(var i=0;i<mCount;i++){var m=newMarkers.shift();markers.push(m);mm.addOverlay(m.get());}},callee:function(parent){if(parent)this.parent=parent;return this.parent;},summaryReady:function(){this.summaryPane.empty();this.summaryPane.html("<p>検索しています...</p>");},summaryFail:function(){var pane=this.summaryPane;pane.empty();pane.hide();pane.html("<p>この付近に該当する情報はありません</p>");pane.slideDown();},updateSummary:function(){var self=this;var len=this.markers.length;var max=this.config.maxSummaryCount;if(!len)this.summaryFail();else{var pane=this.summaryPane;pane.hide();pane.empty();var markers=this.markers;var ul=$(document.createElement("ul"));for(var i=0;i<len&&i<max;i++){var el=markers[i].summarized();ul.append(el);}pane.append(ul);pane.slideDown();}},destroy:function(){this.closeInfoWindow();this.removeMarkers();}});LDMapMarkerCtl.Bounds.Base=function(){};LDMapMarkerCtl.Bounds.Base.prototype=$.extend({},LDMapBase.prototype,{config:{apiPath:"/api/bounds/"},init:function(){this.icon=this.genMIcon(this.iconProps());},iconProps:function(){return this.config.iconProps;},iconImage:function(){return this.config.iconProps.image;},minZoomLevel:function(){return 0;}});LDMapMarkerCtl.Bounds.Gourmet=function(mm){this.mm=mm;this.init();};LDMapMarkerCtl.Bounds.Gourmet.prototype=$.extend(true,{},LDMapMarkerCtl.Bounds.Base.prototype,{config:{iconProps:{image:"/img/map/icons/gourmet.gif",width:21,height:20,aLng:10,aLat:10}},genMarker:function(item){return new LDMapMarkerCtl.Bounds.Gourmet.Marker(this.mm,this.icon,item);},getReqUrl:function(){var params=this.getCoordParams({center:1,bounds:1,zoom:1});params.push("type=gourmet");return[this.getUrl(this.config.apiPath),params.join("&")].join("?");}});LDMapMarkerCtl.Bounds.Landmark=function(mm,type){this.mm=mm,this.type=type;this.init();};LDMapMarkerCtl.Bounds.Landmark.prototype=$.extend(true,{},LDMapMarkerCtl.Bounds.Base.prototype,{config:{iconProps:{width:21,height:20,aLng:10,aLat:10},image:{sightseeing:"/img/map/icons/spa.gif",leisure:"/img/map/icons/leisure.gif",station:"/img/map/icons/station.gif",transportation:"/img/map/icons/car.gif",government:"/img/map/icons/police.gif",others:"/img/map/icons/government.gif",school:"/img/map/icons/school.gif",nature:"/img/map/icons/park.gif",hospital:"/img/map/icons/hospital.gif",life:"/img/map/icons/government.gif",other:"/img/map/icons/gourmet.gif"}},iconProps:function(){var props=this.config.iconProps;props.image=this.iconImage();return props;},iconImage:function(){var image=this.config.image;return image[this.type]?image[this.type]:image.other;},genMarker:function(item){return new LDMapMarkerCtl.Bounds.Landmark.Marker(this.mm,this.icon,item);},getReqUrl:function(){var params=this.getCoordParams({center:1,bounds:1,zoom:1});params.push("type=landmark");params.push(["category",this.type].join("="));return[this.getUrl(this.config.apiPath),params.join("&")].join("?");}});LDMapMarkerCtl.Bounds.Fon=function(mm){this.mm=mm;this.init();};LDMapMarkerCtl.Bounds.Fon.prototype=$.extend(true,{},LDMapMarkerCtl.Bounds.Base.prototype,{config:{minZoomLevel:7,iconProps:{image:"/img/map/icons/fon.gif",width:21,height:20,aLng:10,aLat:10}},minZoomLevel:function(){return this.config.minZoomLevel;},genMarker:function(item){return new LDMapMarkerCtl.Bounds.Fon.Marker(this.mm,this.icon,item);},getReqUrl:function(){var params=this.getCoordParams({center:1,bounds:1,zoom:1});params.push("type=fon");return[this.getUrl(this.config.apiPath),params.join("&")].join("?");}});LDMapMarkerCtl.Bounds.TravelHotel=function(mm){this.mm=mm;this.init();};LDMapMarkerCtl.Bounds.TravelHotel.prototype=$.extend(true,{},LDMapMarkerCtl.Bounds.Base.prototype,{config:{iconProps:{image:"/img/map/icons/hotel.gif",width:21,height:20,aLng:10,aLat:10}},genMarker:function(item){return new LDMapMarkerCtl.Bounds.TravelHotel.Marker(this.mm,this.icon,item);},getReqUrl:function(){var params=this.getCoordParams({center:1,bounds:1,zoom:1});params.push("type=travel_hotel");return[this.getUrl(this.config.apiPath),params.join("&")].join("?");}});LDMapMarkerCtl.Bounds.Trackback=function(mm){this.mm=mm;this.init();};LDMapMarkerCtl.Bounds.Trackback.prototype=$.extend(true,{},LDMapMarkerCtl.Bounds.Base.prototype,{config:{iconProps:{image:"/img/map/icons/trackback.gif",width:21,height:20,aLng:10,aLat:10}},genMarker:function(item){return new LDMapMarkerCtl.Bounds.Trackback.Marker(this.mm,this.icon,item);},getReqUrl:function(){var params=this.getCoordParams({center:1,bounds:1,zoom:1});params.push("type=trackback");return[this.getUrl(this.config.apiPath),params.join("&")].join("?");}});LDMapMarkerCtl.Bounds.Event=function(mm){this.mm=mm;this.init();};LDMapMarkerCtl.Bounds.Event.prototype=$.extend(true,{},LDMapMarkerCtl.Bounds.Base.prototype,{config:{iconProps:{image:"/img/map/icons/hanabi.gif",width:21,height:20,aLng:10,aLat:10}},genMarker:function(item){return new LDMapMarkerCtl.Bounds.Event.Marker(this.mm,this.icon,item);},getReqUrl:function(){var params=this.getCoordParams({center:1,bounds:1,zoom:1});params.push("type=event");return[this.getUrl(this.config.apiPath),params.join("&")].join("?");}});LDMapMarkerCtl.Bounds.MarkerBase=function(){};LDMapMarkerCtl.Bounds.MarkerBase.prototype=$.extend({},LDMapBase.prototype,{domEl:{popTmpl:$("#map-parts-landmark-pop")},create:function(){var item=this.item;this.marker=new MMarker(new MPoint(item.lng,item.lat),this.icon);this.addListener();},addListener:function(){var self=this;this.clickEvent=MEvent.addListener(this.marker,"click",function(){self.popInfo();});},removeListener:function(){MEvent.removeListener(this.clickEvent);},get:function(){return this.marker;},callTo:function(str){return['callto://+81',str.replace(/^0/,"").replace(/\-/g,"")].join("");},summarized:function(){var self=this;var aEl=$(document.createElement("a"));aEl.attr("href","javascript:void(0);").html(this.itemName());aEl.bind("click",function(){self.mm.recenterOrPanToLatLng(new MPoint(self.item.lng,self.item.lat));setTimeout(function(){self.popInfo();},700);});return $(document.createElement("li")).append(aEl).append(this.itemCategory());},itemName:function(){return this.item.name;},itemCategory:function(){return this.item.category;},refresh:function(){var mm=this.mm;setTimeout(refresh,30);function refresh(){mm.infowindow.draw();}},destroy:function(){MEvent.removeListener(this.marker);this.marker=null;this.icon=null;this.item=null;},genSearchLink:function(word){return['<a href="http://search.livedoor.com/search/?lr=lang_ja&c=ld_map_sl&ie=utf8&q=',encodeURIComponent(word),'" target="_blank">',word,'</a>でウェブ検索する'].join("");}});LDMapMarkerCtl.Bounds.Gourmet.Marker=function(mm,icon,item){this.mm=mm;this.icon=icon;this.item=item;this.marker=null;};LDMapMarkerCtl.Bounds.Gourmet.Marker.prototype=$.extend({},LDMapMarkerCtl.Bounds.MarkerBase.prototype,{popInfo:function(){var item=this.item;var pop=this.domEl.popTmpl.children().clone();pop.children(".category").html(item.category);pop.children(".name").html(['<a href="',item.url,'" target="_blank">',item.name,'</a>'].join(""));pop.children(".address").html(item.address);pop.children(".tel").html(['<a href="',this.callTo(item.tel),'">',item.tel,'</a>'].join(""));if(item.img_url)pop.children(".image").html(['<img height="75" src="',item.img_url,'" />'].join(""));this.get().openInfoWindowHtml($(document.createElement("div")).attr("class","infoWindow").append(pop).html());}});LDMapMarkerCtl.Bounds.Landmark.Marker=function(){this.mm=arguments[0];this.icon=arguments[1];this.item=arguments[2];this.marker=null;};LDMapMarkerCtl.Bounds.Landmark.Marker.prototype=$.extend({},LDMapMarkerCtl.Bounds.MarkerBase.prototype,{popInfo:function(){var item=this.item;var pop=this.domEl.popTmpl.children().clone();pop.children(".category").html(item.category);pop.children(".name").html(item.name);pop.children(".misc").html(this.genSearchLink(item.name));this.get().openInfoWindowHtml(pop.html());}});LDMapMarkerCtl.Bounds.Fon.Marker=function(){this.mm=arguments[0];this.icon=arguments[1];this.item=arguments[2];this.marker=null;};LDMapMarkerCtl.Bounds.Fon.Marker.prototype=$.extend({},LDMapMarkerCtl.Bounds.MarkerBase.prototype,{popInfo:function(){var item=this.item;var pop=this.domEl.popTmpl.children().clone();pop.children(".name").html(item.name);this.get().openInfoWindowHtml(pop.html());}});LDMapMarkerCtl.Bounds.TravelHotel.Marker=function(){this.mm=arguments[0];this.icon=arguments[1];this.item=arguments[2];this.marker=null;};LDMapMarkerCtl.Bounds.TravelHotel.Marker.prototype=$.extend({},LDMapMarkerCtl.Bounds.MarkerBase.prototype,{popInfo:function(){var item=this.item;var pop=this.domEl.popTmpl.children().clone();pop.children(".name").html(['<a href="',item.link,'" target="_blank">',item.name,'</a>'].join(""));pop.children(".address").html(item.address);this.get().openInfoWindowHtml(pop.html());}});LDMapMarkerCtl.Bounds.Trackback.Marker=function(){this.mm=arguments[0];this.icon=arguments[1];this.item=arguments[2];this.marker=null;};LDMapMarkerCtl.Bounds.Trackback.Marker.prototype=$.extend({},LDMapMarkerCtl.Bounds.MarkerBase.prototype,{popInfo:function(){var item=this.item;var pop=this.domEl.popTmpl.children().clone();pop.children(".name").html(['<a href="',item.url,'" target="_blank">',item.title,'</a>'].join(""));pop.children(".address").html(item.blog_name);pop.children(".misc").html(item.excerpt);this.get().openInfoWindowHtml(pop.html());},itemName:function(){return this.item.title;},itemCategory:function(){return"";}});LDMapMarkerCtl.Bounds.Event.Marker=function(){this.mm=arguments[0];this.icon=arguments[1];this.item=arguments[2];this.marker=null;};LDMapMarkerCtl.Bounds.Event.Marker.prototype=$.extend({},LDMapMarkerCtl.Bounds.MarkerBase.prototype,{popInfo:function(){var item=this.item;var pop=this.domEl.popTmpl.children().clone();pop.children(".name").html(['<a href="',item.url,'" target="_blank">',item.name,'</a>'].join(""));pop.children(".address").html(item.address);this.get().openInfoWindowHtml(pop.html());},itemCategory:function(){return"";}});