Initialize map on geolocation without location

Hi,

i am using a geolocation for delivery addresses - frappe is initializing the map with location services, which i dont want. How can i overwrite the function from:

/frappe/public/js/frappe/form/controls/geolocation.js

frappe.ui.form.ControlGeolocation = frappe.ui.form.ControlData.extend({
make_map() {
	this.bind_leaflet_map();
	this.bind_leaflet_draw_control();
	this.bind_leaflet_locate_control();
	this.bind_leaflet_refresh_button();
},
})

with a custom function in my delivery_address.js so make_map() only calls:

bind_leaflet_map();
bind_leaflet_draw_control();

so i dont have to overwrite the frappe file.

i searched the forum and tried prototype, which sounded promising but didnt work - i still new to js, so im not sure if i am approaching this the right way

frappe.ui.form.on('Delivery Address', {

setup: function(frm)  {
	//override frappe.ui.form.ControlGeolocation.make_map 
	frappe.ui.form.ControlGeolocation.prototype.make_map = function() {			
		this.bind_leaflet_map();
		this.bind_leaflet_draw_control();			
	}
},

Any help would be appreciated!

okay so i found the solution - on “setup” was already to late - the overwrite just had to happen earlier!

1 Like