Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 04-29-2012, 07:08 PM   PM User | #1
sambar89
New Coder

 
Join Date: Dec 2011
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
sambar89 is an unknown quantity at this point
Geolocation Problem

High, I'm writing an application that will track users movement and display it on a map but I'm having a problem actually initialising geolocation....

This is the first page (Im using JQuery mobile),

Code:
<div data-role="page"  id="home" data-theme="c"> <!-- Start Home page -->
  <div data-role="content"> </div>
  <div data-role="footer" id="homefoot">
    <div data-role="navbar">
      <ul>
        <li><a href="#tracking" onclick="startTracking()">Strack Tracking</a></li>
        <li><a href="#me">Me</a></li>
        <li><a href="#crowdPage">Crowd</a></li>
      </ul>
    </div>
    <!-- /navbar --> 
  </div>
</div>
<!-- end home page -->
So this is the first page. My plan is when the user clicks the 'Start Tracking' button it will initialise Geolocation and direct them to the 'tracking page' (Which is set up exactly like this page.

This is my JavaScript for it..

Code:
var watcher = null;
var options = {
	enableHighAccuracy: true,
	timeout: 45000
};


function startTracking() {
	
    if(window.navigator.geolocation){
		watcher = navigation.geolocation.watchPosition(successCallback, errorCallback, options);
	}
	else {
		alert('Your browser does not supporr Geolocation');
	}


function successCallback(position) {
	// Insert what to do here
}

function errorCallback(error){
	// Error reports
}

}
Now i know it doesn't actually do anything at the moment, but it should still ask me for my permission to use to find my location right?

But yeah, i get nothing? If someone could show me where I'm going wrong i'd be incredibly grateful.

Also, I've declared the right files in the head of the html so i know that isn't the issue.

Cheers
sambar89 is offline   Reply With Quote
Old 04-29-2012, 07:21 PM   PM User | #2
xelawho
Senior Coder

 
xelawho's Avatar
 
Join Date: Nov 2010
Posts: 2,437
Thanks: 52
Thanked 453 Times in 451 Posts
xelawho will become famous soon enoughxelawho will become famous soon enough
Quote:
Originally Posted by sambar89 View Post
Now i know it doesn't actually do anything at the moment, but it should still ask me for my permission to use to find my location right?
it depends on the browser you are testing in. if you are using Chrome for example, once you have given that page permission once it will always have permission. it appears to be the same with IE. Firefox gives you the option to always give that page permission, give it once, deny it once or deny it always.

I would suggest going into the options panel of whatever browser you are using and resetting the defaults (in Chrome for example, this is in settings>under the hood>content settings>location>manage exceptions)
xelawho is offline   Reply With Quote
Old 04-30-2012, 03:36 AM   PM User | #3
sambar89
New Coder

 
Join Date: Dec 2011
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
sambar89 is an unknown quantity at this point
I'm using Safari and Firefox to test it, both of which i know to have automatic permission disabled.

If i try to run it in Dreamweaver live view i the message;

'Your browser does not supporr Geolocation'

So clearly it must be working, it just doesn't want to work in any of my browsers
sambar89 is offline   Reply With Quote
Old 04-30-2012, 05:18 AM   PM User | #4
xelawho
Senior Coder

 
xelawho's Avatar
 
Join Date: Nov 2010
Posts: 2,437
Thanks: 52
Thanked 453 Times in 451 Posts
xelawho will become famous soon enoughxelawho will become famous soon enough
maybe being that your callback functions are empty, it doesn't get around to asking permission. why not code them and then see what happens?
xelawho is offline   Reply With Quote
Old 04-30-2012, 01:37 PM   PM User | #5
sambar89
New Coder

 
Join Date: Dec 2011
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
sambar89 is an unknown quantity at this point
I coded alerts in them just so something pops up but still nothing. I've gone through countless books and resources but still I'm at a dead end.
sambar89 is offline   Reply With Quote
Old 04-30-2012, 03:11 PM   PM User | #6
xelawho
Senior Coder

 
xelawho's Avatar
 
Join Date: Nov 2010
Posts: 2,437
Thanks: 52
Thanked 453 Times in 451 Posts
xelawho will become famous soon enoughxelawho will become famous soon enough
oh, I see it now...

Code:
navigator.geolocation.watchPosition
xelawho is offline   Reply With Quote
Old 05-01-2012, 06:06 PM   PM User | #7
sambar89
New Coder

 
Join Date: Dec 2011
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
sambar89 is an unknown quantity at this point
Oh wow, sorry to have wasted your time with something that ended up being so trivial

But thank you!
sambar89 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:04 PM.


Advertisement
Log in to turn off these ads.