/*! jQuery tinyMap, Licensed MIT (c) essoduke.org | http://app.essoduke.org/tinyMap/ */ window.gMapsCallback=function(){$(window).trigger("gMapsCallback")}; (function(h,u,r,w){function q(a,b){var c={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])&&(c.lat=d[0],c.lng=d[1]);else return a;else if("object"===typeof a){if("function"===typeof a.lat)return a;a.hasOwnProperty("x")&&a.hasOwnProperty("y")?(c.lat=a.x,c.lng=a.y):a.hasOwnProperty("lat")&&a.hasOwnProperty("lng")&&(c.lat=a.lat,c.lng=a.lng)}return!0===b?new google.maps.LatLng(c.lat, c.lng):c}function v(a){var b=a.hasOwnProperty("css")?a.css.toString():"";this.setValues(a);this.span=h("").css({position:"relative",left:"-50%",top:"0","white-space":"nowrap"}).addClass(b);this.div=h("
").css({position:"absolute",display:"none"});this.span.appendTo(this.div)}function x(a,b){var c=this,d=h.extend({},C,b);c.map=null;c._markers=[];c._markersCluster=[];c._clusters={};c._bounds={};c._labels=[];c._polylines=[];c._polygons=[];c._circles=[];c._kmls=[];c._directions=[];c._directionsMarkers= [];c._places=[];c.container=a;c.options=d;c.googleMapOptions={};c.interval=parseInt(c.options.interval,10)||200;h(u).on("gMapsCallback",function(){c.init()});h(this.container).html(d.loading);c.init()}var z=!1,A=!1,B=!1,t={sensor:!1,language:"zh-TW",callback:"gMapsCallback",api:"//maps.googleapis.com/maps/api/js",clusterer:"//google-maps-utility-library-v3.googlecode.com/svn/trunk/markerclustererplus/src/markerclusterer_packed.js",withLabel:"//google-maps-utility-library-v3.googlecode.com/svn/trunk/markerwithlabel/src/markerwithlabel_packed.js"}, C={autoLocation:!1,center:[24,121],infoWindowAutoClose:!0,interval:200,loading:"\u8b80\u53d6\u4e2d…",notFound:"\u627e\u4e0d\u5230\u67e5\u8a62\u7684\u5730\u9ede",zoom:8},y={},y={greyscale:[{featureType:"all",stylers:[{saturation:-100},{gamma:.5}]}]};x.prototype={VERSION:"3.2.14",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,b=this.options;try{this.adsense(a,b),this.kml(a,b),this.direction(a,b),this.markers(a,b),this.drawPolyline(a,b),this.drawPolygon(a,b),this.drawCircle(a,b),this.streetView(a,b),this.places(a,b),this.geoLocation(a,b)}catch(c){console.warn(c)}},bindEvents:function(a,b){var c=this,d={};switch(typeof b){case "function":google.maps.event.addListener(a,"click",b);break;case "object":for(d in b)"function"===typeof b[d]?google.maps.event.addListener(a,d,b[d]):b[d].hasOwnProperty("func")&&"function"=== typeof b[d].func?b[d].hasOwnProperty("once")&&!0===b[d].once?google.maps.event.addListenerOnce(a,d,b[d].func):google.maps.event.addListener(a,d,b[d].func):"function"===typeof b[d]&&google.maps.event.addListener(a,d,b[d])}a.hasOwnProperty("infoWindow")&&google.maps.event.addListener(a,"click",function(){var b=0,d={};if(c.options.hasOwnProperty("infoWindowAutoClose")&&!0===c.options.infoWindowAutoClose)for(b=0;bn&&d.push({location:k.getAt(n),stopover:!1});e&&g.hasOwnProperty("event")&&g.event.hasOwnProperty("created")&&"function"===typeof g.event.created&&g.event.created.call(e, this);c.hasOwnProperty("event")&&this.bindEvents(e,c.event);c.hasOwnProperty("snap")&&!0===c.snap?(g=new google.maps.DirectionsService,g.route({origin:k.getAt(0),waypoints:d,destination:k.getAt(k.length-1),travelMode:google.maps.DirectionsTravelMode.DRIVING},D)):(e.setPath(k),google.maps.hasOwnProperty("geometry")&&google.maps.geometry.hasOwnProperty("spherical")&&"function"===typeof google.maps.geometry.spherical.computeDistanceBetween&&(f=google.maps.geometry.spherical.computeDistanceBetween(k.getAt(0), k.getAt(k.length-1)),"function"===typeof c.getDistance&&c.getDistance.call(this,f)));e.setMap(a)}},drawPolygon:function(a,b){var c={},d={},c=[],e=0,d=0,f={},f={};if(b.hasOwnProperty("polygon")&&Array.isArray(b.polygon))for(e=0;e]+)>/g,""):!1,e=b.hasOwnProperty("text")?b.text.toString():!1,f=this.markerIcon(b),g={},k=h.extend({},{map:a,position:b.parseAddr,animation:null,id:d},b);c&&(k.title=c);e&&(g.content=e,b.hasOwnProperty("infoWindowOptions")&&(g=h.extend({},g,b.infoWindowOptions),g.hasOwnProperty("pixelOffset")&& Array.isArray(g.pixelOffset)&&(g.pixelOffset=this.formatSize(g.pixelOffset))),k.text=e,k.infoWindow=new google.maps.InfoWindow(g));h.isEmptyObject(f)||(k.icon=f);b.hasOwnProperty("animation")&&"string"===typeof b.animation&&(k.animation=google.maps.Animation[b.animation.toUpperCase()]);c="function"===typeof MarkerWithLabel?new MarkerWithLabel(k):new google.maps.Marker(k);this._markers.push(c);c&&b.hasOwnProperty("event")&&b.event.hasOwnProperty("created")&&"function"===typeof b.event.created&&b.event.created.call(c, this);c.hasOwnProperty("position")&&("function"===typeof c.getPosition&&this._bounds.extend(c.position),this.options.hasOwnProperty("markerFitBounds")&&!0===this.options.markerFitBounds&&this._markers.length===this.options.marker.length&&a.fitBounds(this._bounds));(!b.hasOwnProperty("cluster")||b.hasOwnProperty("cluster")&&!0===b.cluster)&&"function"===typeof this._clusters.addMarker&&this._clusters.addMarker(c);b.hasOwnProperty("newLabel")&&(d=new v({text:b.newLabel,map:a,css:b.hasOwnProperty("newLabelCSS")? b.newLabelCSS.toString():"",id:d}),d.bindTo("position",c,"position"),d.bindTo("text",c,"position"),d.bindTo("visible",c),this._labels.push(d));this.bindEvents(c,b.event)},markerGeocoder:function(a,b,c){var d=this;(new google.maps.Geocoder).geocode({address:b.parseAddr},function(e,f){if(f===google.maps.GeocoderStatus.OVER_QUERY_LIMIT)u.setTimeout(function(){d.markerGeocoder(a,b)},d.interval);else if(f===google.maps.GeocoderStatus.OK){var g={},k={},k=b.hasOwnProperty("id")?b.id:"",g=b.hasOwnProperty("title")? b.title.toString().replace(/<([^>]+)>/g,""):!1,p=b.hasOwnProperty("text")?b.text.toString():!1,l={map:a,position:e[0].geometry.location,animation:null,visible:!0,id:k},n=d.markerIcon(b);g&&(l.title=g);p&&(l.text=p,l.infoWindow=new google.maps.InfoWindow({content:p}));h.isEmptyObject(n)||(l.icon=n);b.hasOwnProperty("animation")&&"string"===typeof b.animation&&(l.animation=google.maps.Animation[b.animation.toUpperCase()]);l=h.extend({},l,b);g="function"===typeof MarkerWithLabel?new MarkerWithLabel(l): new google.maps.Marker(l);d._markers.push(g);g&&b.hasOwnProperty("event")&&b.event.hasOwnProperty("created")&&"function"===typeof b.event.created&&b.event.created.call(g,d);g.hasOwnProperty("position")&&("function"===typeof g.getPosition&&d._bounds.extend(g.position),d.options.hasOwnProperty("markerFitBounds")&&!0===d.options.markerFitBounds&&d._markers.length===c.marker.length&&a.fitBounds(d._bounds));(!b.hasOwnProperty("cluster")||b.hasOwnProperty("cluster")&&!0===b.cluster)&&"function"===typeof d._clusters.addMarker&& d._clusters.addMarker(g);b.hasOwnProperty("newLabel")&&(k=new v({text:b.newLabel,map:d.map,css:b.hasOwnProperty("newLabelCSS")?b.newLabelCSS.toString():"",id:k}),k.bindTo("position",g,"position"),k.bindTo("text",g,"position"),k.bindTo("visible",g),d._labels.push(k));d.bindEvents(g,b.event)}})},direction:function(a,b){var c=0;if(b.hasOwnProperty("direction")&&Array.isArray(b.direction))for(c=0;c#LATLNG#,0.000000".replace(/#LATLNG#/gi,l));if(!0===a.polyline)for(f=b._polylines,m=0;m1#LATLNG#".replace(/#LATLNG#/gi, l))}if(!0===a.direction)for(f=b._directions,m=0;m1#LATLNG#".replace(/#LATLNG#/gi,l))}l=c.join("").replace(/#PLACEMARKS#/gi,g+k+p);if(!0===a.download)u.open("data:application/vnd.google-earth.kml+xml;charset=utf-8;base64,"+u.btoa(u.decodeURIComponent(u.encodeURIComponent(l))));else return l}},init:function(){var a=this,b={}, b={},c=h.extend({},t),d=c.api.split("?")[0],e="",f={};try{delete c.api,delete c.clusterer,delete c.withLabel,c=h.param(c)}catch(g){}z||"undefined"!==typeof u.google||(b=r.createElement("script"),b.setAttribute("src",[d,c].join("?")),(r.getElementsByTagName("head")[0]||r.documentElement).appendChild(b),z=!0,b=null);if("object"===typeof u.google){!A&&a.options.hasOwnProperty("markerCluster")&&!1!==a.options.markerCluster&&"undefined"===typeof MarkerClusterer&&(b=r.createElement("script"),b.setAttribute("src", t.clusterer),(r.getElementsByTagName("head")[0]||r.documentElement).appendChild(b),A=!0,b=null);!B&&a.options.hasOwnProperty("markerWithLabel")&&!0===a.options.markerWithLabel&&"undefined"===typeof MarkerWithLabel&&(b=r.createElement("script"),b.setAttribute("src",t.withLabel),(r.getElementsByTagName("head")[0]||r.documentElement).appendChild(b),B=!0,b=null);a._bounds=new google.maps.LatLngBounds;v.prototype=new google.maps.OverlayView;v.prototype.onAdd=function(){this.div.appendTo(h(this.getPanes().overlayLayer)); this.listeners=[google.maps.event.addListener(this,"visible_changed",this.onRemove)]};v.prototype.draw=function(){var a=this.getProjection(),b={};try{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)}};v.prototype.onRemove=function(){h(this.div).remove()};for(f in a.options)a.options.hasOwnProperty(f)&&(vo=a.options[f],/ControlOptions/g.test(f)&&vo.hasOwnProperty("position")&& "string"===typeof vo.position&&(a.options[f].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=q(a.options.center,!0);a.options.hasOwnProperty("styles")&&("string"===typeof a.options.styles&&y.hasOwnProperty(a.options.styles)?a.googleMapOptions.styles=y[a.options.styles]:Array.isArray(a.options.styles)&& (a.googleMapOptions.styles=a.options.styles));"string"===typeof a.options.center?(b=new google.maps.Geocoder,b.geocode({address:a.options.center},function(b,c){try{c===google.maps.GeocoderStatus.OVER_QUERY_LIMIT?u.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))}}};h.fn.tinyMapConfigure= function(a){t=h.extend(t,a)};h.fn.tinyMapDistance=function(a,b){var c={key:t.hasOwnProperty("key")?t.key:"",origins:[],destinations:[],language:"zh-TW"},c=h.extend({},c,a);Array.isArray(c.origins)&&(c.origins=c.origins.join("|"));Array.isArray(c.destinations)&&(c.destinations=c.destinations.join("|"));h.getJSON("//maps.googleapis.com/maps/api/distancematrix/json",c,function(a){"OK"===a.status&&b.cal(this,a)})};h.fn.tinyMapQuery=function(a,b){var c={key:t.hasOwnProperty("key")?t.key:"",language:"zh-TW"}, d=h.extend({},c,a),e=null;h.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()),b.call(this,e))})};h.fn.tinyMap=function(a){var b={},c=[],d=arguments;return"string"===typeof a?(this.each(function(){b=h.data(this,"tinyMap");b instanceof x&&"function"=== typeof b[a]&&(c=b[a].apply(b,Array.prototype.slice.call(d,1)))}),"undefined"!==typeof c?c:this):this.each(function(){h.data(this,"tinyMap")||h.data(this,"tinyMap",new x(this,a))})}})(window.jQuery||{},window,document);