Javascript - Save Geolocation Coordinates

I would like to save the coordinates in localstorage so that it shouldn't ask the users every time to allow GPS or Location and a button to clear the localstorage value so it can again ask for coordinates?

Also it should work with Android & IOS Mobile View.

FYI: I am using Praytimes JS to display Muslim prayer times but for each location i have to manually add latitude & longitude of that location.

Below is my code:

<script type="text/javascript" src="[login to view URL]"></script>

<script type="text/javascript">

var x = [login to view URL]("currentlocation");

var geocoder;

if ([login to view URL]) {

[login to view URL](successFunction, errorFunction);


//Get the latitude and the longitude;

function successFunction(position) {

var lat = [login to view URL];

var lng = [login to view URL];

codeLatLng(lat, lng)


function errorFunction(){

$('#currentlocation').html("Geocoder failed");


function initialize() {

geocoder = new [login to view URL]();


function codeLatLng(lat, lng) {

var latlng = new [login to view URL](lat, lng);

[login to view URL]({'latLng': latlng}, function(results, status) {

if (status == [login to view URL]) {

[login to view URL](results)

if (results[1]) {

//formatted address


//find country name

for (var i=0; i<results[0].[login to view URL]; i++) {

for (var b=0;b<results[0].address_components[i].[login to view URL];b++) {

//there are different types that might hold a city admin_area_lvl_1 usually does in come cases looking for sublocality type will be more appropriate

if (results[0].address_components[i].types[b] == "administrative_area_level_2") {

//this is the object you are looking for

city= results[0].address_components[i];





//city data

$('#currentlocation').html(city.short_name + " " + city.long_name)

} else {

$('#currentlocation').html("No results found");


} else {

$('#currentlocation').html("Geocoder failed due to: " + status);





<p id="currentlocation"></p>

<script type="text/javascript" src="[login to view URL]"></script>

<script type="text/javascript">

function loadTable(position) {

[login to view URL]('MWL');

var date = new Date(); // today

var times = [login to view URL](date, [[login to view URL], [login to view URL]]);

var list = ['Fajr', 'Sunrise', 'Dhuhr', 'Asr', 'Maghrib', 'Isha', 'Midnight'];

var html = '<table id="timetable">';

html += '<tr><th colspan="2">'+ [login to view URL]()+ '</th></tr>';

for(var i in list) {

html += '<tr><td>'+ list[i]+ '</td>';

html += '<td>'+ times[list[i].toLowerCase()]+ '</td></tr>';


html += '</table>';

[login to view URL]('table').innerHTML = html;


if ([login to view URL]) {

[login to view URL](loadTable);



Kemahiran: Android, HTML5, iPhone, Javascript, jQuery / Prototaip

Lihat lagi: navigator geolocation, w3c geolocation api, how much to add on printing cost as graphic designer, how do you add money to paypal, how i can save energy creative writing, google maps javascript api geolocation, silverlight save controls coordinates, javascript auto click coordinates, javascript yahoo maps coordinates marker, add runtime input html tag display extjs, php using xml file save database, allow frontend users add products virtuemart, friends myspace add 5000 times day, allow registered users add entry sobi2, javascript calculator clear button

Tentang Majikan:
( 4 ulasan ) salmiya, Kuwait

ID Projek: #17329237

Dianugerahkan kepada:


I am a Software Engineer having 6 years of extensive hands-on experience in Object Oriented Analysis & Design (OOAD) and Database Design and Implementation using Agile, UML, .NET Framework, C#, ASP.NET, ASP.NET MVC, T Lagi

$10 USD dalam 0 hari
(4 Ulasan)

7 pekerja bebas membida secara purata $31 untuk pekerjaan ini

$55 USD dalam sehari
(223 Ulasan)

Dear Hiring Manager, We are very passionate developers with 5+ years of experience in iPhone/iPad, Android application development. Our skills in specially Ios, Android, Objective C, C, C++, MySql, Git, Swift, A Lagi

$25 USD dalam sehari
(13 Ulasan)
$25 USD dalam sehari
(42 Ulasan)

Hello, I have 6+ years experience in PHP, WordPress & Codeigniter. I Read your job description, I'm interesting in your job. we feel that we are suitable for the job. As a senior WordPress expert, I'll be glad Lagi

$55 USD dalam sehari
(9 Ulasan)
$25 USD dalam sehari
(3 Ulasan)
$25 USD dalam sehari
(2 Ulasan)