Skip to content

Commit ef3754d

Browse files
committed
fix(map): fix zoom in and out issue
1 parent 726b6a0 commit ef3754d

File tree

4 files changed

+26
-10
lines changed

4 files changed

+26
-10
lines changed

src/components/SimpleMap.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
$emit('onZoomIn');
2828
}
2929
"
30-
class="w-8 h-8 border-crisiscleanup-dark-100 border-t border-l border-r bg-white shadow-xl text-xl text-crisiscleanup-dark-400"
30+
class="my-2 w-12 h-12 border-crisiscleanup-dark-100 border-t border-l border-r bg-white shadow-xl text-xl text-crisiscleanup-dark-400"
3131
/>
3232
<base-button
3333
text=""
@@ -42,7 +42,7 @@
4242
$emit('onZoomOut');
4343
}
4444
"
45-
class="w-8 h-8 border border-crisiscleanup-dark-100 bg-white shadow-xl text-xl text-crisiscleanup-dark-400"
45+
class="w-12 h-12 border border-crisiscleanup-dark-100 bg-white shadow-xl text-xl text-crisiscleanup-dark-400"
4646
/>
4747
</div>
4848
<base-button
@@ -66,7 +66,7 @@
6666
"
6767
icon="tree"
6868
icon-size="lg"
69-
class="w-8 h-8 border my-1 border-crisiscleanup-dark-100 bg-white shadow-xl text-crisiscleanup-dark-400"
69+
class="w-12 h-12 border my-1 border-crisiscleanup-dark-100 bg-white shadow-xl text-crisiscleanup-dark-400"
7070
/>
7171
<base-button
7272
v-tooltip="{
@@ -89,7 +89,7 @@
8989
$emit('onZoomIncidentCenter');
9090
}
9191
"
92-
class="w-8 h-8 border border-crisiscleanup-dark-100 my-1 bg-white shadow-xl text-crisiscleanup-dark-400"
92+
class="w-12 h-12 border border-crisiscleanup-dark-100 my-1 bg-white shadow-xl text-crisiscleanup-dark-400"
9393
/>
9494
</div>
9595
<WorksiteLegend

src/components/tags/LanguageTag.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export default defineComponent({
2929
},
3030
},
3131
setup(props) {
32+
console.log(props.languageId)
3233
const { theme } = config;
3334
const language = ref(null);
3435
const styles = computed(() => {

src/hooks/live/useLiveChart.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export default function useLiveChart(
2525
function getHeight() {
2626
const chartContainer = d3.select(`#${chartId}`);
2727
if (chartContainer) {
28-
return Number(chartContainer.style('height').slice(0, -2)) || 0;
28+
return Number(chartContainer.style('height')?.slice(0, -2)) || 0;
2929
}
3030

3131
return 0;

src/pages/phone/PhoneSystem.vue

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,7 +1080,7 @@ import {
10801080
INTERACTIVE_ZOOM_LEVEL,
10811081
} from '@/constants';
10821082
import { averageGeolocation } from '@/utils/map';
1083-
import type { MapUtils } from '@/hooks/worksite/useLiveMap';
1083+
import type { MapUtils } from '@/hooks/worksite/useWorksiteMap';
10841084
import { useCurrentUser } from '@/hooks';
10851085
import PhoneOverlay from '@/components/phone/PhoneOverlay.vue';
10861086
import useAcl from '@/hooks/useAcl';
@@ -1695,19 +1695,34 @@ export default defineComponent({
16951695
}
16961696
16971697
function zoomIn() {
1698-
mapUtils.value?.getMap().zoomIn();
1698+
mapUtils.value!.getMap().zoomIn();
16991699
}
17001700
17011701
function zoomOut() {
1702-
mapUtils.value?.getMap().zoomOut();
1702+
mapUtils.value!.getMap().zoomOut();
1703+
}
1704+
1705+
function fitLocation(location: Location) {
1706+
mapUtils.value!.fitLocation(location);
17031707
}
17041708
17051709
function getIncidentCenter() {
17061710
const { incident_center } = Incident.find(
17071711
currentIncidentId.value,
17081712
) as Incident;
1709-
if (incident_center) {
1710-
return [incident_center.coordinates[1], incident_center.coordinates[0]];
1713+
if (locationModels.length > 0) {
1714+
for (const location of locationModels) {
1715+
fitLocation(location);
1716+
}
1717+
} else {
1718+
const center = averageGeolocation(
1719+
mapUtils.value
1720+
?.getPixiContainer()
1721+
?.children.map((marker) => [marker.x, marker.y]),
1722+
);
1723+
if (center.latitude && center.longitude) {
1724+
mapUtils.value.getMap().setView([center.latitude, center.longitude], 6);
1725+
}
17111726
}
17121727
return [35.746_512_259_918_5, -96.411_509_631_256_56];
17131728
}

0 commit comments

Comments
 (0)