Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New Coder
    Join Date
    Dec 2011
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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

  • #2
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Posts
    2,762
    Thanks
    55
    Thanked 517 Times in 514 Posts
    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)

  • #3
    New Coder
    Join Date
    Dec 2011
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #4
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Posts
    2,762
    Thanks
    55
    Thanked 517 Times in 514 Posts
    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?

  • #5
    New Coder
    Join Date
    Dec 2011
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #6
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Posts
    2,762
    Thanks
    55
    Thanked 517 Times in 514 Posts
    oh, I see it now...

    Code:
    navigator.geolocation.watchPosition

  • #7
    New Coder
    Join Date
    Dec 2011
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Oh wow, sorry to have wasted your time with something that ended up being so trivial

    But thank you!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •