@@ -1351,7 +1351,7 @@ export class LeafletRenderer extends MarkdownRenderChild {
1351
1351
} > {
1352
1352
let latitude = lat ;
1353
1353
let longitude = long ;
1354
- let coords : [ number , number ] = [ undefined , undefined ] ;
1354
+ const coords : [ number , number ] = [ undefined , undefined ] ;
1355
1355
let zoomDistance , file ;
1356
1356
if ( typeof coordinates == "string" && coordinates . length ) {
1357
1357
file = this . plugin . app . metadataCache . getFirstLinkpathDest (
@@ -1375,39 +1375,32 @@ export class LeafletRenderer extends MarkdownRenderChild {
1375
1375
map . log ( `Using supplied coordinates [${ latitude } , ${ longitude } ]` ) ;
1376
1376
}
1377
1377
1378
- let err : boolean = false ;
1379
- const convertedLatitude = Number ( ` ${ latitude } ` ?. split ( "%" ) . shift ( ) ) ;
1380
- const convertedLongitude = Number ( ` ${ longitude } ` ?. split ( "%" ) . shift ( ) ) ;
1378
+ let convertedLatitude : number ;
1379
+ let convertedLongitude : number ;
1380
+
1381
1381
try {
1382
- coords = [ convertedLatitude , convertedLongitude ] ;
1383
- } catch ( e ) {
1384
- err = true ;
1382
+ convertedLatitude = Number ( ` ${ latitude } ` ?. split ( "%" , 1 ) [ 0 ] ) ;
1383
+ } catch ( error ) {
1384
+ new Notice ( t ( "There was an error with the provided latitude. Using default." ) ) ;
1385
1385
}
1386
-
1387
- if (
1388
- ( ! isNaN ( convertedLatitude ) || ! isNaN ( convertedLongitude ) ) &&
1389
- ( err || isNaN ( coords [ 0 ] ) || isNaN ( coords [ 1 ] ) )
1390
- ) {
1391
- new Notice (
1392
- t (
1393
- "There was an error with the provided latitude and longitude. Using defaults."
1394
- )
1395
- ) ;
1386
+ if ( ! isNaN ( convertedLatitude ) ) {
1387
+ coords [ 0 ] = convertedLatitude ;
1388
+ } else if ( map . type === "real" ) {
1389
+ coords [ 0 ] = this . plugin . data . lat ;
1390
+ } else {
1391
+ coords [ 0 ] = 50 ;
1396
1392
}
1397
- if ( map . type != "real" ) {
1398
- if ( ! isNaN ( convertedLatitude ) || isNaN ( coords [ 0 ] ) ) {
1399
- coords [ 0 ] = 50 ;
1400
- }
1401
- if ( ! isNaN ( convertedLongitude ) || isNaN ( coords [ 1 ] ) ) {
1402
- coords [ 1 ] = 50 ;
1403
- }
1393
+ try {
1394
+ convertedLongitude = Number ( `${ longitude } ` ?. split ( "%" , 1 ) [ 0 ] ) ;
1395
+ } catch ( error ) {
1396
+ new Notice ( t ( "There was an error with the provided longitude. Using default." ) ) ;
1397
+ }
1398
+ if ( ! isNaN ( convertedLongitude ) ) {
1399
+ coords [ 1 ] = convertedLongitude ;
1400
+ } else if ( map . type === "real" ) {
1401
+ coords [ 1 ] = this . plugin . data . long ;
1404
1402
} else {
1405
- if ( ! isNaN ( convertedLatitude ) || isNaN ( coords [ 0 ] ) ) {
1406
- coords [ 0 ] = this . plugin . data . lat ;
1407
- }
1408
- if ( ! isNaN ( convertedLongitude ) || isNaN ( coords [ 1 ] ) ) {
1409
- coords [ 1 ] = this . plugin . data . long ;
1410
- }
1403
+ coords [ 1 ] = 50 ;
1411
1404
}
1412
1405
1413
1406
return { coords, zoomDistance, file } ;
0 commit comments