Merge pull request #21734 from barredterra/refactor-geolocation
This commit is contained in:
commit
df4cc5cf2f
3 changed files with 10 additions and 5 deletions
|
|
@ -1,4 +1,4 @@
|
|||
frappe.provide("frappe.utils.utils");
|
||||
frappe.provide("frappe.utils");
|
||||
|
||||
frappe.ui.form.ControlGeolocation = class ControlGeolocation extends frappe.ui.form.ControlData {
|
||||
static horizontal = false;
|
||||
|
|
@ -35,6 +35,7 @@ frappe.ui.form.ControlGeolocation = class ControlGeolocation extends frappe.ui.f
|
|||
}
|
||||
|
||||
make_map(value) {
|
||||
this.customize_draw_controls();
|
||||
this.bind_leaflet_map();
|
||||
if (this.disabled) {
|
||||
this.map.dragging.disable();
|
||||
|
|
@ -113,7 +114,7 @@ frappe.ui.form.ControlGeolocation = class ControlGeolocation extends frappe.ui.f
|
|||
*/
|
||||
on_each_feature(feature, layer) {}
|
||||
|
||||
bind_leaflet_map() {
|
||||
customize_draw_controls() {
|
||||
const circleToGeoJSON = L.Circle.prototype.toGeoJSON;
|
||||
L.Circle.include({
|
||||
toGeoJSON: function () {
|
||||
|
|
@ -137,7 +138,10 @@ frappe.ui.form.ControlGeolocation = class ControlGeolocation extends frappe.ui.f
|
|||
},
|
||||
});
|
||||
|
||||
L.Icon.Default.imagePath = "/assets/frappe/images/leaflet/";
|
||||
L.Icon.Default.imagePath = frappe.utils.map_defaults.image_path;
|
||||
}
|
||||
|
||||
bind_leaflet_map() {
|
||||
this.map = L.map(this.map_id);
|
||||
this.map.setView(frappe.utils.map_defaults.center, frappe.utils.map_defaults.zoom);
|
||||
|
||||
|
|
|
|||
|
|
@ -1203,6 +1203,7 @@ Object.assign(frappe.utils, {
|
|||
attribution:
|
||||
'© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors',
|
||||
},
|
||||
image_path: "/assets/frappe/images/leaflet/",
|
||||
},
|
||||
|
||||
icon(icon_name, size = "sm", icon_class = "", icon_style = "", svg_class = "") {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
* frappe.views.MapView
|
||||
*/
|
||||
frappe.provide("frappe.utils.utils");
|
||||
frappe.provide("frappe.utils");
|
||||
frappe.provide("frappe.views");
|
||||
|
||||
frappe.views.MapView = class MapView extends frappe.views.ListView {
|
||||
|
|
@ -32,7 +32,7 @@ frappe.views.MapView = class MapView extends frappe.views.ListView {
|
|||
|
||||
this.$result.html(`<div id="${this.map_id}" class="map-view-container"></div>`);
|
||||
|
||||
L.Icon.Default.imagePath = "/assets/frappe/images/leaflet/";
|
||||
L.Icon.Default.imagePath = frappe.utils.map_defaults.image_path;
|
||||
this.map = L.map(this.map_id).setView(
|
||||
frappe.utils.map_defaults.center,
|
||||
frappe.utils.map_defaults.zoom
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue