if("undefined"==typeof jQuery)throw new Error("Bootstrap's JavaScript requires jQuery");!function(r,i){r.widget("psc.googlegeocode",{options:{mapId:"map",longId:"Longitude",latId:"Latitude",addrValidationId:"AddressError",formValidId:"ValidationSummary",locComboId:"LocationCombo"},marker:null,gmap:null,_create:function(){this.element.addClass("googlegeocode"),this.gmap=new i.Map(document.getElementById(this.options.mapId),{zoom:16,center:{lat:48.862854,lng:2.2056466}});var o=this;this.element.rules("add",{remote:{url:"https://maps.googleapis.com/maps/api/geocode/json",type:"get",data:{sensor:!1,address:function(){return o.element.val()}},dataType:"json",dataFilter:function(t){r("#"+o.options.locComboId).html("");var e=JSON.parse(t);return e.results.forEach(function(t){t.formatted_address!==o.element.val()&&r("
  • "+t.formatted_address+"
  • ").data("geoloc",t).click(function(){o.chooseLoc("user",t)}).css("cursor","pointer").appendTo(r("#"+o.options.locComboId))}),"OK"===e.status&&1==e.results.length},error:function(){return!1}}})},chooseLoc:function(t,e){"user"===t&&this.element.val(e.formatted_address);var o=e.geometry.location,a=new Number(o.lat),n=new Number(o.lng);return r(document.getElementById(this.options.latId)).val(a.toLocaleString("en")),r(document.getElementById(this.options.longId)).val(n.toLocaleString("en")),this.gmap.setCenter(o),this.marker&&this.marker.setMap(null),this.marker=new i.Marker({map:this.gmap,draggable:!0,animation:i.Animation.DROP,position:o}),i.event.addListener(this.marker,"dragend",function(){var t=this.marker.getPosition();r("#"+this.options.latId).val(t.lat),r("#"+this.options.longId).val(t.lng)}),this.element.valid(),r("#"+this.options.addrValidationId).empty(),r("#"+this.options.formValidId).empty(),r("#"+this.options.locComboId).empty(),this}})}(jQuery,google.maps);