Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mapper Frontend: routing to feature #1963

Open
wants to merge 22 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
a395f4c
feat(entities): store selected entity coordinate to store
NSUWAL123 Dec 9, 2024
bffb490
feat(maplibre-gl-directions): package add for maplibre routing feature
NSUWAL123 Dec 9, 2024
12dea50
feat(main): store clicked entity coordinate to store
NSUWAL123 Dec 9, 2024
dd2a82e
feat(geolocation): route path add from user location to selected entity
NSUWAL123 Dec 9, 2024
cfaa556
fix(merge): merge conflict solve
NSUWAL123 Dec 11, 2024
2065f46
fix(icon): icon add
NSUWAL123 Dec 11, 2024
021f791
fix(button): add css for button type link
NSUWAL123 Dec 11, 2024
53a9a72
feat(dialog-entities-actions): navigate btn add, other button syling …
NSUWAL123 Dec 11, 2024
1a43ea6
fix(geolocation): ts type add
NSUWAL123 Dec 12, 2024
181c4a6
Merge branch 'development' of github.com:hotosm/fmtm into feat/maplib…
NSUWAL123 Dec 12, 2024
39976fb
feat(entities): entityToNavigate & toggleGeolocation state add to store
NSUWAL123 Dec 12, 2024
668ef7f
fix(dialog-entities-actions): navigate to entity function trigger on …
NSUWAL123 Dec 12, 2024
b7954c1
refactor(main): geolocation status handle on child component, select …
NSUWAL123 Dec 12, 2024
c3a53af
fix(geolocation): handle toggle geolocation on geolocation component …
NSUWAL123 Dec 12, 2024
a49376c
feat(location): location img add
NSUWAL123 Dec 13, 2024
f29f108
fix(main): upate entity fill-color
NSUWAL123 Dec 13, 2024
381f82f
feat(maplibre-directions): custom styling for direction routes
NSUWAL123 Dec 13, 2024
3d21603
fix(geolocation): load destination location image, custom layer style…
NSUWAL123 Dec 13, 2024
d8acb4d
Merge branch 'development' of github.com:hotosm/fmtm into feat/maplib…
NSUWAL123 Dec 16, 2024
bc821e9
fix(entities): turn off geolocation by default
NSUWAL123 Dec 16, 2024
b39ecfa
feat(geolocation): show tooltip popup to users indicating geolocation…
NSUWAL123 Dec 16, 2024
3bb4df4
fix(main): remove zoom buttons from map
NSUWAL123 Dec 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/mapper/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"@electric-sql/client": "^0.8.0",
"@electric-sql/pglite": "^0.2.14",
"@hotosm/ui": "0.2.0-b5",
"@maplibre/maplibre-gl-directions": "^0.7.1",
"@tiptap/core": "^2.10.3",
"@tiptap/pm": "^2.10.3",
"@tiptap/starter-kit": "^2.10.3",
Expand Down
32 changes: 32 additions & 0 deletions src/mapper/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added src/mapper/src/assets/images/location.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
68 changes: 68 additions & 0 deletions src/mapper/src/assets/maplibre-directions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
// snapline: line from waypoint to road
export const layers = [
{
id: 'maplibre-gl-directions-snapline',
type: 'line',
source: 'maplibre-gl-directions',
layout: {
'line-cap': 'round',
'line-join': 'round',
},
paint: {
'line-dasharray': [2, 2],
'line-color': '#000000',
'line-opacity': 0.65,
'line-width': 2,
},
filter: ['==', ['get', 'type'], 'SNAPLINE'],
},

// primary route
{
id: 'maplibre-gl-directions-routeline',
type: 'line',
source: 'maplibre-gl-directions',
layout: {
'line-cap': 'butt',
'line-join': 'round',
},
paint: {
'line-width': 12,
'line-opacity': 1,
'line-color': '#4285f4',
},
filter: ['==', ['get', 'route'], 'SELECTED'],
},

// alternative route
{
id: 'maplibre-gl-directions-alt-routeline',
type: 'line',
source: 'maplibre-gl-directions',
layout: {
'line-cap': 'butt',
'line-join': 'round',
},
paint: {
'line-width': 12,
'line-opacity': 0.8,
'line-color': '#547fff',
},
filter: ['==', ['get', 'route'], 'ALT'],
},

// only apply icon-style to the destination waypoint as we have icon for the origin
{
id: 'maplibre-gl-directions-waypoint',
type: 'symbol',
source: 'maplibre-gl-directions',
layout: {
'icon-image': 'location',
'icon-anchor': 'bottom',
'icon-ignore-placement': true,
'icon-overlap': 'always',
'icon-size': 0.5,
},
filter: ['all', ['==', ['get', 'type'], 'WAYPOINT'], ['==', ['get', 'category'], 'DESTINATION']],
},
];
75 changes: 56 additions & 19 deletions src/mapper/src/lib/components/dialog-entities-actions.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
const selectedEntity = $derived(
entitiesStore.entitiesStatusList?.find((entity) => entity.osmid === selectedEntityOsmId),
);
const selectedEntityCoordinate = $derived(entitiesStore.selectedEntityCoordinate);
const entityToNavigate = $derived(entitiesStore.entityToNavigate);

