Skip to content

Commit

Permalink
fix(geolocation): load destination location image, custom layer style…
Browse files Browse the repository at this point in the history
… load
  • Loading branch information
NSUWAL123 committed Dec 13, 2024
1 parent 381f82f commit 3d21603
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/mapper/src/lib/components/map/geolocation.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import { getAlertStore } from '$store/common.svelte.ts';
import { getEntitiesStatusStore } from '$store/entities.svelte.ts';
import { getCommonStore } from '$store/common.svelte.ts';
import { layers } from '$assets/maplibre-directions.ts';
import locationUrl from '$assets/images/location.png';
interface Props {
map: maplibregl.Map | undefined;
Expand All @@ -29,7 +31,20 @@
// initialize MapLibreGlDirections
$effect(() => {
if (map) {
directions = new MapLibreGlDirections(map);
// load location image for destination
map.loadImage(locationUrl).then((image) => {
if (image) {
map.addImage('location', image.data);
}
});
directions = new MapLibreGlDirections(map, {
// custom styled direction layer
layers,
sensitiveWaypointLayers: ['maplibre-gl-directions-waypoint'],
sensitiveSnappointLayers: ['maplibre-gl-directions-snappoint'],
sensitiveRoutelineLayers: ['maplibre-gl-directions-routeline'],
sensitiveAltRoutelineLayers: ['maplibre-gl-directions-alt-routeline'],
});
directions.interactive = false;
map.addControl(new LoadingIndicatorControl(directions));
directions.clear();
Expand Down

0 comments on commit 3d21603

Please sign in to comment.