8000 feat: add style & onEachFeature function for geojson in geolocation controller by blaggacao · Pull Request #21322 · frappe/frappe · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat: add style & onEachFeature function for geojson in geolocation controller #21322

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion frappe/public/js/frappe/form/controls/geolocation.js
8000
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@ frappe.ui.form.ControlGeolocation = class ControlGeolocation extends frappe.ui.f
this.clear_editable_layers();

const data_layers = new L.FeatureGroup().addLayer(
L.geoJson(JSON.parse(value), { pointToLayer: this.point_to_layer })
L.geoJson(JSON.parse(value), {
pointToLayer: this.point_to_layer,
style: this.set_style,
onEachFeature: this.on_each_feature,
})
);
this.add_non_group_layers(data_layers, this.editableLayers);
this.editableLayers.addTo(this.map);
Expand All @@ -70,6 +74,8 @@ frappe.ui.form.ControlGeolocation = class ControlGeolocation extends frappe.ui.f
/**
* Defines custom rules for how geoJSON data is rendered on the map.
*
* Can be inherited in custom map controllers.
*
* @param {Object} geoJsonPoint - The geoJSON object to be rendered on the map.
* @param {Object} latlng - The latitude and longitude where the geoJSON data should be rendered on the map.
* @returns {Object} - Returns the Leaflet layer object to be rendered on the map.
Expand All @@ -85,6 +91,28 @@ frappe.ui.form.ControlGeolocation = class ControlGeolocation extends frappe.ui.f
}
}

/**
* Defines custom styles for how geoJSON Line and LineString data is rendered on the map.
*
* Can be inherited in custom map controllers.
*
* @param {Object} geoJsonFeature - The geoJSON object to be rendered on the map.
* @returns {Object} - Returns the style object for the geoJSON object.
*/
set_style(geoJsonFeature) {
return {};
}

/**
* Is called after each feature is rendered and styles, can be used to attache popups, tooltips and other events
*
* Can be inherited in custom map controllers.
*
* @param {Object} feature - The leaflet object representing a geojson feature.
* @param {Object} layer - The leaflet layer object.
*/
on_each_feature(feature, layer) {}

bind_leaflet_map() {
const circleToGeoJSON = L.Circle.prototype.toGeoJSON;
L.Circle.include({
Expand Down
0