Skip to content

Conversation

@amish1188
Copy link
Contributor

@amish1188 amish1188 commented Dec 17, 2025

Jeg har brukt leaflet istedenfor statisk kart bilde. Jeg merket at det blir enklere å kalkulere senter (siden jeg må hente gejson med async) i en separat metoden og så justere senter etter kart er lastet. Kan være det var feil, men hvis dere har et bedre forslag på hvordan å løse det bare kjør på.

Jeg har bestemt å endre høyden på kart på små skjermer men kanskje vi kunne ha bare 200px på store og? Hva syns dere?

Også jeg har inkludert kart i ion-content så at den har samme padding som skjema. Hvis dere mener kart burde spre seg over hele skjerm bredde det kan fikses men da må jeg lage en dummy div under kart for da må kart bli absolute og skjema fortsatt må vise på riktig høyden i hensyn til kart.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 11 comments.

add map to plan detail

update

asd
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

.map((f) => f.coordinates as [number, number]);

const flatCoords: [number, number][] = [...lineCoords, ...pointCoords];

Copy link

Copilot AI Dec 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method does not handle the case where there are no valid coordinates (empty flatCoords array). Calling L.latLngBounds() with an empty array will throw an error. Add a check to ensure flatCoords has at least one coordinate before calling fitBounds.

Suggested change
if (flatCoords.length === 0) {
return;
}

Copilot uses AI. Check for mistakes.
Comment on lines 31 to 53
@Component({
selector: 'app-plan.page',
templateUrl: './plan.page.html',
schemas: [CUSTOM_ELEMENTS_SCHEMA],
imports: [DatePipe, IonContent, IonToolbar, IonBackButton, IonTitle, IonHeader, IonButtons, TranslatePipe],
imports: [
DatePipe,
IonContent,
IonToolbar,
IonBackButton,
IonTitle,
IonHeader,
IonButtons,
TranslatePipe,
LeafletModule,
],
providers: [
{
provide: MapLayersService,
useClass: isPlatform('hybrid') ? OfflineCapableMapLayersService : MapLayersService,
},
],
styleUrl: './plan.page.css',
})
Copy link

Copilot AI Dec 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The component is missing the changeDetection: ChangeDetectionStrategy.OnPush setting in the decorator. This is a best practice for Angular components, especially when using signals for state management. The sibling component plans.page.ts includes this setting, and it should be added here for consistency and optimal performance.

Copilot generated this review using guidance from repository custom instructions.
Comment on lines +108 to +133
const lineFeatures = geoJSON.features.map((f) => {
if (f.geometry && f.geometry.type === 'LineString') {
return f.geometry as LineString;
}
return null;
});
const pointFeatures = geoJSON.features.map((f) => {
if (f.geometry && f.geometry.type === 'Point') {
return f.geometry as Point;
}
return null;
});

const lineCoords: [number, number][] = lineFeatures
.filter((f): f is LineString => f !== null)
.flatMap((f) => f.coordinates as [number, number][]);

const pointCoords: [number, number][] = pointFeatures
.filter((f): f is Point => f !== null)
.map((f) => f.coordinates as [number, number]);

const flatCoords: [number, number][] = [...lineCoords, ...pointCoords];

const latLngs = flatCoords.map(([lng, lat]) => L.latLng(lat, lng));

this.map.fitBounds(L.latLngBounds(latLngs), { padding: [5, 5] });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Jeg tror dette kan forenkles til:

Suggested change
const lineFeatures = geoJSON.features.map((f) => {
if (f.geometry && f.geometry.type === 'LineString') {
return f.geometry as LineString;
}
return null;
});
const pointFeatures = geoJSON.features.map((f) => {
if (f.geometry && f.geometry.type === 'Point') {
return f.geometry as Point;
}
return null;
});
const lineCoords: [number, number][] = lineFeatures
.filter((f): f is LineString => f !== null)
.flatMap((f) => f.coordinates as [number, number][]);
const pointCoords: [number, number][] = pointFeatures
.filter((f): f is Point => f !== null)
.map((f) => f.coordinates as [number, number]);
const flatCoords: [number, number][] = [...lineCoords, ...pointCoords];
const latLngs = flatCoords.map(([lng, lat]) => L.latLng(lat, lng));
this.map.fitBounds(L.latLngBounds(latLngs), { padding: [5, 5] });
this.map.fitBounds(geoJsonLayer.getBounds(), { padding: [5, 5] });

Eventuelt med sjekk på om bounds fra geoJsonLayer.getBounds() er valid (bounds.isValid())

Copy link
Contributor

@jorgkv jorgkv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Så lenge vi fikser dette med å bruke geoJsonLayer.getBounds() i stedet for all den egne logikken som er skrevet for dette, så kan vi ta inn denne, tenker jeg.

@jorgkv
Copy link
Contributor

jorgkv commented Dec 19, 2025

Eventuelt så er det også mulig å lage en bedre visning for web / store skjermer. Kartet kunne tatt opp (nesten) hele skjermen, og metadata bare blitt vist ved siden av / under kartet.

@gruble gruble force-pushed the feature/RO-13-turplaner branch 2 times, most recently from e299446 to e878b4a Compare December 19, 2025 16:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants