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 May 21, 2024
1 parent 873f706 commit a7e5855
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 @@ -27,7 +27,7 @@
$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"

Check warning on line 30 in src/components/SimpleMap.vue

View check run for this annotation

Codecov / codecov/patch

src/components/SimpleMap.vue#L30

Added line #L30 was not covered by tests
/>
<base-button
text=""
Expand All @@ -42,7 +42,7 @@
$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"

Check warning on line 45 in src/components/SimpleMap.vue

View check run for this annotation

Codecov / codecov/patch

src/components/SimpleMap.vue#L45

Added line #L45 was not covered by tests
/>
</div>
<base-button
Expand All @@ -66,7 +66,7 @@
"
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"

Check warning on line 69 in src/components/SimpleMap.vue

View check run for this annotation

Codecov / codecov/patch

src/components/SimpleMap.vue#L69

Added line #L69 was not covered by tests
/>
<base-button
v-tooltip="{
Expand All @@ -89,7 +89,7 @@
$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"

Check warning on line 92 in src/components/SimpleMap.vue

View check run for this annotation

Codecov / codecov/patch

src/components/SimpleMap.vue#L92

Added line #L92 was not covered by tests
/>
</div>
<WorksiteLegend
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)

Check failure on line 32 in src/components/tags/LanguageTag.vue

View workflow job for this annotation

GitHub Actions / Lint 💅

Insert `;`

Check warning on line 32 in src/components/tags/LanguageTag.vue

View check run for this annotation

Codecov / codecov/patch

src/components/tags/LanguageTag.vue#L32

Added line #L32 was not covered by tests
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;

Check warning on line 28 in src/hooks/live/useLiveChart.ts

View check run for this annotation

Codecov / codecov/patch

src/hooks/live/useLiveChart.ts#L28

Added line #L28 was not covered by tests
}

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 @@ -1081,7 +1081,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';

Check warning on line 1084 in src/pages/phone/PhoneSystem.vue

View check run for this annotation

Codecov / codecov/patch

src/pages/phone/PhoneSystem.vue#L1084

Added line #L1084 was not covered by tests
import { useCurrentUser } from '@/hooks';
import PhoneOverlay from '@/components/phone/PhoneOverlay.vue';
import useAcl from '@/hooks/useAcl';
Expand Down Expand Up @@ -1696,19 +1696,34 @@ export default defineComponent({
}
function zoomIn() {
mapUtils.value?.getMap().zoomIn();
mapUtils.value!.getMap().zoomIn();

Check warning on line 1699 in src/pages/phone/PhoneSystem.vue

View check run for this annotation

Codecov / codecov/patch

src/pages/phone/PhoneSystem.vue#L1699

Added line #L1699 was not covered by tests
}
function zoomOut() {
mapUtils.value?.getMap().zoomOut();
mapUtils.value!.getMap().zoomOut();
}
function fitLocation(location: Location) {
mapUtils.value!.fitLocation(location);

Check warning on line 1707 in src/pages/phone/PhoneSystem.vue

View check run for this annotation

Codecov / codecov/patch

src/pages/phone/PhoneSystem.vue#L1703-L1707

Added lines #L1703 - L1707 were not covered by tests
}
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);
}

Check warning on line 1726 in src/pages/phone/PhoneSystem.vue

View check run for this annotation

Codecov / codecov/patch

src/pages/phone/PhoneSystem.vue#L1714-L1726

Added lines #L1714 - L1726 were not covered by tests
}
return [35.746_512_259_918_5, -96.411_509_631_256_56];
}
Expand Down

0 comments on commit a7e5855

Please sign in to comment.