@@ -21,7 +21,7 @@ basemap.addTo(map);
21
21
var coordinatesdiv = new L . Control ( ) ;
22
22
coordinatesdiv . onAdd = function ( map ) {
23
23
this . _div = L . DomUtil . create ( 'div' , 'coordinates-info' ) ;
24
- this . _div . innerHTML = 'Center Coordinates<hr><div id="coordinates">-2.61119,118.65234</div><button id="copy" onclick="CopyToClipboard()">Copy Coordinates</button><br><br><div id="zoom">Zoom: 5</div><hr>Bounding Box<hr><div id="bbox">Move the map</div>' ;
24
+ this . _div . innerHTML = 'Center Coordinates<hr><div id="coordinates">-2.61119,118.65234</div><button id="copy" onclick="CopyToClipboard()">Copy Coordinates</button><br><br><div id="zoom">Zoom: 5</div><hr>Bounding Box<hr><div id="bbox">Move the map</div><div id="bbox-copy"></div><button id="copy" onclick="CopyToClipboardBbox()">Copy Bounding Box</button> ' ;
25
25
return this . _div ;
26
26
} ;
27
27
coordinatesdiv . addTo ( map ) ;
@@ -44,6 +44,7 @@ function mapMovement (e) {
44
44
document . getElementById ( "coordinates" ) . innerHTML = mapcenter . lat . toFixed ( precisionLatLng ) + "," + mapcenter . lng . toFixed ( precisionLatLng ) ;
45
45
document . getElementById ( "zoom" ) . innerHTML = "Zoom: " + map . getZoom ( ) ;
46
46
document . getElementById ( "bbox" ) . innerHTML = "Left : " + map . getBounds ( ) . getWest ( ) . toFixed ( precisionBbox ) + "<br>Bottom: " + map . getBounds ( ) . getSouth ( ) . toFixed ( precisionBbox ) + "<br>Right : " + map . getBounds ( ) . getEast ( ) . toFixed ( precisionBbox ) + "<br>Top : " + map . getBounds ( ) . getNorth ( ) . toFixed ( precisionBbox ) ;
47
+ document . getElementById ( "bbox-copy" ) . innerHTML = map . getBounds ( ) . getWest ( ) . toFixed ( precisionBbox ) + "," + map . getBounds ( ) . getSouth ( ) . toFixed ( precisionBbox ) + "," + map . getBounds ( ) . getEast ( ) . toFixed ( precisionBbox ) + "," + map . getBounds ( ) . getNorth ( ) . toFixed ( precisionBbox ) ;
47
48
48
49
marker . remove ( ) ;
49
50
@@ -66,4 +67,21 @@ function CopyToClipboard() {
66
67
timer : 1000 ,
67
68
backdrop : false ,
68
69
} )
70
+ }
71
+
72
+ function CopyToClipboardBbox ( ) {
73
+ var text = document . getElementById ( "bbox-copy" ) ;
74
+ var r = document . createRange ( ) ;
75
+ r . selectNode ( text ) ;
76
+ window . getSelection ( ) . removeAllRanges ( ) ;
77
+ window . getSelection ( ) . addRange ( r ) ;
78
+ document . execCommand ( 'copy' ) ;
79
+ window . getSelection ( ) . removeAllRanges ( ) ;
80
+ Swal . fire ( {
81
+ icon : 'success' ,
82
+ text : 'Bounding box copied to clipboard' ,
83
+ showConfirmButton : false ,
84
+ timer : 1000 ,
85
+ backdrop : false ,
86
+ } )
69
87
}
0 commit comments