Skip to content

Commit deff0a8

Browse files
committed
fix: latitude and longitude can be 0 (close #362)
1 parent b5f36c8 commit deff0a8

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

src/renderer/renderer.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1376,17 +1376,16 @@ export class LeafletRenderer extends MarkdownRenderChild {
13761376
}
13771377

13781378
let err: boolean = false;
1379+
const convertedLatitude = Number(`${latitude}`?.split("%").shift());
1380+
const convertedLongitude = Number(`${longitude}`?.split("%").shift());
13791381
try {
1380-
coords = [
1381-
Number(`${latitude}`?.split("%").shift()),
1382-
Number(`${longitude}`?.split("%").shift())
1383-
];
1382+
coords = [convertedLatitude, convertedLongitude];
13841383
} catch (e) {
13851384
err = true;
13861385
}
13871386

13881387
if (
1389-
(latitude || longitude) &&
1388+
(!isNaN(convertedLatitude) || !isNaN(convertedLongitude)) &&
13901389
(err || isNaN(coords[0]) || isNaN(coords[1]))
13911390
) {
13921391
new Notice(
@@ -1396,17 +1395,17 @@ export class LeafletRenderer extends MarkdownRenderChild {
13961395
);
13971396
}
13981397
if (map.type != "real") {
1399-
if (!latitude || isNaN(coords[0])) {
1398+
if (!isNaN(convertedLatitude) || isNaN(coords[0])) {
14001399
coords[0] = 50;
14011400
}
1402-
if (!longitude || isNaN(coords[1])) {
1401+
if (!isNaN(convertedLongitude) || isNaN(coords[1])) {
14031402
coords[1] = 50;
14041403
}
14051404
} else {
1406-
if (!latitude || isNaN(coords[0])) {
1405+
if (!isNaN(convertedLatitude) || isNaN(coords[0])) {
14071406
coords[0] = this.plugin.data.lat;
14081407
}
1409-
if (!longitude || isNaN(coords[1])) {
1408+
if (!isNaN(convertedLongitude) || isNaN(coords[1])) {
14101409
coords[1] = this.plugin.data.long;
14111410
}
14121411
}

0 commit comments

Comments
 (0)