Dear Team,
In Employee check in , will update data i need live location as default,employee cant able to change or mark the loaction,but now it shows as default as incorrect location and unable to save nad refersh map,how to enable save button how could i change in to live tracking
can you help me setup the script or just copy paste the script.
also i was using other scripts but no luck, i just want that when someone/myself marked the employee checkin then it should pick the location automatically, even if i marked the location after reloading the page the map returns to the default value.
The script is working fine in the Chrome and it picks the location as well. 1) However it is not working well in Microsoft Edge 2) - Is there a way to mark or circle the location automatically ?
As the map only shows the location but where exactly inside the map.
Hi, @avc
Thank you for you valuable response.
This script seems not working or I’m doing something wrong, i don’t have much ideas regarding this language.
Here is the screenshots, Please help.
code-
frappe.ui.form.on('Employee Checkin', {
onload: function(frm) {
frm.fields_dict.location.map.on('locationfound', function(e) {
var radius = e.accuracy;
var marker = L.marker(e.latlng).addTo(frm.fields_dict.location.map)
.bindPopup('I am here! Where are you?').openPopup();
var circle = L.circle(e.latlng, radius).addTo(frm.fields_dict.location.map);
frm.set_value("device_id", e.latitude + ' ' + e.longitude);
});
frm.fields_dict.location.map.on('locationerror', function(e) {
console.error('Geolocation error: ' + e.message);
});
}
});
I have attached a video link, in that you can see the new scripts does not load the location automatically and also it does not fill the field as well.
Hi, @avc
Yes it does help , but again it only shows the current location but no circle or marker, and if i click on the location icon it’s not working.
so i change the script - with this-
frappe.ui.form.on('Employee Checkin', {
refresh: function(frm) {
// Ensure Leaflet is loaded
if (typeof L === 'undefined') {
console.error('Leaflet library is not loaded.');
return;
}
// Check if the map is initialized
if (!frm.fields_dict.location.map) {
console.error('Map is not initialized.');
return;
}
frm.fields_dict.location.map.locate({setView: true});
frm.fields_dict.location.map.on('locationfound', function(e) {
var radius = e.accuracy;
// Ensure marker function exists
if (typeof L.marker !== 'function') {
console.error('L.marker is not a function.');
return;
}
var marker = L.marker(e.latlng).addTo(frm.fields_dict.location.map)
.bindPopup('I am here! Where are you?').openPopup();
var circle = L.circle(e.latlng, radius).addTo(frm.fields_dict.location.map);
frm.set_value("device_id", e.latitude + ' ' + e.longitude);
});
frm.fields_dict.location.map.on('locationerror', function(e) {
console.error('Geolocation error: ' + e.message);
});
}
});
I guess i’m missing something or the geolocation have some bugs.