/*
MIT License
Last modified: 2015-10-05 18:08:49+0800
*/
window.gMapsCallback=function(){$(window).trigger("gMapsCallback")};
(function(f,w,n,z){function p(a,c){var b={lat:"",lng:""},d=[],e=/^[+-]?\d+(\.\d+)?$/;if("string"===typeof a||Array.isArray(a))if(d=Array.isArray(a)?a:a.toString().replace(/\s+/,"").split(","),2===d.length)e.test(d[0])&&e.test(d[1])&&(b.lat=d[0],b.lng=d[1]);else return a;else if("object"===typeof a){if("function"===typeof a.lat)return a;a.hasOwnProperty("x")&&a.hasOwnProperty("y")?(b.lat=a.x,b.lng=a.y):a.hasOwnProperty("lat")&&a.hasOwnProperty("lng")&&(b.lat=a.lat,b.lng=a.lng)}return!0===c?new google.maps.LatLng(b.lat,
b.lng):b}function x(a){var c=a.hasOwnProperty("css")?a.css.toString():"";this.setValues(a);this.span=f("").css({position:"relative",left:"-50%",top:"0","white-space":"nowrap"}).addClass(c);this.div=f("
").css({position:"absolute",display:"none"});this.span.appendTo(this.div)}function A(a,c){var b=this,d=f.extend({},G,c);b.map=null;b._markers=[];b._markersCluster=[];b._clusters={};b._bounds={};b._labels=[];b._polylines=[];b._polygons=[];b._circles=[];b._kmls=[];b._directions=[];b._directionsMarkers=
[];b._places=[];b.container=a;b.options=d;b.googleMapOptions={};b.interval=parseInt(b.options.interval,10)||200;f(w).on("gMapsCallback",function(){b.init()});f(this.container).html(d.loading);b.init()}var C=!1,D=!1,E=!1,r={sensor:!1,language:"zh-TW",callback:"gMapsCallback",api:"https://maps.googleapis.com/maps/api/js",clusterer:"https://google-maps-utility-library-v3.googlecode.com/svn/trunk/markerclustererplus/src/markerclusterer_packed.js",withLabel:"https://google-maps-utility-library-v3.googlecode.com/svn/trunk/markerwithlabel/src/markerwithlabel_packed.js"},
G={autoLocation:!1,center:[24,121],infoWindowAutoClose:!0,interval:200,loading:"\u8b80\u53d6\u4e2d…",notFound:"\u627e\u4e0d\u5230\u67e5\u8a62\u7684\u5730\u9ede",zoom:8},B={},B={greyscale:[{featureType:"all",stylers:[{saturation:-100},{gamma:.5}]}]};A.prototype={VERSION:"3.3.0",formatSize:function(a){return Array.isArray(a)&&2===a.length?new google.maps.Size(a[0],a[1]):a},formatPoint:function(a){return Array.isArray(a)&&2===a.length?new google.maps.Point(a[0],a[1]):a},overlay:function(){var a=
this.map,c=this.options;try{this.adsense(a,c),this.kml(a,c),this.directionService(a,c),this.placeMarkers(a,c),this.drawPolyline(a,c),this.drawPolygon(a,c),this.drawCircle(a,c),this.streetView(a,c),this.places(a,c),this.geoLocation(a,c)}catch(b){console.error(b)}},bindEvents:function(a,c){var b=this,d={};switch(typeof c){case "function":google.maps.event.addListener(a,"click",c);break;case "object":for(d in c)"function"===typeof c[d]?"created"===d?c[d].call(a):google.maps.event.addListener(a,d,c[d]):
c[d].hasOwnProperty("func")&&"function"===typeof c[d].func?c[d].hasOwnProperty("once")&&!0===c[d].once?google.maps.event.addListenerOnce(a,d,c[d].func):google.maps.event.addListener(a,d,c[d].func):"function"===typeof c[d]&&google.maps.event.addListener(a,d,c[d])}a.hasOwnProperty("infoWindow")&&google.maps.event.addListener(a,"click",function(){var c=0,d={};if(b.options.hasOwnProperty("infoWindowAutoClose")&&!0===b.options.infoWindowAutoClose)for(c=0;cl&&d.push({location:k.getAt(l),stopover:!1});e&&h.hasOwnProperty("event")&&h.event.hasOwnProperty("created")&&"function"===typeof h.event.created&&
h.event.created.call(e,this);b.hasOwnProperty("event")&&this.bindEvents(e,b.event);b.hasOwnProperty("snap")&&!0===b.snap?(h=new google.maps.DirectionsService,h.route({origin:k.getAt(0),waypoints:d,destination:k.getAt(k.length-1),travelMode:google.maps.DirectionsTravelMode.DRIVING},y)):(e.setPath(k),google.maps.hasOwnProperty("geometry")&&google.maps.geometry.hasOwnProperty("spherical")&&"function"===typeof google.maps.geometry.spherical.computeDistanceBetween&&(g=google.maps.geometry.spherical.computeDistanceBetween(k.getAt(0),
k.getAt(k.length-1)),"function"===typeof b.getDistance&&b.getDistance.call(this,g)));e.setMap(a)}},drawPolygon:function(a,c){var b={},d={},b=[],e=0,d=0,g={},g={};if(c.hasOwnProperty("polygon")&&Array.isArray(c.polygon))for(e=0;e]+)>/g,""));f.isEmptyObject(q)||(l.icon=q);g.hasOwnProperty("animation")&&"string"===typeof g.animation&&(l.animation=google.maps.Animation[g.animation.toUpperCase()]);"string"===typeof h?(e=new google.maps.Geocoder,e.geocode({address:h},function(e,h){h===
google.maps.GeocoderStatus.OVER_QUERY_LIMIT?setTimeout(function(){d.placeMarkers(a,c,b)},d.interval):h===google.maps.GeocoderStatus.OK&&(!y&&t?("function"===typeof g.setPosition&&g.setPosition(e[0].geometry.location),v=g):(l.position=e[0].geometry.location,u=c.hasOwnProperty("markerWithLabel")&&!0===c.markerWithLabel?"function"===typeof MarkerWithLabel?new MarkerWithLabel(l):new google.maps.Marker(l):new google.maps.Marker(l),d._markers.push(u),v=u),d.processMarker(a,c,v,b))})):(!y&&t?("function"===
typeof g.setPosition&&g.setPosition(h),v=g):(l.position=h,u=c.hasOwnProperty("markerWithLabel")&&!0===c.markerWithLabel?"function"===typeof MarkerWithLabel?new MarkerWithLabel(l):new google.maps.Marker(l):new google.maps.Marker(l),d._markers.push(u),v=u),d.processMarker(a,c,v,b))})},directionService:function(a,c){var b=this,d=new google.maps.DirectionsService;Array.isArray(c.direction)&&c.direction.forEach(function(c){if("undefined"!==typeof c.from&&"undefined"!==typeof c.to){var g={},h=new google.maps.DirectionsRenderer,
k=f.extend({},{infoWindow:new google.maps.InfoWindow,map:b.map},c),m=[],q=[],l=[];g.origin=p(c.from,!0);g.destination=p(c.to,!0);g.travelMode=c.hasOwnProperty("travel")&&google.maps.TravelMode[c.travel.toString().toUpperCase()]?google.maps.TravelMode[c.travel.toString().toUpperCase()]:google.maps.TravelMode.DRIVING;c.hasOwnProperty("panel")&&f(c.panel).length&&(k.panel=f(c.panel).get(0));c.hasOwnProperty("requestExtra")&&c.requestExtra&&(g=f.extend({},g,c.requestExtra));c.hasOwnProperty("waypoint")&&
Array.isArray(c.waypoint)&&(c.waypoint.forEach(function(a){var b={stopover:!0};"string"===typeof a||Array.isArray(a)?b.location=p(a,!0):a.hasOwnProperty("location")&&(b.location=p(a.location,!0),b.stopover=a.hasOwnProperty("stopover")?a.stopover:!0);q.push(a.text||a.toString());a.hasOwnProperty("icon")&&l.push(a.icon.toString());m.push(b)}),g.waypoints=m);d.route(g,function(d,f){f===google.maps.DirectionsStatus.OK&&(d.routes.forEach(function(h,f){c.hasOwnProperty("renderAll")&&!0===c.renderAll&&!0===
g.provideRouteAlternatives&&new google.maps.DirectionsRenderer({map:a,directions:d,routeIndex:f});var m=h.legs,t="",p="",n={};c.hasOwnProperty("fromText")&&(t=m[0].start_address=c.fromText);c.hasOwnProperty("toText")&&(1===m.length?m[0].end_address=c.toText:m[m.length-1].end_address=c.toText,p=c.toText);c.hasOwnProperty("icon")&&(k.suppressMarkers=!0,c.icon.hasOwnProperty("from")&&"string"===typeof c.icon.from&&b.directionServiceMarker(m[0].start_location,{icon:c.icon.from,text:t},k.infoWindow,c),
c.icon.hasOwnProperty("to")&&"string"===typeof c.icon.to&&b.directionServiceMarker(m[m.length-1].end_location,{icon:c.icon.to,text:p},k.infoWindow,c));for(f=1;f #style1 #DATA# ".split(" "),
d=" #style1 1 1 clampedToGround #LATLNG# ".split(" "),e="",g="",h="",k="",m="";a="";this.get("marker,polyline,polygon,circle,direction",function(a){var f="";!0===c.marker&&"undefined"!==typeof a.marker&&a.marker.forEach(function(a){f=[a.getPosition().lng(),
a.getPosition().lat()].join();e+=b.join("").replace(/#NAME#/gi,"Markers").replace(/#DATA#/gi,"#LATLNG#,0.000000".replace(/#LATLNG#/gi,f))});!0===c.polyline&&"undefined"!==typeof a.polyline&&a.polyline.forEach(function(a){f="";a.getPath().getArray().forEach(function(a){f+=[a.lng(),a.lat(),"0.000000\n"].join()});g+=b.join("").replace(/#NAME#/gi,"Polylines").replace(/#DATA#/gi,"1#LATLNG#".replace(/#LATLNG#/gi,
f))});!0===c.polygon&&"undefined"!==typeof a.polygon&&a.polygon.forEach(function(a){f="";a.getPath().getArray().forEach(function(a){f+=[a.lng(),a.lat(),"0.000000\n"].join()});h+=d.join("").replace(/#NAME#/gi,"Polygons").replace(/#LATLNG#/gi,f)});!0===c.circle&&"undefined"!==typeof a.circle&&a.circle.forEach(function(a){f="";var b=Math.PI/180,c=180/Math.PI,c=a.getRadius()/6378137*c,b=c/Math.cos(a.getCenter().lat()*b);for(j=j=theta=0;65>j;j+=1)theta=j/32*Math.PI,ey=a.getCenter().lng()+b*Math.cos(theta),
ex=a.getCenter().lat()+c*Math.sin(theta),f+=[ey,ex,"0.000000\n"].join();k+=d.join("").replace(/#NAME#/gi,"Circles").replace(/#LATLNG#/gi,f)});!0===c.direction&&"undefined"!==typeof a.direction&&a.direction.forEach(function(a){a=a.getDirections();a.hasOwnProperty("routes")&&Array.isArray(a.routes)&&"undefined"!==typeof a.routes[0]&&"undefined"!==typeof a.routes[0].legs&&Array.isArray(a.routes[0].legs)&&a.routes[0].legs.forEach(function(a){Array.isArray(a.steps)&&a.steps.forEach(function(a){f="";Array.isArray(a.path)&&
a.path.forEach(function(a){f+=[a.lng(),a.lat(),"0.000000\n"].join()});m+=b.join("").replace(/#NAME#/gi,"Directions").replace(/#DATA#/gi,"1#LATLNG#".replace(/#LATLNG#/gi,f))})})})});a='#PLACEMARKS#'.replace(/#NAME#/gi,
"").replace(/#PLACEMARKS#/gi,e+g+h+k+m);if(!0===c.download)w.open("data:application/vnd.google-earth.kml+xml;charset=utf-8;base64,"+w.btoa(decodeURIComponent(encodeURIComponent(a))));else return a},init:function(){var a=this,c={},c={},b=f.extend({},r),d=b.api.split("?")[0],e="",g={};try{delete b.api,delete b.clusterer,delete b.withLabel,b=f.param(b)}catch(h){}C||"undefined"!==typeof w.google||(c=n.createElement("script"),c.setAttribute("src",[d,b].join("?")),(n.getElementsByTagName("head")[0]||n.documentElement).appendChild(c),
C=!0,c=null);if("object"===typeof w.google){!D&&a.options.hasOwnProperty("markerCluster")&&!1!==a.options.markerCluster&&"undefined"===typeof MarkerClusterer&&(c=n.createElement("script"),c.setAttribute("src",r.clusterer),(n.getElementsByTagName("head")[0]||n.documentElement).appendChild(c),D=!0,c=null);!E&&a.options.hasOwnProperty("markerWithLabel")&&!0===a.options.markerWithLabel&&"undefined"===typeof MarkerWithLabel&&(c=n.createElement("script"),c.setAttribute("src",r.withLabel),(n.getElementsByTagName("head")[0]||
n.documentElement).appendChild(c),E=!0,c=null);a._bounds=new google.maps.LatLngBounds;x.prototype=new google.maps.OverlayView;x.prototype.onAdd=function(){this.div.appendTo(f(this.getPanes().overlayLayer));this.listeners=[google.maps.event.addListener(this,"visible_changed",this.onRemove)]};x.prototype.draw=function(){var a=this.getProjection(),b={};try{a&&((b=a.fromLatLngToDivPixel(this.get("position")))&&this.div.css({left:b.x+"px",top:b.y+"px",display:"block"}),this.text&&this.span.html(this.text.toString()))}catch(c){console.error(c)}};
x.prototype.onRemove=function(){f(this.div).remove()};for(g in a.options)a.options.hasOwnProperty(g)&&(vo=a.options[g],/ControlOptions/g.test(g)&&vo.hasOwnProperty("position")&&"string"===typeof vo.position&&(a.options[g].position=google.maps.ControlPosition[vo.position.toUpperCase()]));a.googleMapOptions=a.options;a.options.hasOwnProperty("streetView")&&(a.googleMapOptions.streetViewObj=a.options.streetView,delete a.googleMapOptions.streetView);a.googleMapOptions.center=p(a.options.center,!0);a.options.hasOwnProperty("styles")&&
("string"===typeof a.options.styles&&B.hasOwnProperty(a.options.styles)?a.googleMapOptions.styles=B[a.options.styles]:Array.isArray(a.options.styles)&&(a.googleMapOptions.styles=a.options.styles));"string"===typeof a.options.center?(c=new google.maps.Geocoder,c.geocode({address:a.options.center},function(b,c){try{c===google.maps.GeocoderStatus.OVER_QUERY_LIMIT?setTimeout(function(){a.init()},a.interval):c===google.maps.GeocoderStatus.OK&&Array.isArray(b)?0").text(e).html()),console.error("Geocoder Error Code: "+c))}catch(d){console.error(d)}})):(a.map=new google.maps.Map(a.container,a.googleMapOptions),google.maps.event.addListenerOnce(a.map,
"idle",function(){a.overlay();google.maps.event.trigger(a.map,"resize")}),a.bindEvents(a.map,a.options.event))}}};f.fn.tinyMapConfigure=function(a){r=f.extend(r,a)};f.fn.tinyMapQuery=function(a,c){var b={key:r.hasOwnProperty("key")?r.key:"",language:"zh-TW"},d=f.extend({},b,a),e=null;f.getJSON("//maps.googleapis.com/maps/api/geocode/json",d,function(a){"OK"===a.status&&a.results&&"undefined"!==typeof a.results[0]&&(d.hasOwnProperty("latlng")?e=a.results[0].formatted_address:d.hasOwnProperty("address")&&
(e=[a.results[0].geometry.location.lat,a.results[0].geometry.location.lng].join()),c.call(this,e))})};f.fn.tinyMap=function(a){var c={},b=[],d=arguments;return"string"===typeof a?(this.each(function(){c=f.data(this,"tinyMap");c instanceof A&&"function"===typeof c[a]&&(b=c[a].apply(c,Array.prototype.slice.call(d,1)))}),"undefined"!==typeof b?b:this):this.each(function(){f.data(this,"tinyMap")||f.data(this,"tinyMap",new A(this,a))})}})(window.jQuery||{},window,document);