ACMS.Dispatch.Edit.yolp=function(item){var $img=$(".js-map_editable-container",item).add(".column-map",item);var $lat=$(".js-map_editable-lat",item).add(':input[name^="yolp_lat_"]',item);var $lng=$(".js-map_editable-lng",item).add(':input[name^="yolp_lng_"]',item);var $zoom=$(".js-map_editable-zoom",item).add(':input[name^="yolp_zoom_"]',item);var $layer=$(".js-map_editable-layer",item).add(':input[name^="yolp_layer_"]',item);if(!$img.size()||!$img.is("img"))return false;if(!$lat.size()||!$lat.is(":input"))return false;
if(!$lng.size()||!$lng.is(":input"))return false;var query=ACMS.Library.parseQuery($img.attr("src").replace(/^[^?]*\?/,""));var latlng=new Array(query.lat,query.lon);var zoom=parseInt(query.z,11);if($zoom.size()&&$zoom.val().length)zoom=parseInt($zoom.val(),10);var activate=function(){var $div=$('<div style="overflow:hidden;"></div>');$div.css("width",$img.width()+"px");$div.css("height",$img.height()+"px");$img.replaceWith($div);function getCenter(){return new Y.LatLng($lat.val(),$lng.val())}function latLngOnChange(){YMap.panTo(getCenter(),
true)}function setLayer(ly){var layerSet=ly;switch(ly){case "map":layerSet=YMap.setLayerSet(Y.LayerSetId.NORMAL);break;case "photo":layerSet=YMap.setLayerSet(Y.LayerSetId.PHOTO);break;case "map-b1":layerSet=YMap.setLayerSet(Y.LayerSetId.B1);break;case "railway":layerSet="MyRailwaySet";break;case "monotone":layerSet="MyMonotoneSet";break;case "bold":layerSet="MyBoldSet";break;case "midnight":layerSet="MyRMidnightSet";break;default:YMap.setLayerSet(Y.LayerSetId.NORMAL);break}YMap.setLayerSet(layerSet)}
var center=getCenter();var YMap=new Y.Map($div.get(0),{configure:{doubleClickZoom:true,continuousZoom:true}});var railwayLayer=new Y.StyleMapLayer("railway");var monotoneLayer=new Y.StyleMapLayer("monotone");var boldLayer=new Y.StyleMapLayer("bold");var midnightLayer=new Y.StyleMapLayer("midnight");var railwaySet=new Y.LayerSet("\u8def\u7dda\u56f3",[railwayLayer]);YMap.addLayerSet("MyRailwaySet",railwaySet);var monotoneSet=new Y.LayerSet("\u30e2\u30ce\u30c8\u30fc\u30f3",[monotoneLayer]);YMap.addLayerSet("MyMonotoneSet",
monotoneSet);var boldSet=new Y.LayerSet("\u30dc\u30fc\u30eb\u30c9",[boldLayer]);YMap.addLayerSet("MyBoldSet",boldSet);var midnightSet=new Y.LayerSet("\u30df\u30c3\u30c9\u30ca\u30a4\u30c8",[midnightLayer]);YMap.addLayerSet("MyRMidnightSet",midnightSet);YMap.addControl(new Y.CenterMarkControl);YMap.addControl(new Y.ScaleControl);YMap.addControl(new Y.SliderZoomControlVertical);YMap.addControl(new Y.SearchControl);$lat.change(latLngOnChange);$lng.change(latLngOnChange);YMap.bind("moveend",function(){var _latlng=
YMap.getCenter();$lat.val(_latlng.Lat);$lng.val(_latlng.Lon)});if($zoom.size()){YMap.bind("zoomend",function(){$zoom.val(YMap.getZoom())});$zoom.change(function(){var zl=$(this).val();YMap.setZoom(parseInt(zl),true)})}YMap.drawMap(center,zoom,Y.LayerSetId.NORMAL);if($layer.size()){setLayer($layer.val());YMap.bind("layersetchanged",function(){$zoom.val(YMap.getZoom())});$layer.change(function(){setLayer($(this).val())})}};if($lat.val().length&&$lng.val().length)activate();else $img.click(function(){if(!$lat.val().length)$lat.val(latlng[0]);
if(!$lng.val().length)$lng.val(latlng[1]);if($zoom.size())$zoom.val(zoom);activate()})};
