Skip to content

Commit

Permalink
fix(map): fix zoom in and out issue
Browse files Browse the repository at this point in the history
  • Loading branch information
pablo014 committed Feb 6, 2025
1 parent 64007d3 commit 9f74fc5
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 10 deletions.
8 changes: 4 additions & 4 deletions src/components/SimpleMap.vue
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ watch(showingLegend, async (newValue) => {
emit('onZoomIn');
}
"
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"
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"
/>
<base-button
text=""
Expand All @@ -108,7 +108,7 @@ watch(showingLegend, async (newValue) => {
emit('onZoomOut');
}
"
class="w-8 h-8 border border-crisiscleanup-dark-100 bg-white shadow-xl text-xl text-crisiscleanup-dark-400"
class="w-12 h-12 border border-crisiscleanup-dark-100 bg-white shadow-xl text-xl text-crisiscleanup-dark-400"
/>
</div>
<base-button
Expand All @@ -131,7 +131,7 @@ watch(showingLegend, async (newValue) => {
"
icon="tree"
icon-size="lg"
class="w-8 h-8 border my-1 border-crisiscleanup-dark-100 bg-white shadow-xl text-crisiscleanup-dark-400"
class="w-12 h-12 border my-1 border-crisiscleanup-dark-100 bg-white shadow-xl text-crisiscleanup-dark-400"
/>
<base-button
v-tooltip="{
Expand All @@ -153,7 +153,7 @@ watch(showingLegend, async (newValue) => {
emit('onZoomIncidentCenter');
}
"
class="w-8 h-8 border border-crisiscleanup-dark-100 my-1 bg-white shadow-xl text-crisiscleanup-dark-400"
class="w-12 h-12 border border-crisiscleanup-dark-100 my-1 bg-white shadow-xl text-crisiscleanup-dark-400"
/>
<base-button
v-if="props.showMapLayerToggle"
Expand Down
1 change: 1 addition & 0 deletions src/components/tags/LanguageTag.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export default defineComponent({
},
},
setup(props) {
console.log(props.languageId)
const { theme } = config;
const language = ref(null);
const styles = computed(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/live/useLiveChart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default function useLiveChart(
function getHeight() {
const chartContainer = d3.select(`#${chartId}`);
if (chartContainer) {
return Number(chartContainer.style('height').slice(0, -2)) || 0;
return Number(chartContainer.style('height')?.slice(0, -2)) || 0;
}

return 0;
Expand Down
25 changes: 20 additions & 5 deletions src/pages/phone/PhoneSystem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ import {
INTERACTIVE_ZOOM_LEVEL,
} from '@/constants';
import { averageGeolocation } from '@/utils/map';
import type { MapUtils } from '@/hooks/worksite/useLiveMap';
import type { MapUtils } from '@/hooks/worksite/useWorksiteMap';
import { useCurrentUser } from '@/hooks';
import PhoneOverlay from '@/components/phone/PhoneOverlay.vue';
import useAcl from '@/hooks/useAcl';
Expand Down Expand Up @@ -1277,19 +1277,34 @@ export default defineComponent({
}
function zoomIn() {
mapUtils.value?.getMap().zoomIn();
mapUtils.value!.getMap().zoomIn();
}
function zoomOut() {
mapUtils.value?.getMap().zoomOut();
mapUtils.value!.getMap().zoomOut();
}
function fitLocation(location: Location) {
mapUtils.value!.fitLocation(location);
}
function getIncidentCenter() {
const { incident_center } = Incident.find(
currentIncidentId.value,
) as Incident;
if (incident_center) {
return [incident_center.coordinates[1], incident_center.coordinates[0]];
if (locationModels.length > 0) {
for (const location of locationModels) {
fitLocation(location);
}
} else {
const center = averageGeolocation(
mapUtils.value
?.getPixiContainer()
?.children.map((marker) => [marker.x, marker.y]),
);
if (center.latitude && center.longitude) {
mapUtils.value.getMap().setView([center.latitude, center.longitude], 6);
}
}
return [35.746_512_259_918_5, -96.411_509_631_256_56];
}
Expand Down

0 comments on commit 9f74fc5

Please sign in to comment.