Skip to content

Commit

Permalink
Merge pull request #463 from OpenSPP/fix-gis-view
Browse files Browse the repository at this point in the history
improved gis view
  • Loading branch information
reichie020212 authored Jun 27, 2024
2 parents 3a3989a + 941bc66 commit 2004f4b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
8 changes: 8 additions & 0 deletions spp_base_gis/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,14 @@ def get_edit_info_for_gis_column(self, column):
"default_center": view.default_center,
}

@api.model
def get_edit_info_for_gis(self):
view = self._get_gis_view()
return {
"default_zoom": view.default_zoom,
"default_center": view.default_center,
}

@api.model
def get_fields_of_type(self, field_type: str | list) -> list:
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,15 @@ export class GisRenderer extends Component {

async renderMap() {
let defaultCenter = [124.74037191, 7.83479874];
let defaultZoom = 6;
const editInfo = await this.orm.call(this.props.data._config.resModel, "get_edit_info_for_gis", []);

if (editInfo.default_center) {
defaultCenter = JSON.parse(editInfo.default_center);
}
if (editInfo.default_zoom) {
defaultZoom = editInfo.default_zoom;
}

if (this.featureCollection.features.length > 0) {
const centroid = turf.centroid(this.featureCollection);
Expand All @@ -172,7 +181,7 @@ export class GisRenderer extends Component {
container: "olmap",
style: defaultMapStyle,
center: defaultCenter,
zoom: 6,
zoom: defaultZoom,
});

this.map.on("styledata", () => {
Expand Down

0 comments on commit 2004f4b

Please sign in to comment.