PageSourceSearch

https://fleet.heliot.co.th/js/route.6c459428.js

js heliot.co.th collected 2026-10-02 02:11:44 UTC 36,706 bytes, 2 lines download raw bytes

1"use strict";(self["webpackChunkheliot_fleet_v4"]=self["webpackChunkheliot_fleet_v4"]||[]).push([[786],{43527:function(t,e,i){i.d(e,{A:function(){return h}});var o=function(){var t=this,e=t._self._c;return e("input",{directives:[{name:"model",rawName:"v-model",value:t.autocompleteText,expression:"autocompleteText"}],ref:"autocomplete",class:t.classname,attrs:{type:"text",id:t.id,placeholder:t.placeholder,disabled:t.disabled},domProps:{value:t.autocompleteText},on:{focus:function(e){return t.onFocus()},blur:function(e){return t.onBlur()},change:t.onChange,keypress:t.onKeyPress,keyup:t.onKeyUp,input:function(e){e.target.composing||(t.autocompleteText=e.target.value)}}})},s=[];const n={subpremise:"short_name",street_number:"short_name",route:"long_name",locality:"long_name",administrative_area_level_1:"short_name",administrative_area_level_2:"long_name",country:"long_name",postal_code:"short_name"},a=["locality","administrative_area_level_3"],l=["locality","sublocality","postal_code","country","administrative_area_level_1","administrative_area_level_2"],r=["address_components","adr_address","alt_id","formatted_address","geometry","icon","id","name","business_status","photo","place_id","scope","type","url","utc_offset_minutes","vicinity"];var c={name:"VueGoogleAutocomplete",props:{id:{type:String,required:!0},classname:String,placeholder:{type:String,default:"Start typing"},disabled:{type:Boolean,default:!1},types:{type:String,default:"address"},fields:{type:Array,default:function(){return r}},country:{type:[String,Array],default:null},enableGeolocation:{type:Boolean,default:!1},geolocationOptions:{type:Object,default:null}},data(){return{autocomplete:null,autocompleteText:"",geolocation:{geocoder:null,loc:null,position:null}}},watch:{autocompleteText:function(t,e){this.$emit("inputChange",{newVal:t,oldVal:e},this.id)},country:function(t,e){this.autocomplete.setComponentRestrictions({country:null===this.country?[]:this.country})}},mounted:function(){const t={};this.types&&(t.types=[this.types]),this.country&&(t.componentRestrictions={country:this.country}),this.autocomplete=new google.maps.places.Autocomplete(document.getElementById(this.id),t),this.autocomplete.setFields(this.fields),this.autocomplete.addListener("place_changed",this.onPlaceChanged)},methods:{onPlaceChanged(){let t=this.autocomplete.getPlace();t.geometry?void 0!==t.address_components&&(this.$emit("placechanged",this.formatResult(t),t,this.id),this.autocompleteText=document.getElementById(this.id).value,this.onChange()):this.$emit("no-results-found",t,this.id)},onFocus(){this.biasAutocompleteLocation(),this.$emit("focus")},onBlur(){this.$emit("blur")},onChange(){this.$emit("change",this.autocompleteText)},onKeyPress(t){this.$emit("keypress",t)},onKeyUp(t){this.$emit("keyup",t)},clear(){this.autocompleteText=""},focus(){this.$refs.autocomplete.focus()},blur(){this.$refs.autocomplete.blur()},update(t){this.autocompleteText=t},updateCoordinates(t){(t||t.lat||t.lng)&&(this.geolocation.geocoder||(this.geolocation.geocoder=new google.maps.Geocoder),this.geolocation.geocoder.geocode({location:t},(t,e)=>{"OK"===e?(t=this.filterGeocodeResultTypes(t),t[0]?(this.$emit("placechanged",this.formatResult(t[0]),t[0],this.id),this.update(t[0].formatted_address)):this.$emit("error","no result for provided coordinates")):this.$emit("error","error getting address from coords")}))},geolocate(){this.updateGeolocation((t,e)=>{this.updateCoordinates(t)})},updateGeolocation(t=null){if(navigator.geolocation){let e={};this.geolocationOptions&&Object.assign(e,this.geolocationOptions),navigator.geolocation.getCurrentPosition(e=>{let i={lat:e.coords.latitude,lng:e.coords.longitude};this.geolocation.loc=i,this.geolocation.position=e,t&&t(i,e)},t=>{this.$emit("error","Cannot get Coordinates from navigator",t)},e)}},biasAutocompleteLocation(){this.enableGeolocation&&this.updateGeolocation((t,e)=>{let i=new google.maps.Circle({center:t,radius:e.coords.accuracy});this.autocomplete.setBounds(i.getBounds())})},formatResult(t){let e={};for(let i=0;i<t.address_components.length;i++){let o=t.address_components[i].types[0];if(n[o]){let s=t.address_components[i][n[o]];e[o]=s}}return e["latitude"]=t.geometry.location.lat(),e["longitude"]=t.geometry.location.lng(),e}
1,filterGeocodeResultTypes(t){if(!t||!this.types)return t;let e=[],i=[this.types];i.includes("(cities)")&&(i=i.concat(a)),i.includes("(regions)")&&(i=i.concat(l));for(let o of t)for(let t of o.types)if(i.includes(t)){e.push(o);break}return e}}},u=c,d=i(81656),p=(0,d.A)(u,o,s,!1,null,null,null),h=p.exports},71829:function(t,e,i){i.r(e),i.d(e,{default:function(){return I}});var o=i.cw(function(t,e){var o=i.p+"img/copy-icon.49f1d8f6.svg";t.exports=o}),s=i.cw(function(t,e){var o=i.p+"img/gmap_pin.541e52e0.svg";t.exports=o}),n=function(){var t=this,e=t._self._c;return e("defaultLayout",[e("div",{staticClass:"route-modal"},[e("div",{staticClass:"route-title"},[t._v(t._s(t.$t("route.title")))]),e("div",{staticClass:"route-header"},[e("div",{staticClass:"navigation-btn",on:{click:t.onChangeTab}},[t.displayRoutesList?t._e():e("a-icon",{attrs:{type:"left"}}),e("div",{staticClass:"navigation-text"},[t._v(" "+t._s(t.displayRoutesList?t.$t("route.addRoute"):t.$t("route.allRoutes"))+" ")])],1)]),e("div",{staticClass:"route-content"},[t.displayRoutesList?e("div",{staticClass:"route-list"},t._l(t.routes,function(i){return e("div",{key:i.id,staticClass:"route-info-container"},[e("a-row",{attrs:{type:"flex"}},[e("a-col",{attrs:{span:20},on:{click:function(e){return t.setSelectedRoute(i)}}},[e("div",{staticClass:"route-info"},[e("div",{staticClass:"type"},[e("icon-font",{staticStyle:{"padding-right":"5px"},attrs:{type:"icon-Iconawesome-route"}})],1),e("div",{staticClass:"name"},[t._v(t._s(i.Name))])])]),e("a-col",{attrs:{span:4}},[e("a-popconfirm",{staticStyle:{padding:"10px","font-size":"1.2rem"},attrs:{title:t.$t("route.deleteRouteConfirm"),okText:t.$t("common.confirm"),cancelText:t.$t("common.cancel")},on:{confirm:function(e){return t.onRemoveRoute(i.id)}}},[e("div",{staticClass:"remove"},[e("icon-font",{attrs:{type:"icon-delete1"}})],1)])],1)],1)],1)}),0):e("div",[t.isReadOnly?e("div",[e("route-info",{attrs:{route:t.selectedRoute,googleMap:this.$refs.googleMap,directionsDisplay:t.directionsDisplay,calculateInfoRouteList:t.calculateInfoRouteList,calculateRouteDirection:t.calculateRouteDirection},on:{onClickEditIcon:t.onClickEditIcon}})],1):e("div",[e("route-form",{attrs:{route:t.selectedRoute,googleMap:this.$refs.googleMap,directionsDisplay:t.directionsDisplay,calculateInfoRouteList:t.calculateInfoRouteList,calculateRouteDirection:t.calculateRouteDirection,onCreateWaypoints:t.onCreateWaypoints,onRemoveWaypoints:t.onRemoveWaypoints,latlngMap:`${t.clickedLat},${t.clickedLng}`},on:{onSave:t.onClickSave,onClose:t.onClickClose,clearWaypoints:t.onClearRouteWaypoints}})],1)])])]),e("div",{staticClass:"google-map"},[e("GmapMap",{ref:"googleMap",staticStyle:{width:"100%",height:"100vh"},attrs:{center:{lat:13.7460067,lng:100.5440535},zoom:this.mapZoom,"map-type-id":"roadmap",options:{zoomControl:!0,mapTypeControl:!0,scaleControl:!1,streetViewControl:!0,rotateControl:!1,fullscreenControl:!1,disableDefaultUi:!0,zoomControlOptions:{position:3},streetViewControlOptions:{position:3},clickableIcons:!0}},on:{click:t.clickPosition}})],1)])},a=[],l=(i(44114),i(18111),i(7588),i(61701),i(62849)),r=function(){var t=this,e=t._self._c;return e("div",[e("div",{staticClass:"title"},[t._v(" "+t._s(t.$t("route.routeInfo"))+" "),t.positionList.length>0?e("a-icon",{attrs:{type:"form"},on:{click:()=>this.$emit("onClickEditIcon")}}):t._e()],1),e("div",{staticClass:"header"},[e("div",{staticClass:"name-container"},[e("div",{staticClass:"name-container-title"},[t._v(t._s(t.$t("route.route")))]),e("div",{staticClass:"name-container-name"},[t._v(" "+t._s(t.name)+" ")])])]),e("a-timeline",{staticClass:"content"},t._l(t.displayedPositionList,function(i,o){return e("a-timeline-item",{key:`${i.name}-${o}`,staticStyle:{height:"80px",padding:"0"},attrs:{color:"info"===i.type?"#555":"green"}}
1,["info"===i.type?e("a-icon",{staticStyle:{"font-size":"14px"},attrs:{slot:"dot",type:"question-circle"},slot:"dot"}):e("icon-font",{staticStyle:{"font-size":"20px"},attrs:{slot:"dot",type:t.getPositionIcon(i.type)},slot:"dot"}),Object.keys(i).length>0?e("div",[e("div",{staticClass:"item-info-container"},[e("div",{staticClass:"item-info-name"},[t._v(" "+t._s(i.name)+" ")])])]):t._e()],1)}),1),e("div",{staticClass:"footer"},[e("div",[e("div",{staticClass:"summary"},[t._v(" "+t._s(t.$t("route.totalDistance"))+" "+t._s(t.sumDistance)+" "+t._s(t.$t("route.km"))+" "+t._s(t.$t("route.totalTravelTime"))+" "+t._s(t.sumDuration)+" "+t._s(t.$t("route.minutes"))+" ")]),e("a-button",{staticClass:"share-link-btn",attrs:{type:"primary"},on:{click:()=>t.isDisplayedModal=!0}},[e("a-icon",{attrs:{type:"share-alt"}}),t._v(" "+t._s(t.$t("route.share"))+" ")],1)],1)]),e("a-modal",{attrs:{visible:t.isDisplayedModal,mask:!0,closable:!0,footer:!1,centered:"",width:360},on:{cancel:()=>(t.isDisplayedModal=!1,t.posShareTabActivated=!0,t.routeShareTabActivated=!1)}},[e("div",{staticClass:"share-modal"},[e("div",{staticClass:"navigation-container"},[e("div",{class:["modal-title","navigation-button",t.posShareTabActivated&&"active"],on:{click:function(e){return t.handleTabClick("postions_share")}}},[t._v(t._s(t.$t("route.sharePosition")))]),e("div",{class:["modal-title","navigation-button",t.routeShareTabActivated&&"active"],on:{click:function(e){return t.handleTabClick("routes_share")}}},[t._v(t._s(t.$t("route.shareRoute")))])]),t.posShareTabActivated?e("div",{staticStyle:{width:"100%"}},[e("div",{class:t.positionList.length>4?"modal-routes-container":"modal-routes-container-fixed"},t._l(t.positionList,function(i,n){return e("div",{key:n,staticClass:"modal-route-item-layout"},[e("div",{staticClass:"route-item-input"},[t._v(" "+t._s(i.name)+" ")]),e("a-button",{staticClass:"route-item-btn",on:{click:function(e){return t.shareSinglePosUrl(i,!0)}}},[e("img",{attrs:{src:o(),alt:""}})]),e("a-button",{staticClass:"route-item-btn",on:{click:function(e){return t.shareSinglePosUrl(i,!1)}}},[e("img",{attrs:{src:s(),alt:"gmap-pin"}})])],1)}),0),e("a-button",{staticClass:"modal-share_all-btn",on:{click:function(e){return t.shareAllPosUrl(!0)}}},[e("img",{attrs:{src:o(),alt:""}}),e("span",[t._v(t._s(t.$t("route.copyAllLinks")))])])],1):t._e(),t.routeShareTabActivated?e("div",{staticClass:"modal-btn-container"},[e("a-button",{staticClass:"modal-btn",attrs:{size:"large"},on:{click:function(e){return t.shareLinkUrl(!1)}}},[e("img",{attrs:{src:s(),alt:"gmap-pin"}}),e("span",{staticStyle:{"margin-left":"8px"}},[t._v("Google Map")])]),e("a-button",{staticClass:"modal-btn",attrs:{icon:"copy",size:"large"},on:{click:function(e){return t.shareLinkUrl(!0)}}},[t._v(" "+t._s(t.$t("route.copyLink"))+" ")]),t.canShareNative()?e("a-button",{staticClass:"modal-btn",attrs:{icon:"share-alt",size:"large"},on:{click:function(e){return t.otherShare()}}},[t._v(" "+t._s(t.$t("route.shareTo"))+" ")]):t._e()],1):t._e()])])],1)},c=[],u=i(25979),d={name:"routeInfo",props:{route:Object,googleMap:Object,directionsDisplay:Object,calculateRouteDirection:Function,calculateInfoRouteList:Function},components:{IconFont:u.rP},data(){return{displayedPositionList:[{}],name:"",positionList:[],sumDistance:0,sumDuration:0,isDisplayedModal:!1,posShareTabActivated:!0,routeShareTabActivated:!1}},async mounted(){const t=await this.calculateRouteDirection(this.route.positionList,!1);if(t){const e=t.routes[0].legs;if(e.length>0){let t=0,i=0;e.forEach(e=>{t+=parseFloat(e.distance.value),i+=parseFloat(e.duration.value)}),this.sumDistance=(t/1e3).toFixed(2),this.sumDuration=Math.ceil(i/60)}this.directionsDisplay.setMap(this.googleMap.$mapObject),this.directionsDisplay.setDirections(t),this.displayedPositionList=this.calculateInfoRouteList(t.routes[0],this.route.positionList),this.name=this.route.name,this.positionList=this.route.positionList}},methods:{canShareNative(){return!!navigator.share},otherShare(){const t="updatable";let e="https://www.google.com/maps/dir/";if(this.positionList.length>0){for(let t=0;t<this.positionList.length;t++)e=e+this.positionList[t].lat+","+this.positionList[t].lng+"/";
1navigator.share?navigator.share({title:this.$t("route.shareLocationTo"),url:e}).then(()=>{}).catch(console.error):this.visibleShareModal=!0}else this.$message.warning({content:this.$t("route.noDataFound"),key:t,duration:3})},shareLinkUrl(t){const e="updatable";let i="https://www.google.com/maps/dir/";if(this.positionList.length>0){for(let t=0;t<this.positionList.length;t++)i=i+this.positionList[t].lat+","+this.positionList[t].lng+"/";!1===t?window.open(i,"_blank"):this.clipboardNavigator(e,i)}else this.$message.warning({content:this.$t("route.noDataFound"),key:e,duration:3})},shareSinglePosUrl(t,e){const i="updateable",o=`https://www.google.com/maps/search/?api=1&query=${t.lat},${t.lng}`;this.positionList.length>0?!1===e?window.open(o,"_blank"):this.clipboardNavigator(i,o):this.$message.warning({content:this.$t("route.noDataFound"),key:i,duration:3})},shareAllPosUrl(t){const e="updateable";let i=[];if(this.positionList.length>0){for(let t=0;t<this.positionList.length;t++){const e=`https://www.google.com/maps/search/?api=1&query=${this.positionList[t].lat},${this.positionList[t].lng}`;i.push(`${t+1}. ${this.positionList[t].name} ${e}\n`)}if(t){const t=i.join("");this.clipboardNavigator(e,t)}}else this.$message.warning({content:this.$t("route.noDataFound"),key:e,duration:3})},clipboardNavigator(t,e){navigator.clipboard.writeText(e).then(()=>{this.$message.success({content:this.$t("route.linkCopied"),key:t,duration:3})}).catch(()=>{this.$message.warning({content:this.$t("route.errorTryAgain"),key:t,duration:3})})},handleTabClick(t){this.posShareTabActivated="postions_share"===t,this.routeShareTabActivated="routes_share"===t},getPositionIcon(t){switch(t){case"google":return"icon-location2";case"search":return"icon-location2";case"vehicle":return"icon-car";case"geofence":return"icon-Geotagplace";case"info":return"question-circle";default:return"icon-location2"}}}},p=d,h=i(81656),g=(0,h.A)(p,r,c,!1,null,"141c0f59",null),m=g.exports,v=function(){var t=this,e=t._self._c;return e("div",[e("div",{staticClass:"title"},[t._v(" "+t._s(""===t.routeDetail.id?t.$t("route.addRouteTitle"):t.$t("route.editRouteTitle"))+" ")]),e("a-row",{staticClass:"header",attrs:{type:"flex",align:"middle"}},[e("a-col",{attrs:{span:6}},[t._v(t._s(t.$t("route.routeName")))]),e("a-col",{attrs:{span:18}},[e("a-input",{attrs:{placeholder:t.$t("route.enterRouteName")},model:{value:t.routeDetail.name,callback:function(e){t.$set(t.routeDetail,"name",e)},expression:"routeDetail.name"}})],1)],1),e("div",{staticClass:"content"},[t.isPreviewRoute?e("a-timeline",t._l(t.displayedPreviewPositionList,function(i,o){return e("a-timeline-item",{key:`${i.name}-${o}`,staticStyle:{height:"80px",padding:"0"},attrs:{color:"info"===i.type?"#555":"green"}}
1,["info"===i.type?e("a-icon",{staticStyle:{"font-size":"14px"},attrs:{slot:"dot",type:"question-circle"},slot:"dot"}):e("icon-font",{staticStyle:{"font-size":"20px"},attrs:{slot:"dot",type:t.getPositionIcon(i.type)},slot:"dot"}),e("div",{staticClass:"item-info-container"},[e("div",{staticClass:"item-info-name"},[t._v(" "+t._s(i.name)+" ")])])],1)}),1):e("a-timeline",t._l(t.displayedPositionList,function(i,o){return e("a-timeline-item",{key:`${i.name}-${o}`,staticStyle:{height:"80px",padding:"0"},attrs:{color:"green"}},[void 0===i.type?e("a-icon",{style:{"font-size":void 0===i.type?"18px":"14px"},attrs:{slot:"dot",type:"plus-circle"},slot:"dot"}):e("icon-font",{staticStyle:{"font-size":"20px"},attrs:{slot:"dot",type:t.getPositionIcon(i.type)},slot:"dot"}),Object.keys(i).length>0?e("div",[t.editPositionIndex!==o?e("div",{staticClass:"position-list-item"},[e("div",{staticClass:"item-info-container"},[e("div",{staticClass:"item-info-name"},[t._v(" "+t._s(i.name)+" ")]),e("div",{staticClass:"item-info-action"},[e("a-icon",{attrs:{type:"form"},on:{click:function(e){return t.onEditingPosition(o)}}}),e("a-icon",{attrs:{type:"delete"},on:{click:function(e){return t.onRemovePosition(o)}}})],1)]),e("div",{staticClass:"item-switch-container"},[e("a-button",{staticClass:"item-switch",attrs:{disabled:0===o||t.displayedPositionList.length<2},on:{click:function(e){return t.onSwitchPositionList(!0,o)}}},[e("a-icon",{attrs:{type:"arrow-up"}})],1),e("a-button",{staticClass:"item-switch",attrs:{disabled:o===t.displayedPositionList.length-2},on:{click:function(e){return t.onSwitchPositionList(!1,o)}}},[e("a-icon",{attrs:{type:"arrow-down"}})],1)],1)]):e("div",[e("positionSelection",{attrs:{index:o,position:i,latlngMap:t.latlngMap},on:{onClose:t.onCloseEditPosition,onSubmit:t.onSubmitEditingPosition,onCoordinatesChange:t.onCoordinatesChange}})],1)]):e("div",[null===t.editPositionIndex?e("positionSelection",{attrs:{index:o,position:i,latlngMap:t.latlngMap},on:{onSubmit:t.onSubmitAddingPosition,onCoordinatesChange:t.onCoordinatesChange}}):t._e()],1)],1)}),1)],1),e("div",{staticClass:"footer"},[t.isPreviewRoute?e("div",{staticClass:"summary-container"},[t._v(" "+t._s(t.$t("route.totalDistance"))+" "+t._s(t.sumDistance)+" "+t._s(t.$t("route.km"))+" "+t._s(t.$t("route.totalTravelTime"))+" "+t._s(t.sumDuration)+" "+t._s(t.$t("route.minutes"))+" ")]):e("div",{staticClass:"options-btn-container"},[e("div",[e("a-switch",{attrs:{disabled:t.positionList.length<2},model:{value:t.isOptimizedActive,callback:function(e){t.isOptimizedActive=e},expression:"isOptimizedActive"}}),t._v(" "+t._s(t.$t("route.optimizeBestRoute"))+" ")],1),e("div",[e("a-switch",{attrs:{disabled:t.positionList.length<2},model:{value:t.isMilkRunActive,callback:function(e){t.isMilkRunActive=e},expression:"isMilkRunActive"}}),t._v(" "+t._s(t.$t("route.returnToFirst"))+" ")],1)]),e("div",{staticClass:"actions-btn-container"},[e("a-button",{attrs:{type:"primary",disabled:t.disableButton()},on:{click:function(e){t.isPreviewRoute?t.onClickSaveRoute():t.onClickPreviewRoute()}}},[t._v(" "+t._s(t.isPreviewRoute?t.$t("route.saveRoute"):t.$t("route.showRoute"))+" ")]),e("a-button",{on:{click:function(e){t.isPreviewRoute?t.onClickCancelPreviewRoute():t.onClickCancelRoute()}}},[t._v(" "+t._s(t.isPreviewRoute?t.$t("route.back"):t.$t("common.cancel"))+" ")])],1),t.isPreviewRoute?e("a-button",{staticClass:"share-link-btn",attrs:{type:"primary"},on:{click:()=>t.isDisplayedModal=!0}},[e("a-icon",{attrs:{type:"share-alt"}}),t._v(" "+t._s(t.$t("route.share"))+" ")],1):t._e()],1),e("a-modal",{attrs:{visible:t.isDisplayedModal,mask:!0,closable:!0,footer:!1,centered:"",width:360},on:{cancel:()=>(t.isDisplayedModal=!1,t.posShareTabActivated=!0,t.routeShareTabActivated=!1)}},[e("div",{staticClass:"share-modal"},[e("div",{staticClass:"navigation-container"},[e("div",{class:["modal-title","navigation-button",t.posShareTabActivated&&"active"],on:{click:function(e){return t.handleTabClick("postions_share")}}},[t._v(t._s(t.$t("route.sharePosition")))]),e("div",{class:["modal-title","navigation-button",t.routeShareTabActivated&&"active"],on:{click:function(e){return t.handleTabClick("routes_share")}}}
1,[t._v(t._s(t.$t("route.shareRoute")))])]),t.posShareTabActivated?e("div",{staticStyle:{width:"100%"}},[e("div",{class:t.positionList.length>4?"modal-routes-container":"modal-routes-container-fixed"},t._l(t.positionList,function(i,n){return e("div",{key:n,staticClass:"modal-route-item-layout"},[e("div",{staticClass:"route-item-input"},[t._v(" "+t._s(i.name)+" ")]),e("a-button",{staticClass:"route-item-btn",on:{click:function(e){return t.shareSinglePosUrl(i,!0)}}},[e("img",{attrs:{src:o(),alt:"copy-icon"}})]),e("a-button",{staticClass:"route-item-btn",on:{click:function(e){return t.shareSinglePosUrl(i,!1)}}},[e("img",{attrs:{src:s(),alt:"gmap-pin"}})])],1)}),0),e("a-button",{staticClass:"modal-share_all-btn",on:{click:function(e){return t.shareAllPosUrl(!0)}}},[e("img",{attrs:{src:o(),alt:""}}),e("span",[t._v(t._s(t.$t("route.copyAllLinks")))])])],1):t._e(),t.routeShareTabActivated?e("div",{staticClass:"modal-btn-container"},[e("a-button",{staticClass:"modal-btn",attrs:{size:"large"},on:{click:function(e){return t.shareLinkUrl(!1)}}},[e("img",{attrs:{src:s(),alt:"gmap-pin"}}),e("span",{staticStyle:{"margin-left":"8px"}},[t._v("Google Map")])]),e("a-button",{staticClass:"modal-btn",attrs:{icon:"copy",size:"large"},on:{click:function(e){return t.shareLinkUrl(!0)}}},[t._v(" "+t._s(t.$t("route.copyLink"))+" ")]),t.canShareNative()?e("a-button",{staticClass:"modal-btn",attrs:{icon:"share-alt",size:"large"},on:{click:function(e){return t.otherShare()}}},[t._v(" "+t._s(t.$t("route.shareTo"))+" ")]):t._e()],1):t._e()])])],1)},y=[],f=(i(22489),function(){var t=this,e=t._self._c;return e("div",{staticClass:"container"},[Object.keys(t.position).length>0?e("div",{staticClass:"cancel-btn-container"},[e("button",{staticClass:"cancel-btn",on:{click:()=>this.$emit("onClose")}},[e("a-icon",{attrs:{type:"close",danger:""}})],1)]):t._e(),e("div",{staticStyle:{width:"50px"}},[t._v(" "+t._s(Object.keys(t.position).length>0?"แก้ไข":"เพิ่มจาก")+" ")]),e("div",{staticClass:"option-selecting-container"},[e("a-select",{staticClass:"select-route-input",on:{change:t.onSelectingOption},model:{value:t.selectedOption,callback:function(e){t.selectedOption=e},expression:"selectedOption"}},t._l(t.options,function(i,o){return e("a-select-option",{key:o,attrs:{value:i.value}},[t._v(" "+t._s(i.label)+" ")])}),1),e("div",{staticClass:"input-container"},[t.selectedOption===t.positionType.Coordinates?e("div",[e("a-input",{staticStyle:{width:"150px"},attrs:{placeholder:t.labelTypes.Coordinates},on:{input:t.onInputCoordinates},model:{value:t.inputText,callback:function(e){t.inputText=e},expression:"inputText"}})],1):t.selectedOption===t.positionType.Place?e("div",[e("vue-google-autocomplete",{ref:"locationSearch",staticClass:"type-place",attrs:{id:"map",placeholder:"ค้นหา",size:"small",country:["th"],"enable-geolocation":!0,types:null},on:{inputChange:t.onInputPlaceChange,placechanged:t.onPlaceChanged}})],1):t.selectedOption===t.positionType.Vehicle?e("div",[e("a-select",{staticStyle:{width:"150px","border-radius":"30px"},attrs:{"show-arrow":!1,showSearch:"",placeholder:"เลือกพาหนะ",optionFilterProp:"children",filterOption:t.filterOption,defaultValue:""===t.inputText?void 0:t.inputText},on:{change:t.onSelectVehicle}},t._l(t.vehicles,function(i){return e("a-select-option",{key:i.id,attrs:{value:i.plate_number}},[t._v(" "+t._s(i.plate_number.trim())+" ( "+t._s(i.name.trim())+" ) ")])}),1)],1):t.selectedOption===t.positionType.Geofence?e("div",[e("a-select",{staticStyle:{width:"150px","border-radius":"30px"},attrs:{"show-arrow":!1,showSearch:"",placeholder:"เลือกสถานี",optionFilterProp:"children",filterOption:t.filterOption,defaultValue:""===t.inputText?void 0:t.inputText},on:{change:t.onSelectGeofence,dropdownVisibleChange:t.onDropdownVisibleChange,search:t.onSearchGeofence}},t._l(t.resultList,function(i){return e("a-select-option",{key:i.id,attrs:{value:i.id}},[t._v(" "+t._s(i.name)+" ")])}),1)],1):t._e(),e("div",{staticClass:"action"},[e("a-button",{attrs:{type:"primary",disabled:t.disableSaveButton(),icon:Object.keys(t.position).length>0?"save":"plus"},on:{click:t.onClick}})],1)])],1)])}),C=[],b=(i(74423),i(20116),i(43527)),_=i(95353);const w=Object.freeze({Coordinates:"latlng",Place:"search",Vehicle:"vehicle",Geofence:"geofence"}),k=Object.freeze({Coordinates:"ละติจูด, ลองจิจูด",Place:"สถานที่",Vehicle:"พาหนะ",Geofence:"สถานี"});var $={name:"positionSelection",components:{"vue-google-autocomplete":b.A},props:{index:Number,position:Object,latlngMap:String},data(){return{labelTypes:k,positionType:w,options:[{value:w.Coordinates,label:k.Coordinates},{value:w.Place,label:k.Place},{value:w.Vehicle,label:k.Vehicle},{value:w.Geofence,label:k.Geofence}],selectedOption:w.Coordinates,inputText:"",coordinates:{lat:0,lng:0},resultList:[]}},watch:{latlngMap(t){this.selectedOption===w.Coordinates&&(this.inputText=t,this.onInputCoordinates())}},computed:{...(0,_.aH)({geofences:t=>t.geofence.geofences,selectedGroup:t=>t.authen.selectedGroup}),...(0,_.L8)({vehicles:"vehicle/vehicles"})},async mounted(){0===this.geofences.length&&this.getAllGeofences([this.selectedGroup.id]),Object.keys(this.position).length>0&&(this.inputText=this.position.name,this.selectedOption=this.position.type,this.coordinates.lat=this.position.lat,this.coordinates.lng=this.position.lng,this.selectedOption===w.Place&&(this.$refs.locationSearch||this.$nextTick(()=>{this.$refs.locationSearch.updateCoordinates(this.coordinates)})))},methods:{...(0,_.i0)({getAllGeofences:"geofence/getAllGeofences"}),disableSaveButton(){return!(this.coordinates.lat>0&&this.coordinates.lng>0)},onClick(){this.$emit("onSubmit",{index:this.index,data:{lat:parseFloat(this.coordinates.lat),lng:parseFloat(this.coordinates.lng),name:this.inputText,type:this.selectedOption}})}
1,setCoordinates(t){this.coordinates={lat:parseFloat(t.lat),lng:parseFloat(t.lng)},this.$emit("onCoordinatesChange",this.coordinates)},validateCoordinates(t){const e=/^[-+]?([1-8]?\d(\.\d+)?|90(\.0+)?)/,i=/^[-+]?(180(\.0+)?|((1[0-7]\d)|([1-9]?\d))(\.\d+)?)$/,o=e.test(t.lat),s=i.test(t.lng);return o&&s},onSelectingOption(t){this.selectedOption=t,this.inputText="",this.coordinates={lat:0,lng:0}},onPlaceChanged(t,e){this.inputText=e.formatted_address,this.setCoordinates({lat:t.latitude,lng:t.longitude})},onInputPlaceChange(t){0===t.newVal.length&&this.setCoordinates({lat:0,lng:0})},onInputCoordinates(){const t=this.inputText.split(",");if(2===t.length){const e={lat:t[0].trim(),lng:t[1].trim()};if(this.validateCoordinates(e))return this.setCoordinates(e)}this.setCoordinates({lat:0,lng:0})},onSelectVehicle(t){const e=this.vehicles.find(e=>e.plate_number===t);if(e){this.inputText=`${e.plate_number.trim()} ( ${e.name.trim()} )`;let t={lat:0,lng:0};e.last_position_json&&(t.lat=e.last_position_json.latitude/1e7,t.lng=e.last_position_json.longitude/1e7),this.setCoordinates(t)}},onSelectGeofence(t){const e=this.geofences.find(e=>e.id===t);if(e){this.inputText=e.name;let t={lat:0,lng:0};e.Positions.length>0&&(t=e.Positions[0]),this.setCoordinates(t)}},onSearchGeofence(t){this.resultList=""===t?[...this.geofences.slice(0,50)]:[...this.geofences.filter(e=>e.name.toLowerCase().includes(t.toLowerCase()))]},filterOption(t,e){return e.componentOptions.children[0].text.toLowerCase().indexOf(t.toLowerCase())>=0},onDropdownVisibleChange(t){t&&(this.resultList=[...this.geofences.slice(0,50)])}}},L=$,R=(0,h.A)(L,f,C,!1,null,"a1ed6790",null),P=R.exports,S={props:{route:Object,googleMap:Object,directionsDisplay:Object,calculateRouteDirection:Function,calculateInfoRouteList:Function,onCreateWaypoints:Function,onRemoveWaypoints:Function,latlngMap:String},components:{IconFont:u.rP,positionSelection:P},data(){return{displayedPositionList:[{}],displayedPreviewPositionList:[],isDisplayedModal:!1,routeDetail:{id:"",name:"",positionList:[]},previewWaypoints:[],sumDistance:0,sumDuration:0,isPreviewRoute:!1,editPositionIndex:null,isMilkRunActive:!1,isOptimizedActive:!1,posShareTabActivated:!0,routeShareTabActivated:!1}},watch:{async positionList(t){this.displayedPositionList=[...t,{}],this.previewWaypoints=[...t].map((t,e)=>({marker:new window.google.maps.Marker({position:{lat:t.lat,lng:t.lng},label:{text:(e+1).toString(),color:"white"}}),info:{label:t.name}})),t.length>0&&this.googleMap.$mapPromise.then(e=>{let i=new window.google.maps.LatLngBounds;for(let o=0;o<t.length;o++)i.extend(t[o]);e.fitBounds(i),e.panTo(i.getCenter())})},previewWaypoints(t,e){e.length>0&&this.onRemoveWaypoints(e),t.length>0&&this.onCreateWaypoints(t,this.googleMap.$mapObject)},isPreviewRoute(t){this.previewWaypoints.length>0&&(t?this.onRemoveWaypoints(this.previewWaypoints):this.onCreateWaypoints(this.previewWaypoints,this.googleMap.$mapObject))}},mounted(){this.directionsDisplay&&this.directionsDisplay.setMap(null);const t=[...this.route.positionList];t.length>0&&t[0].lat===t[t.length-1].lat&&t[0].lng===t[t.length-1].lng&&(t.pop(),this.isMilkRunActive=!0),this.routeDetail.positionList=t,this.routeDetail.id=this.route.id,this.routeDetail.name=this.route.name},computed:{positionList(){return this.routeDetail.positionList},displayPreviewPositionList(){return this.displayedPreviewPositionList.filter((t,e)=>e%2===0)}},methods:{canShareNative(){return!!navigator.share},otherShare(){const t="updatable";let e="https://www.google.com/maps/dir/";if(this.displayPreviewPositionList.length>0){for(let t=0;t<this.displayPreviewPositionList.length;t++)e=e+this.displayPreviewPositionList[t].lat+","+this.displayPreviewPositionList[t].lng+"/";navigator.share?navigator.share({title:this.$t("route.shareLocationTo"),url:e}).then(()=>{}).catch(console.error):this.visibleShareModal=!0}else this.$message.warning({content:this.$t("route.noDataFound"),key:t,duration:3})},shareLinkUrl(t){const e="updatable";let i="https://www.google.com/maps/dir/";if(this.displayPreviewPositionList.length>0){for(let t=0;t<this.displayPreviewPositionList.length;t++)i=i+this.displayPreviewPositionList[t].lat+","+this.displayPreviewPositionList[t].lng+"/";!1===t?window.open(i,"_blank"):this.clipboardNavigator(e,i)}else this.$message.warning({content:this.$t("route.noDataFound"),key:e,duration:3})},shareSinglePosUrl(t,e){const i="updateable",o=`https://www.google.com/maps/search/?api=1&query=${t.lat},${t.lng}`;this.positionList.length>0?!1===e?window.open(o,"_blank"):this.clipboardNavigator(i,o):this.$message.warning({content:this.$t("route.noDataFound"),key:i,duration:3})},shareAllPosUrl(t){const e="updateable";let i=[];if(this.positionList.length>0){for(let t=0;t<this.positionList.length;t++){const e=`https://www.google.com/maps/search/?api=1&query=${this.positionList[t].lat},${this.positionList[t].lng}`;i.push(`${t+1}. ${this.positionList[t].name} ${e}\n`)}if(t){const t=i.join("");this.clipboardNavigator(e,t)}}else this.$message.warning({content:this.$t("route.noDataFound"),key:e,duration:3})},clipboardNavigator(t,e){navigator.clipboard.writeText(e).then(()=>{this.$message.success({content:this.$t("route.linkCopied"),key:t,duration:3})}).catch(()=>{this.$message.warning({content:this.$t("route.errorTryAgain"),key:t,duration:3})})},getPositionIcon(t){switch(t){case"google":return"icon-location2";case"search":return"icon-location2";case"vehicle":return"icon-car";case"geofence":return"icon-Geotagplace";case"info":return"question-circle";default:return"icon-location2"}},onSubmitAddingPosition(t){const e=t.data;this.routeDetail.positionList.push(e)},async onSubmitEditingPosition(t){const e=t.data,i=t.index,o=[...this.positionList];o[i]=e,this.routeDetail.positionList=o,this.onCloseEditPosition()},async onSwitchPositionList(t,e){this.onCloseEditPosition();let i=t?e-1:e+1,o=[...this.positionList];[o[e],o[i]]=[o[i],o[e]],this.routeDetail.positionList=o},async onRemovePosition(t){const e=[...this.positionList];e.splice(t,1),this.routeDetail.positionList=e},onEditingPosition(t){this.editPositionIndex=t},onCloseEditPosition(){this.editPositionIndex=null},async onClickPreviewRoute(){const t=[...this.positionList];this.isMilkRunActive&&t.push(this.positionList[0]);const e=await this.calculateRouteDirection(t,this.isOptimizedActive);if(e){const i=e.routes[0].legs;if(i.length>0){let t=0,e=0;
1i.forEach(i=>{t+=parseFloat(i.distance.value),e+=parseFloat(i.duration.value)}),this.sumDistance=(t/1e3).toFixed(2),this.sumDuration=Math.ceil(e/60)}this.directionsDisplay.setMap(this.googleMap.$mapObject),this.directionsDisplay.setDirections(e),this.displayedPreviewPositionList=this.calculateInfoRouteList(e.routes[0],t),this.isPreviewRoute=!0,this.onCloseEditPosition()}},onClickCancelPreviewRoute(){this.directionsDisplay&&this.directionsDisplay.setMap(null),this.displayedPreviewPositionList=[],this.sumDistance=0,this.sumDuration=0,this.isPreviewRoute=!1,this.$emit("clearWaypoints")},onClickSaveRoute(){this.$emit("onSave",{id:this.routeDetail.id,name:this.routeDetail.name,positions:this.displayedPreviewPositionList.filter((t,e)=>e%2===0)})},onClickCancelRoute(){this.$emit("onClose")},disableButton(){return this.isPreviewRoute?""===this.routeDetail.name:this.positionList.length<2},onCoordinatesChange(t){t.lat>0&&t.lng>0&&this.googleMap.$mapPromise.then(e=>{e.panTo(t),e.setZoom(17)})},handleTabClick(t){this.posShareTabActivated="postions_share"===t,this.routeShareTabActivated="routes_share"===t}},destroyed(){this.previewWaypoints.length>0&&this.onRemoveWaypoints(this.previewWaypoints)}},x=S,D=(0,h.A)(x,v,y,!1,null,"475d9d3e",null),T=D.exports,A={name:"trip",components:{defaultLayout:l.A,IconFont:u.rP,routeInfo:m,routeForm:T},data(){return{displayRoutesList:!0,isReadOnly:!1,selectedRoute:{id:"",name:"",positionList:[]},displayedPositionList:[{}],routeWaypoints:[],mapZoom:12,directionsService:null,directionsDisplay:null,clickedLat:"",clickedLng:""}}
1,watch:{routeWaypoints(t,e){e.length>0&&this.onRemoveWaypoints(e),t.length>0&&this.onCreateWaypoints(t,this.$refs.googleMap.$mapObject)}},mounted(){this.routes<=0&&this.getAllRoutes([this.selectedGroup.id])},computed:{...(0,_.aH)({selectedGroup:t=>t.authen.selectedGroup,routes:t=>t.route.routes})},methods:{...(0,_.i0)({createRoute:"route/createRoute",updateRoute:"route/updateRoute",deleteRoute:"route/deleteRoute",getAllRoutes:"route/getAllRoutes"}),async calculateRouteDirection(t,e){return null===this.directionsService&&(this.directionsService=new window.google.maps.DirectionsService),null===this.directionsDisplay&&(this.directionsDisplay=new window.google.maps.DirectionsRenderer({suppressMarkers:!0})),await this.directionsService.route({origin:t[0],destination:t[t.length-1],travelMode:"DRIVING",optimizeWaypoints:e,waypoints:[...t].splice(1,t.length-2).map(t=>({location:t,stopover:!0}))},(t,e)=>"OK"===e?t:null)},calculateInfoRouteList(t,e){const i=[...e],o=[];let s=[i.shift()];for(let n=0;n<i.length-1;n++)s.push(i[t.waypoint_order[n]]);s.push(i[i.length-1]),e=[];for(let n=0;n<s.length-1;n++)e.push(s[n]),e.push({name:this.$t("route.distanceAndTime",{distance:t.legs[n].distance.text,time:t.legs[n].duration.text}),type:"info"});return e.push(s[s.length-1]),t.legs.forEach((t,e)=>{0===e&&o.push({lat:t.start_location.lat(),lng:t.start_location.lng()}),o.push({lat:t.end_location.lat(),lng:t.end_location.lng()})}),this.routeWaypoints=[...o].map((t,i)=>({marker:new window.google.maps.Marker({position:{lat:t.lat,lng:t.lng},label:{text:(i+1).toString(),color:"white"}}),info:{label:e[2*i].name}})),e},setDisplayRoutesList(t){this.displayRoutesList=t},async setSelectedRoute(t){this.selectedRoute={id:t.id,name:t.Name,positionList:t.Positions},this.isReadOnly=!0,this.setDisplayRoutesList(!1)},onChangeTab(){this.setDisplayRoutesList(!this.displayRoutesList),this.isReadOnly=!1,this.resetSelectedRoute(),this.directionsDisplay&&this.directionsDisplay.setMap(null)},async onClickSave(t){if(""===t.id){const e=await this.createRoute({Name:t.name,positions:t.positions,org:this.selectedGroup.id});e?(this.getAllRoutes([this.selectedGroup.id]),this.setSelectedRoute(e.data.createRouting.routing),this.$message.success(this.$t("route.savedSuccess"),5)):this.$message.warning(this.$t("route.saveError"),5)}else{const e=await this.updateRoute({routeID:t.id,Name:t.name,positions:t.positions});e?(this.getAllRoutes([this.selectedGroup.id]),this.setSelectedRoute(e.data.updateRouting.routing),this.$message.success(this.$t("route.savedSuccess"),5)):this.$message.warning(this.$t("route.saveError"),5)}},async onRemoveRoute(t){const e=await this.deleteRoute(t);e?(this.getAllRoutes([this.selectedGroup.id]),this.$message.success(this.$t("route.deleteSuccess"),5)):this.$message.warning(this.$t("route.deleteError"),5)},onClickClose(){""===this.selectedRoute.id?this.displayRoutesList=!0:this.isReadOnly=!0},onClickEditIcon(){this.isReadOnly=!1,this.onClearRouteWaypoints()},onClearRouteWaypoints(){this.routeWaypoints=[]},onCreateWaypoints(t,e){t.forEach(t=>{const i=new window.google.maps.InfoWindow({content:t.info.label});t.marker.addListener("click",()=>{i.open({anchor:t.marker,map:e})}),t.marker.setMap(e)})},onRemoveWaypoints(t){t.forEach(t=>{t.marker.setMap(null)})},resetSelectedRoute(){this.selectedRoute={id:"",name:"",positionList:[]},this.displayedPositionList=[{}],this.onClearRouteWaypoints()},clickPosition(t){this.clickedLat=parseFloat(t.latLng.lat().toFixed(7)),this.clickedLng=parseFloat(t.latLng.lng().toFixed(7))}}},O=A,M=(0,h.A)(O,n,a,!1,null,"bd8e80f8",null),I=M.exports}}]);
2//# sourceMappingURL=route.6c459428.js.map

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.