var Bizgaze; (function (Bizgaze) { let Apps; (function (Apps) { let Hrms; (function (Hrms) { let Controls; (function (Controls) { class geofencingmap extends Unibase.Platform.Core.BaseComponent { init(formpropertyid, prop, callback) { var _id = $(".formValidate:visible").attr("id"); var slt = _id.split('_'); var map11 = $('#locationcontrol_' + formpropertyid); map11.geocomplete({ details: "form.form_" + slt[1] }); var instance = this; instance.loadControlSettings(prop.ControlJsonText, prop.FormPropertyId); instance.loadPropertySettings(prop.PropertySettings, prop.FormPropertyId); } loadControl(containerid, prop) { var html = '
' + '
' + ''; $("#" + containerid).html(html); var latd = 0; var lgtd = 0; $('#hfLattitude').val(latd); $('#hfLongitude').val(lgtd); $("#lbl_coordinates").html("latd : " + latd + ", lgtd : " + lgtd); Bizgaze.Apps.Hrms.Controls.geofencingmap.Instance().loadMap(latd, lgtd, prop.FormPropertyId); } loadMap(latd, lgtd, formpropertyid) { var instance = this; var myLatlng = new google.maps.LatLng(latd, lgtd); var mapOptions = { zoom: 15, center: myLatlng, draggable: true, }; let radius = Number($("#div_radius").find(".number_radius").val()); var myCity = new google.maps.Circle({ center: myLatlng, radius: radius, strokeColor: "#87C1FF", strokeOpacity: 0.8, strokeWeight: 2, fillColor: "#87C1FF", fillOpacity: 0.4 }); var map = new google.maps.Map(document.getElementById("GeofencingMap"), mapOptions); myCity.setMap(map); var marker = new google.maps.Marker({ position: myLatlng, title: "", }); marker.setMap(map); var url = "https://maps.googleapis.com/maps/api/geocode/json?latlng=" + latd + "," + lgtd + "&key=" + _mapsettings.key() + "&sensor=false"; var xhr = Bizgaze.Apps.Hrms.Controls.geofencingmap.Instance().createCORSRequest2('Get', url); if (!xhr) { bootbox.alert('CORS not supported'); return; } xhr.onload = function () { var text = xhr.responseText; var json = JSON.parse(text); instance.addressData = []; instance.addressData = json.results; $("#locationcontrol_" + formpropertyid).val(json.results[0].formatted_address); }; xhr.onerror = function () { bootbox.alert('Woops, there was an error making the request.'); }; } getLocation(formpropertyid) { var ContactAddressId = Number($("#hf_AutocompleteId").val()); var latitude = 0; var longitude = 0; this.fileCacheHelper.addCacheFiles(["apps/crm/contacts/managers/contactmanager.js"]); Bizgaze.Apps.Crm.Contacts.Managers.ContactManager.Instance().getAddressById(ContactAddressId).then(function (response) { latitude = response.result.AddrLatd; longitude = response.result.AddrLgtd; if (latitude == 0 || longitude == 0 || latitude == null || longitude == null) { MessageHelper.Instance().showError("You are Selected Branch Geo Tagging is not Enabled longitude : " + longitude + " , latitude : " + latitude, 'div_ErrorMessage_' + $('#' + Unibase.Platform.Helpers.NavigationHelper.Instance().getLastContainerId()).find('#hf_FormId').val()); } $("#div_latitude").find(".number_latitude").val(+latitude); $("#div_longitude").find(".number_longitude").val(+longitude); $("#lbl_coordinates").html("latd : " + latitude + ", lgtd : " + longitude); Bizgaze.Apps.Hrms.Controls.geofencingmap.Instance().loadMap(latitude, longitude, formpropertyid); }); } createCORSRequest2(method, url) { let XDomainRequest; var xhr = new XMLHttpRequest(); if ("withCredentials" in xhr) { xhr.open(method, url, true); } else if (typeof XDomainRequest != "undefined") { xhr = new XDomainRequest(); xhr.open(method, url); } else { xhr = null; } return xhr; } loadControlSettings(controlsettingjson, formpropertyid) { return null; } loadPropertySettings(propertysettings, formpropertyid) { return null; } bindEditFormDetails(formpropertyid, propval, DocPropertyName) { return null; } static Instance() { if (this.instance === undefined) { this.instance = new geofencingmap(); } return this.instance; } } Controls.geofencingmap = geofencingmap; })(Controls = Hrms.Controls || (Hrms.Controls = {})); })(Hrms = Apps.Hrms || (Apps.Hrms = {})); })(Apps = Bizgaze.Apps || (Bizgaze.Apps = {})); })(Bizgaze || (Bizgaze = {}));