×

Discussion Board

Results 1 to 6 of 6

Hybrid 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.

  2. #2
    Nokia Developer Expert
    Join Date
    Mar 2012
    Posts
    65

    Re: MH5 Get Current location

    Hi,

    We've noticed sometimes browsers have troubles with geolocation handling if several handlers are added to navigator.geolocation.
    Because mh5 already adds its own handler to geolocation object, I'd recommend you to use nokia.mh5.geolocation for geolocation handling.
    Let me know whether it solves your problem.

    Br,
    Leo

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

    Re: MH5 Get Current location

    It works with nokia.mh5.geolocation.

    Thanks
    Tom

  4. #4
    Registered User
    Join Date
    Mar 2013
    Posts
    3

    Re: MH5 Get Current location

    Hello,

    I am also interested in getting current coords for the user when the map is loaded so I can add a infobubble with information on his/her current location, would you be so kind and share how you did it?

    Thanks!

  5. #5
    Nokia Developer Expert
    Join Date
    Mar 2012
    Posts
    65

    Re: MH5 Get Current location

    Hi,

    if you use Map component you can access map.position to get latitude & longitude of the user position.

    Br,
    Leo

  6. #6
    Registered User
    Join Date
    Mar 2013
    Posts
    3

    Re: MH5 Get Current location

    Quote Originally Posted by ZieL View Post
    Hi,

    if you use Map component you can access map.position to get latitude & longitude of the user position.

    Br,
    Leo
    Yes, that helped, thanks a lot!

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
  •