Skip to content

Commit 5a087a8

Browse files
authored
Merge pull request #1136 from Fahim047/Fahim047-js-web-api
➕ Added JS Geolocation Api Cheat Sheet
2 parents 0d98fc7 + 31bb03b commit 5a087a8

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

data/js-web-api.json

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,45 @@
1111
"code": "structuredClone(value, transferables)"
1212
}
1313
]
14+
},
15+
{
16+
"title": "Geolocation API",
17+
"items": [
18+
{
19+
"definition": "Geolocation API সাপোর্ট আছে কিনা চেক করা",
20+
"code": "if (navigator.geolocation) { /* Supported */ }"
21+
},
22+
{
23+
"definition": "ইউজারের বর্তমান অবস্থান পাওয়া",
24+
"code": "navigator.geolocation.getCurrentPosition(success, error, options);"
25+
},
26+
{
27+
"definition": "সফল হলে কলব্যাক ফাংশন",
28+
"code": "function success(position) { const { latitude, longitude } = position.coords; }"
29+
},
30+
{
31+
"definition": "ত্রুটি হ্যান্ডেল করার ফাংশন",
32+
"code": "function error(err) { console.log(`Error: ${err.message}`); }"
33+
},
34+
{
35+
"definition": "অপশনাল অপশন সেট করা",
36+
"code": "const options = { enableHighAccuracy: true, timeout: 5000, maximumAge: 0 };"
37+
},
38+
{
39+
"definition": "ইউজারের অবস্থান পরিবর্তন হলে ট্র্যাক করা (watch)",
40+
"code": "const watchId = navigator.geolocation.watchPosition(success, error, options);"
41+
},
42+
{
43+
"definition": "ট্র্যাকিং বন্ধ করা",
44+
"code": "navigator.geolocation.clearWatch(watchId);"
45+
},
46+
{
47+
"definition": "position অবজেক্টে থাকা প্রপার্টিজ",
48+
"code": "position.coords.latitude, position.coords.longitude, position.coords.accuracy"
49+
}
50+
]
1451
}
52+
53+
1554
]
1655
}

0 commit comments

Comments
 (0)