×

Discussion Board

Results 1 to 6 of 6

Threaded View

  1. #1
    Registered User
    Join Date
    Jan 2013
    Posts
    31

    MH5 Get Current location

    With Chrome, this HTML5 code works fine by itself and with JQuery Mobile, but in my application that uses JQUery Mobile and Nokia HTML5 map, it times out (error code=3).
    With Firefox and IE it works fine in all cases. Also as noted in a separate thread, the "Get current position" icon is not displayed on the map in Chrome.

    Code:
    function get_current_location(){
        if(navigator.geolocation){
            // timeout at 60000 milliseconds (60 seconds)
            var options = {timeout:10000, enableHighAccuracy:false};
            navigator.geolocation.getCurrentPosition(showLocation, errorHandler, options);
            //track_position();
        }else{
            alert("Sorry, browser does not support geolocation!");
        }
        }
        
    function showLocation(position) {
        var latitude = position.coords.latitude;
        var longitude = position.coords.longitude;
        alert("Latitude : " + latitude + " Longitude: " + longitude);
    }    
    
    function errorHandler(err) {
        //   0: unknown error
        //   1: permission denied
        //   2: position unavailable (error response from locaton provider)
        //   3: timed out
        if(err.code == 0)
            alert("Unknown error while getting current location!");
        else if(err.code == 1)
            alert("Access is denied while getting current location!");
        else if( err.code == 2)
            alert("Error: Position is unavailable!");
        else if( err.code == 3)
            alert("Error: Timed out while getting current location!");
    
    }
    Is there any reason why it shouldn't work in Chrome?
    Is there another way to do this?

    Thanks
    Tom
    Last edited by tomgiam; 2013-01-11 at 03:56. Reason: Problem is only with Chrome.

Similar Threads

  1. Get My Current Location Lat, lon
    By HadiDelphi in forum [Archived] Qt Mobility Project
    Replies: 4
    Last Post: 2011-07-06, 06:57
  2. How to get current GPS location
    By videoFx in forum [Archived] Flash Lite on Nokia Devices
    Replies: 2
    Last Post: 2009-04-07, 06:46
  3. Current Location
    By marc_garraway in forum Mobile Java General
    Replies: 7
    Last Post: 2008-10-17, 18:33
  4. Getting Current location
    By amishra in forum Mobile Java General
    Replies: 7
    Last Post: 2008-07-09, 13:25

Posting Permissions

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