Completed

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

$('#currentlocation').html(results[0].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];

break;

}

}

}

//city data

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

} else {

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

}

} else {

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

}

});

}

</script>

<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);

}

</script>

Compétences : Android, HTML5, iPhone, Javascript, jQuery / Prototype

en voir plus : 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

Concernant l'employeur :
( 4 commentaires ) salmiya, Kuwait

Nº du projet : #17329237

Décerné à:

zmgroup

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 Plus

%selectedBids___i_sum_sub_7% %project_currencyDetails_sign_sub_8% USD en 0 jours
(4 Commentaires)
3.1

7 freelance font une offre moyenne de $31 pour ce travail

%bids___i_sum_sub_32% %project_currencyDetails_sign_sub_33% USD en 1 jour
(223 Commentaires)
8.5
amitbanerjee2812

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 Plus

%bids___i_sum_sub_32% %project_currencyDetails_sign_sub_33% USD en 1 jour
(13 Commentaires)
4.9
%bids___i_sum_sub_32% %project_currencyDetails_sign_sub_33% USD en 1 jour
(42 Commentaires)
5.0
rohit554ITHUB

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 Plus

%bids___i_sum_sub_32% %project_currencyDetails_sign_sub_33% USD en 1 jour
(9 Commentaires)
3.1
%bids___i_sum_sub_32% %project_currencyDetails_sign_sub_33% USD en 1 jour
(3 Commentaires)
1.9
%bids___i_sum_sub_32% %project_currencyDetails_sign_sub_33% USD en 1 jour
(2 Commentaires)
0.8