/* MIT License */ window.gMapsCallback=function(){$(window).trigger("gMapsCallback")}; (function(g,t,q,I){function z(a){var b;if(a instanceof Array)for(b=0;b").css({position:"relative", left:"-50%",top:"0","white-space":"nowrap"}).addClass(b);this.div=g("
").css({position:"absolute",display:"none"});this.span.appendTo(this.div)}function A(a,b){var d=this,c=g.extend({},H,b);d.idleOnceCount=!1;d.map=null;d._markers=[];d._markersCluster=[];d._clusters={};d._bounds={};d._labels=[];d._polylines=[];d._polygons=[];d._circles=[];d._kmls=[];d._directions=[];d._directionsMarkers=[];d._places=[];d.container=a;d.options=c;d.googleMapOptions={};d.interval=parseInt(d.options.interval,10)|| 200;g(t).on("gMapsCallback",function(){d.init()});g(this.container).html(c.loading);return d.init()}var D=!1,E=!1,F=!1,G=!1,y={language:"zh-TW",callback:"gMapsCallback",api:"https://maps.googleapis.com/maps/api/js",clusterer:"https://cdn.essoduke.org/js/tinyMap/markerclusterer.js",withLabel:"https://cdn.essoduke.org/js/tinyMap/markerwithlabel.js",OMS:"https://cdn.essoduke.org/js/tinyMap/oms.min.js"},H={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.4.6",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(a){a=this.map;var b=this.options;try{this.idleOnceCount||(this.kml(a,b),this.directionService(a,b),this.placeMarkers(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),this.idleOnceCount=!0)}catch(d){console.error(d)}finally{google.maps.event.trigger(a,"resize")}},bindEvents:function(a,b){var d=this,c={};switch(typeof b){case "function":google.maps.event.clearListeners(a,"click");google.maps.event.addListener(a,"click",b);break;case "object":for(c in b)"function"===typeof b[c]?"created"===c?b[c].call(a):(google.maps.event.clearListeners(a, c),google.maps.event.addListener(a,c,b[c])):b[c].hasOwnProperty("func")&&"function"===typeof b[c].func?b[c].hasOwnProperty("once")&&!0===b[c].once?google.maps.event.addListenerOnce(a,c,b[c].func):(google.maps.event.clearListeners(a,c),google.maps.event.addListener(a,c,b[c].func)):"function"===typeof b[c]&&(google.maps.event.clearListeners(a,c),google.maps.event.addListener(a,c,b[c]))}a.hasOwnProperty("defaultInfoWindow")&&(google.maps.event.clearListeners(a,"click"),google.maps.event.addListener(a, "click",function(){var b;if(d.options.hasOwnProperty("infoWindowAutoClose")&&!0===d.options.infoWindowAutoClose)for(b=0;bm&&c.push({location:k.getAt(m),stopover:!1});d.hasOwnProperty("event")&&this.bindEvents(e,d.event);d.hasOwnProperty("snap")&&!0===d.snap?(h=new google.maps.DirectionsService,h.route({origin:k.getAt(0),waypoints:c,destination:k.getAt(k.length-1),travelMode:google.maps.DirectionsTravelMode.DRIVING},u)):(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 d.getDistance&&d.getDistance.call(this,f)));e.setMap(a)}},drawPolygon:function(a,b){var d,c;if(b.hasOwnProperty("polygon")&&Array.isArray(b.polygon))for(c=0;c', ""];b.forEach(function(a){"undefined"!==typeof a.infoWindow&&a.infoWindow.close();e.push('")});e.push("");c.on("change.tinyMap","select",function(){var b=g(this);a.close("marker");this.value.length&&a.get({marker:[this.value]},function(c){c.marker.length&&"undefined"!==c.marker[0]&&(c=c.marker[0],!0===d.infoWindow&&"undefined"!==typeof c.infoWindow&&"function"===typeof c.infoWindow.open&& c.infoWindow.open(a.map,c),!0===d.panTo&&a.map.panTo(c.getPosition()),"function"===typeof d.onChange&&d.onChange.call(b,c))})}).html(e.join(""));"string"===typeof d.css&&c.find("select").addClass(d.css)})}},placeMarkers:function(a,b,d,c){var e=this,f={},h={maxZoom:null,gridSize:60},k=Array.isArray(b.marker)?b.marker:[],l={},n=!1;"undefined"!==typeof c&&Array.isArray(c)&&c.length&&(k=c);e.options.hasOwnProperty("markerCluster")&&"function"===typeof MarkerClusterer&&(h=g.extend({},h,b.markerCluster), e._clusters=new MarkerClusterer(a,[],h),h.hasOwnProperty("event")&&e.bindEvents(e._clusters,h.event));e.options.hasOwnProperty("enableOMS")&&"function"===typeof OverlappingMarkerSpiderfier&&(n=!0);n&&(l=new OverlappingMarkerSpiderfier(a,{markersWontHide:!0}),l.addListener("click",function(b){b.hasOwnProperty("oms")&&b.infoWindow.setContent(b.oms);b.infoWindow.open(a,b)}),l.addListener("spiderfy",function(a){}),l.addListener("unspiderfy",function(a){}));var m=k.length;k.forEach(function(c,k){var h= r(c.addr,!0),u=e.markerIcon(c),v=!0,C=!1,q={},w={},t="undefined"!==typeof c.id?c.id:c.addr.toString().replace(/\s/g,""),p={id:t,map:a,animation:null,showLabel:!0},p=g.extend({},p,c);"modify"===d&&t&&e.get({marker:[t]},function(a){!Array.isArray(a.marker)||!a.marker.length||c.hasOwnProperty("forceInsert")&&!0===c.forceInsert||(c=g.extend(a.marker[0],c),"function"===typeof e._clusters.removeMarker&&e._clusters.removeMarker(a.marker[0]),v=!1,C=!0)});c.hasOwnProperty("title")&&(p.title=c.title.toString().replace(/<([^>]+)>/g, ""));g.isEmptyObject(u)||(p.icon=u);c.hasOwnProperty("animation")&&"string"===typeof c.animation&&(p.animation=google.maps.Animation[c.animation.toUpperCase()]);"string"===typeof h?(f=new google.maps.Geocoder,f.geocode({address:h},function(f,h){h===google.maps.GeocoderStatus.OVER_QUERY_LIMIT?setTimeout(function(){e.placeMarkers(m,a,b,d,[c])},e.interval*(k+1)):h===google.maps.GeocoderStatus.OK&&(!v&&C?("function"===typeof c.setPosition&&(c.setPosition(f[0].geometry.location),p.hasOwnProperty("title")&& c.setTitle(p.title),p.hasOwnProperty("icon")&&c.setIcon(p.icon)),w=c):(p.position=f[0].geometry.location,q=b.hasOwnProperty("markerWithLabel")&&!0===b.markerWithLabel?"function"===typeof MarkerWithLabel?new MarkerWithLabel(p):new google.maps.Marker(p):new google.maps.Marker(p),e._markers.push(q),w=q),n&&l.addMarker(w),e.processMarker(m,a,b,w,d))})):(!v&&C?("function"===typeof c.setPosition&&h.lat()&&h.lng()&&c.setPosition(h),p.hasOwnProperty("title")&&c.setTitle(p.title),p.hasOwnProperty("icon")&& c.setIcon(p.icon),w=c):(p.position=h,q=b.hasOwnProperty("markerWithLabel")&&!0===b.markerWithLabel?"function"===typeof MarkerWithLabel?new MarkerWithLabel(p):new google.maps.Marker(p):new google.maps.Marker(p),e._markers.push(q),w=q,n&&l.addMarker(w)),e.processMarker(m,a,b,w,d))});b.hasOwnProperty("markerWithLabel")&&g.isNumeric(b.markerWithLabel)&&function(){e.clear("label");var c=a.getCenter(),b=[];e.get("marker",function(d){d.forEach(function(a){1E3>google.maps.geometry.spherical.computeDistanceBetween(a.getPosition(), c)&&b.push(a)});b&&b.forEach(function(c){var b={id:c.id,text:c.newLabel,map:a,css:c.hasOwnProperty("newLabelCSS")?c.newLabelCSS.toString():""},b=new x(b);b.bindTo("position",c);b.set("visible",c.showLabel);e._labels.push(b)})})}.apply(e,arguments);e.markerControl()},directionService:function(a,b){var d=this,c=new google.maps.DirectionsService;Array.isArray(b.direction)&&b.direction.forEach(function(b){if("undefined"!==typeof b.from&&"undefined"!==typeof b.to){var e={},h=new google.maps.DirectionsRenderer, k=g.extend({},{infoWindow:new google.maps.InfoWindow,map:d.map},b),l=[],n=[],m=[];e.origin=r(b.from,!0,!1);e.destination=r(b.to,!0,!1);e.travelMode=b.hasOwnProperty("travel")&&google.maps.TravelMode[b.travel.toString().toUpperCase()]?google.maps.TravelMode[b.travel.toString().toUpperCase()]:google.maps.TravelMode.DRIVING;b.hasOwnProperty("panel")&&g(b.panel).length&&(k.panel=g(b.panel).get(0));b.hasOwnProperty("requestExtra")&&b.requestExtra&&(e=g.extend({},e,b.requestExtra));b.hasOwnProperty("optimize")&& (e.optimizeWaypoints=b.optimize);b.hasOwnProperty("waypoint")&&Array.isArray(b.waypoint)&&(b.waypoint.forEach(function(a){var b={stopover:!0};"string"===typeof a||Array.isArray(a)?b.location=r(a,!0):a.hasOwnProperty("location")&&(b.location=r(a.location,!0),b.stopover=a.hasOwnProperty("stopover")?a.stopover:!0);n.push(a.text||a.toString());a.hasOwnProperty("icon")&&m.push(a.icon.toString());l.push(b)}),e.waypoints=l);c.route(e,function(c,f){f===google.maps.DirectionsStatus.OK&&(c.routes.forEach(function(f, h){b.hasOwnProperty("renderAll")&&!0===b.renderAll&&!0===e.provideRouteAlternatives&&new google.maps.DirectionsRenderer({map:a,directions:c,routeIndex:h});var g=f.legs,l="",u="",v={};b.hasOwnProperty("fromText")&&(l=g[0].start_address=b.fromText);b.hasOwnProperty("toText")&&(1===g.length?g[0].end_address=b.toText:g[g.length-1].end_address=b.toText,u=b.toText);b.hasOwnProperty("icon")&&(k.suppressMarkers=!0,b.icon.hasOwnProperty("from")&&"string"===typeof b.icon.from&&d.directionServiceMarker(g[0].start_location, {icon:b.icon.from,text:l},k.infoWindow,b),b.icon.hasOwnProperty("to")&&"string"===typeof b.icon.to&&d.directionServiceMarker(g[g.length-1].end_location,{icon:b.icon.to,text:u},k.infoWindow,b));for(l=1;l #style1 #DATA# ".split(" "),c=" #style1 1 1 clampedToGround #LATLNG# ".split(" "), e="",f="",h="",k="",l="";a="";this.get("marker,polyline,polygon,circle,direction",function(a){var g="";!0===b.marker&&"undefined"!==typeof a.marker&&a.marker.forEach(function(a){g=[a.getPosition().lng(),a.getPosition().lat()].join();e+=d.join("").replace(/#NAME#/gi,"Markers").replace(/#DATA#/gi,"#LATLNG#,0.000000".replace(/#LATLNG#/gi,g))});!0===b.polyline&&"undefined"!==typeof a.polyline&&a.polyline.forEach(function(a){g="";a.getPath().getArray().forEach(function(a){g+= [a.lng(),a.lat(),"0.000000\n"].join()});f+=d.join("").replace(/#NAME#/gi,"Polylines").replace(/#DATA#/gi,"1#LATLNG#".replace(/#LATLNG#/gi,g))});!0===b.polygon&&"undefined"!==typeof a.polygon&&a.polygon.forEach(function(a){g="";a.getPath().getArray().forEach(function(a){g+=[a.lng(),a.lat(),"0.000000\n"].join()});h+=c.join("").replace(/#NAME#/gi,"Polygons").replace(/#LATLNG#/gi,g)});!0===b.circle&&"undefined"!==typeof a.circle&& a.circle.forEach(function(a){g="";var b=Math.PI/180,d=180/Math.PI,d=a.getRadius()/6378137*d,b=d/Math.cos(a.getCenter().lat()*b),e;for(e=0;65>e;e+=1){var f=e/32*Math.PI;var h=a.getCenter().lng()+b*Math.cos(f);f=a.getCenter().lat()+d*Math.sin(f);g+=[h,f,"0.000000\n"].join()}k+=c.join("").replace(/#NAME#/gi,"Circles").replace(/#LATLNG#/gi,g)});!0===b.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){g="";Array.isArray(a.path)&&a.path.forEach(function(a){g+=[a.lng(),a.lat(),"0.000000\n"].join()});l+=d.join("").replace(/#NAME#/gi,"Directions").replace(/#DATA#/gi,"1#LATLNG#".replace(/#LATLNG#/gi,g))})})})});a='#PLACEMARKS#'.replace(/#NAME#/gi, "").replace(/#PLACEMARKS#/gi,e+f+h+k+l);if(!0===b.download)t.open("data:application/vnd.google-earth.kml+xml;charset=utf-8;base64,"+t.btoa(t.decodeURIComponent(t.encodeURIComponent(a))));else return a},init:function(){var a=this,b={},d={},d=g.extend({},y),c=d.api.split("?")[0],e="",b={},f={};try{delete d.api,delete d.clusterer,delete d.withLabel,d=g.param(d)}catch(k){}D||"undefined"!==typeof t.google||(b=q.createElement("script"),b.setAttribute("src",[c,d].join("?")),(q.getElementsByTagName("head")[0]|| q.documentElement).appendChild(b),D=!0,b=null);if("object"===typeof t.google){z(a.options);!E&&a.options.hasOwnProperty("markerCluster")&&!1!==a.options.markerCluster&&"undefined"===typeof MarkerClusterer&&(b=q.createElement("script"),b.setAttribute("src",y.clusterer),(q.getElementsByTagName("head")[0]||q.documentElement).appendChild(b),E=!0,b=null);!F&&a.options.hasOwnProperty("markerWithLabel")&&!0===a.options.markerWithLabel&&"undefined"===typeof MarkerWithLabel&&(b=q.createElement("script"),b.setAttribute("src", y.withLabel),(q.getElementsByTagName("head")[0]||q.documentElement).appendChild(b),F=!0,b=null);!G&&a.options.hasOwnProperty("enableOMS")&&"undefined"===typeof OverlappingMarkerSpiderfier&&(b=q.createElement("script"),b.setAttribute("src",y.OMS),(q.getElementsByTagName("head")[0]||q.documentElement).appendChild(b),G=!0,b=null);a._bounds=new google.maps.LatLngBounds;x.prototype=new google.maps.OverlayView;x.prototype.onAdd=function(){var a=this;null!==a.div&&(a.div.appendTo(g(a.getPanes().overlayLayer)), a.listeners=[google.maps.event.addListener(a,"visible_changed",function(){a.draw()}),google.maps.event.addListener(a,"position_changed",function(){a.draw()}),google.maps.event.addListener(a,"visible_changed",function(){a.draw()}),google.maps.event.addListener(a,"clickable_changed",function(){a.draw()}),google.maps.event.addListener(a,"text_changed",function(){a.draw()}),google.maps.event.addListener(a,"zindex_changed",function(){a.draw()})])};x.prototype.draw=function(){var a=this.getProjection(), b={};try{null!==this.div&&a&&((b=a.fromLatLngToDivPixel(this.get("position")))&&this.div.css({left:b.x+"px",top:b.y+"px",display:this.get("visible")?"block":"none"}),this.text&&this.span.html(this.text.toString()))}catch(n){console.error(n)}};x.prototype.onRemove=function(){g(this.div).remove();this.div=null};for(f in a.options)a.options.hasOwnProperty(f)&&(b=a.options[f],/ControlOptions/g.test(f)&&b.hasOwnProperty("position")&&"string"===typeof b.position&&(a.options[f].position=google.maps.ControlPosition[b.position.toUpperCase()])); a.googleMapOptions=a.options;a.options.hasOwnProperty("streetView")&&(a.googleMapOptions.streetViewObj=a.options.streetView,delete a.googleMapOptions.streetView);a.googleMapOptions.center=r(a.options.center,!0,!1);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));if("string"===typeof a.options.center)d=new google.maps.Geocoder, d.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(n){console.error(n)}});else{a.map=new google.maps.Map(a.container,a.googleMapOptions);var h="undefined"!==typeof a.options.event?a.options.event:{};a.mapIdleEvent(h)}}},mapIdleEvent:function(a){var b=this;a.hasOwnProperty("idle")?"undefined"!==a.idle.func&&"function"===typeof a.idle.func&&"undefined"!==typeof a.idle.once?!0===a.idle.once?google.maps.event.addListenerOnce(b.map,"idle",function(){b.overlay();a.idle.func.apply(this,arguments);delete a.idle}): google.maps.event.addListener(b.map,"idle",function(){b.overlay();a.idle.func.apply(this,arguments)}):"function"===typeof a.idle&&google.maps.event.addListener(b.map,"idle",function(){b.overlay();a.idle.apply(this,arguments)}):google.maps.event.addListenerOnce(b.map,"idle",function(){b.overlay()});b.bindEvents(b.map,a)}};g.fn.tinyMapConfigure=function(a){y=g.extend(y,a)};g.fn.tinyMap=function(a){var b={},d=[],c=arguments;return"string"===typeof a?(this.each(function(){b=g.data(this,"tinyMap");b instanceof A&&"function"===typeof b[a]&&(d=b[a].apply(b,Array.prototype.slice.call(c,1)))}),"undefined"!==typeof d?d:this):this.each(function(){g.data(this,"tinyMap")||g.data(this,"tinyMap",new A(this,a))})}})(window.jQuery||{},window,document);