const mapFeature = () => {
const xformId = projectData?.odk_form_id;
Expand All @@ -43,6 +45,13 @@
alertStore.setAlert({ message: 'Requires a mobile phone with ODK Collect.', variant: 'warning' });
}
};

const navigateToEntity = () => {
if (!entitiesStore.toggleGeolocation) {
entitiesStore.setToggleGeolocation(true);
}
entitiesStore.setEntityToNavigate(selectedEntityCoordinate);
};
</script>

{#if isTaskActionModalOpen && selectedTab === 'map' && selectedEntity}
Expand All @@ -68,7 +77,6 @@
<div class="flex items-center justify-between">
<p class="text-[#333] text-xl font-barlow-semibold">Feature {selectedEntity?.osmid}</p>
<sl-button
loading={entitiesStore.syncEntityStatusLoading}
onclick={async () => {
await entitiesStore.syncEntityStatus(projectData?.id);
}}
Expand All @@ -78,8 +86,14 @@
role="button"
tabindex="0"
size="small"
class="secondary w-fit ml-auto"
class="link w-fit ml-auto"
disabled={entitiesStore.syncEntityStatusLoading}
>
<hot-icon
slot="prefix"
name="arrow-repeat"
class={`!text-[1rem] cursor-pointer duration-200 ${entitiesStore.syncEntityStatusLoading && 'animate-spin'}`}
></hot-icon>
<span class="font-barlow-medium text-SM uppercase">SYNC STATUS</span>
</sl-button>
</div>
Expand All @@ -92,24 +106,47 @@
</p>
</div>
{#if selectedEntity?.status !== 'SURVEY_SUBMITTED'}
<sl-button
loading={entitiesStore.updateEntityStatusLoading}
variant="default"
size="small"
class="primary"
onclick={() => {
mapFeature();
}}
onkeydown={(e: KeyboardEvent) => {
if (e.key === 'Enter') {
<div class="flex gap-2">
<sl-button
disabled={entityToNavigate?.entityId === selectedEntity?.osmid}
variant="default"
size="small"
class="secondary flex-grow"
onclick={() => {
navigateToEntity();
}}
onkeydown={(e: KeyboardEvent) => {
if (e.key === 'Enter') {
navigateToEntity();
}
}}
role="button"
tabindex="0"
>
<hot-icon slot="prefix" name="direction" class="!text-[1rem] cursor-pointer duration-200"></hot-icon>
<span class="font-barlow-medium text-sm">NAVIGATE HERE</span>
</sl-button>
<sl-button
loading={entitiesStore.updateEntityStatusLoading}
variant="default"
size="small"
class="primary flex-grow"
onclick={() => {
mapFeature();
}
}}
role="button"
tabindex="0"
>
<span class="font-barlow-medium text-sm">MAP FEATURE IN ODK</span>
</sl-button>
}}
onkeydown={(e: KeyboardEvent) => {
if (e.key === 'Enter') {
mapFeature();
}
}}
role="button"
tabindex="0"
>
<hot-icon slot="prefix" name="location" class="!text-[1rem] text-white cursor-pointer duration-200"
></hot-icon>
<span class="font-barlow-medium text-sm">MAP FEATURE IN ODK</span>
</sl-button>
</div>
{/if}
</div>
</div>
Expand Down
Loading
Loading