11import type { Map } from "leaflet" ;
2- import library_loader from "../services/library_loader.js" ;
2+ import L from "leaflet" ;
3+ import "leaflet/dist/leaflet.css" ;
34import NoteContextAwareWidget from "./note_context_aware_widget.js" ;
45
56const TPL = `\
@@ -21,7 +22,7 @@ const TPL = `\
2122 <div class="geo-map-container"></div>
2223</div>` ;
2324
24- export type Leaflet = typeof import ( "leaflet" ) ;
25+ export type Leaflet = typeof L ;
2526export type InitCallback = ( L : Leaflet ) => void ;
2627
2728export default class GeoMapWidget extends NoteContextAwareWidget {
@@ -40,23 +41,18 @@ export default class GeoMapWidget extends NoteContextAwareWidget {
4041
4142 this . $container = this . $widget . find ( ".geo-map-container" ) ;
4243
43- library_loader . requireLibrary ( library_loader . LEAFLET ) . then ( async ( ) => {
44- const L = ( await import ( "leaflet" ) ) . default ;
45-
46- const map = L . map ( this . $container [ 0 ] , {
47- worldCopyJump : true
48- } ) ;
44+ const map = L . map ( this . $container [ 0 ] , {
45+ worldCopyJump : true
46+ } ) ;
4947
50- this . map = map ;
51- if ( this . initCallback ) {
52- this . initCallback ( L ) ;
53- }
48+ this . map = map ;
49+ if ( this . initCallback ) {
50+ this . initCallback ( L ) ;
51+ }
5452
55- L . tileLayer ( "https://tile.openstreetmap.org/{z}/{x}/{y}.png" , {
56- attribution : '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors' ,
57- detectRetina : true
58- } ) . addTo ( map ) ;
59- } ) ;
53+ L . tileLayer ( "https://tile.openstreetmap.org/{z}/{x}/{y}.png" , {
54+ attribution : '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors' ,
55+ detectRetina : true
56+ } ) . addTo ( map ) ;
6057 }
61-
6258}
0 commit comments