0

Location in java script

I wanted to write an application like a google map, but nowhere can I find how to get the user's location, can you guys explain?

28th Aug 2020, 2:19 PM
Andrew Selezniov
Andrew Selezniov - avatar
2 Answers
+ 3
You have to use geolocation API in JavaScript. Using that you can get users longitude and latitude. https://developer.mozilla.org/en-US/docs/Web/API/Geolocation_API https://developers.google.com/maps/documentation/javascript/examples/map-geolocation
28th Aug 2020, 2:22 PM
Raj Chhatrala
Raj Chhatrala - avatar
0
If you use geolocation api you must have a secure origin. I have tried but it throw this error. https://code.sololearn.com/WeLcqUnkYx4R/?ref=app
28th Aug 2020, 3:02 PM
Divya Mohan
Divya Mohan - avatar