@@ -15,52 +15,47 @@ var accessLocation;
15
15
document . getElementById ( "getLocation" ) . onclick = ( ) => {
16
16
17
17
18
- shareLocation = navigator . geolocation . watchPosition (
19
- function ( position ) {
20
- accessLocation = true
21
-
22
- document . getElementById ( "alert" ) . innerHTML = `
23
- <div class="alert alert-success"
24
- role="alert"> يتم عرض موقعك الان في خريطة بشكل مباشر </div> `
25
- document . getElementById ( "getLocation" ) . innerHTML = "إيقاف مشاركة"
26
- isLive = true
27
-
28
- document . getElementById ( "map" ) . innerHTML =
29
- `<iframe height="400" width="100%" src="https://www.openstreetmap.org/export/embed.html?bbox=${ position . coords . longitude } ,${ position . coords . latitude } &;layer=mapnik"> </iframe> `
30
- } ,
31
- function ( error ) {
32
- switch ( error . code ) {
33
- case error . PERMISSION_DENIED :
34
- document . getElementById ( "alert" ) . innerHTML = ` <div class="alert alert-danger mt-3 mb-3" role="alert">
35
- لقد قمت برفض وصول إلى موقعك , يرجى محاولة وموافقة
36
- </div> `
37
- break ;
38
-
39
- case error . UNKNOWN_ERROR :
40
- document . getElementById ( "alert" ) . innerHTML = `<div class="alert alert-danger mt-3 mb-3" role="alert"> حدث خطا غير معروف </div> `
41
-
42
- break ;
43
-
18
+
19
+ if ( isLive === false ) {
20
+
21
+ shareLocation = navigator . geolocation . watchPosition (
22
+ function ( position ) {
23
+ accessLocation = true
24
+
25
+ document . getElementById ( "alert" ) . innerHTML = `
26
+ <div class="alert alert-success"
27
+ role="alert"> يتم عرض موقعك الان في خريطة بشكل مباشر </div> `
28
+ document . getElementById ( "getLocation" ) . innerHTML = "إيقاف مشاركة"
29
+ isLive = true
30
+
31
+ document . getElementById ( "map" ) . innerHTML =
32
+ `<iframe height="400" width="100%" src="https://www.openstreetmap.org/export/embed.html?bbox=${ position . coords . longitude } ,${ position . coords . latitude } &;layer=mapnik"> </iframe> `
33
+ } ,
34
+ function ( error ) {
35
+ switch ( error . code ) {
36
+ case error . PERMISSION_DENIED :
37
+ document . getElementById ( "alert" ) . innerHTML = ` <div class="alert alert-danger mt-3 mb-3" role="alert">
38
+ لقد قمت برفض وصول إلى موقعك , يرجى محاولة وموافقة
39
+ </div> `
40
+ break ;
41
+
42
+ case error . UNKNOWN_ERROR :
43
+ document . getElementById ( "alert" ) . innerHTML = `<div class="alert alert-danger mt-3 mb-3" role="alert"> حدث خطا غير معروف </div> `
44
+
45
+ break ;
46
+
47
+ }
44
48
}
45
- }
46
- )
47
-
48
- if ( isLive === false && accessLocation === true ) {
49
-
50
- document . getElementById ( "alert" ) . innerHTML = `
51
- <div class="alert alert-success"
52
- role="alert"> يتم عرض موقعك الان في خريطة بشكل مباشر </div> `
53
-
54
- document . getElementById ( "getLocation" ) . innerHTML = "إيقاف مشاركة"
55
- isLive = true
49
+ )
50
+
56
51
} else if ( isLive === true && accessLocation === true ) {
57
-
52
+ console . log ( "removed" + navigator . geolocation . clearWatch ( shareLocation ) )
58
53
59
54
document . getElementById ( "alert" ) . innerHTML = `
60
55
<div class="alert alert-success"
61
56
role="alert"> تم إيقاف مشاركة موقع بنجاح
62
57
</div> `
63
-
58
+ console . log ( shareLocation )
64
59
navigator . geolocation . clearWatch ( shareLocation ) ;
65
60
document . getElementById ( "getLocation" ) . innerHTML = "عرض موقعي"
66
61
isLive = false
0 commit comments