-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
133 lines (112 loc) · 4.43 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
<!DOCTYPE html>
<html>
<head>
<title>ماجد تحديد الموقع - عمل علي عبدالعزيز الزبيدي</title>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<style>
/* Always set the map height explicitly to define the size of the div
* element that contains the map. */
#map {
height: 600px;
}
/* Optional: Makes the sample page fill the window. */
html,
body {
height: 400px;
margin: 0;
padding: 0;
}
.myDiv {
border: 5px outset red;
background-color: lightblue;
text-align: center;
}
.footer {
text-align: center;
}
</style>
</head>
<body>
<div class="myDiv">
<button onclick="getLocation()">توليد كود العنوان</button>
<div id="barcode"></div>
<img id="QRcode" src="">
<div id="shareLocationDiv">
<button id="shareLocation" onclick="getLocation()">مشاركة العنوان</button>
<button id="shareLocationBC" onclick="getLocation()">مشاركة الباركود</button>
</div>
</div>
<div id="map"></div>
<script>
document.getElementById("shareLocationDiv").style.display = "none";
// Note: This example requires that you consent to location sharing when
// prompted by your browser. If you see the error "The Geolocation service
// failed.", it means you probably did not give permission for the browser to
// locate you.
var map, infoWindow;
function initMap() {
map = new google.maps.Map(document.getElementById('map'), {
center: { lat: -34.397, lng: 150.644 },
zoom: 6
});
infoWindow = new google.maps.InfoWindow;
// Try HTML5 geolocation.
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function (position) {
var pos = {
lat: position.coords.latitude,
lng: position.coords.longitude
};
infoWindow.setPosition(pos);
infoWindow.setContent('تم تحديد الموقع');
infoWindow.open(map);
map.setCenter(pos);
}, function () {
handleLocationError(true, infoWindow, map.getCenter());
});
} else {
// Browser doesn't support Geolocation
handleLocationError(false, infoWindow, map.getCenter());
}
}
function handleLocationError(browserHasGeolocation, infoWindow, pos) {
infoWindow.setPosition(pos);
infoWindow.setContent(browserHasGeolocation ?
'Error: The Geolocation service failed.' :
'متصفحك لا يدعم خدمة تحديد المواقع');
infoWindow.open(map);
}
</script>
<script>
var QRurl;
var MapURL;
var x = document.getElementById("barcode");
function getLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition);
} else {
x.innerHTML = "خدمة تحديد المواقع غير ممكنة في جهازك";
}
}
function showPosition(position) {
x.innerHTML = "Latitude: " + position.coords.latitude +
"<br>Longitude: " + position.coords.longitude;
MapURL = "https://maps.google.com/?q=" + position.coords.latitude + "," + position.coords.longitude;
QRurl = "https://qrickit.com/api/qr.php?d="+MapURL;
document.getElementById("QRcode").src = QRurl;
document.getElementById("shareLocationDiv").style.display = "block";
}
</script>
<script async defer
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDpvi3g0IfJgXnAvlnb5XomGz4FZDPOfsY&callback=initMap">
</script>
<script src='sharemap.js'> </script>
<script src='sharebc.js'> </script>
<div class="footer">
<p>تصميم وتنفيذ علي عبدالعزيز الزبيدي</p>
<br>
<a href="https://twitter.com/AliAAlzubaidi">حسابي على تويتر</a>
</div>
</body>
</html>