Skip to content

Commit

Permalink
Merge pull request #101 from TaiBIF/feature-18_adjust_refetch_boundar…
Browse files Browse the repository at this point in the history
…y_logic

adjust shouldReloadForestBoundary logic
  • Loading branch information
Chihjen Ko committed Dec 3, 2018
2 parents 2167608 + 38f5def commit 8812ec6
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions src/pages/index/views/Project.vue
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@
:center="mapInfo.center"
:options="mapInfo.options"
@update:bounds="centerUpdated"
@update:zoom="zoomUpdated"
>
<l-control-zoom :position="'topleft'" />
<l-tile-layer
:url="mapInfo.url"
:attribution="mapInfo.attribution"
Expand Down Expand Up @@ -388,7 +388,6 @@ import {
LMap,
LTileLayer,
LMarker,
LControlZoom,
LTooltip,
LCircle,
LLayerGroup,
Expand Down Expand Up @@ -476,7 +475,7 @@ export default {
mapInfo: {
zoom: 11,
options: {
zoomControl: false,
zoomControl: true,
},
center: L.latLng(25.039202, 121.819413),
url: 'http://{s}.tile.osm.org/{z}/{x}/{y}.png',
Expand Down Expand Up @@ -612,7 +611,6 @@ export default {
components: {
LMap,
LTileLayer,
LControlZoom,
LMarker,
LPolygon,
LCircle,
Expand Down Expand Up @@ -948,10 +946,21 @@ export default {
if (!this.mapInfo || !this.mapInfo.center) {
return false;
}
if (this.mapInfo.zoom < 9) {
// console.log('zoom < 9');
return false;
}
const { lat, lng } = this.mapInfo.center;
const { decimalLatitude, decimalLongitude } = this.getForestBoundaryParam;
// TODO: set change limit for reload forestBoundary
if (lat == decimalLatitude && lng === decimalLongitude) {
if (
Math.abs(lat - decimalLatitude) < 0.05 ||
Math.abs(lng - decimalLongitude) < 0.05
) {
// console.log(
// 'move range below 0.05',
// lat - decimalLatitude,
// lng - decimalLongitude,
// );
return false;
}
this.getForestBoundaryParam = {
Expand All @@ -977,6 +986,9 @@ export default {
centerUpdated() {
this.loadForestBoundaryByMapCenter();
},
zoomUpdated(e) {
this.mapInfo.zoom = e;
},
},
mounted() {
this.setCurrentProject(this.$route.params.id);
Expand Down

0 comments on commit 8812ec6

Please sign in to comment.