×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Oct 2011
    Posts
    34

    Error on Geolocation

    Hello everybody,

    var a= nokia.device.load("geolocation");

    works fine when the user permits the program to retrieve "geographic information" but when the user does not permit the program, it gives an "undefined" error. what i would like to do is the following, please help me:

    if(the user permits to get "geographic information"){
    var a = nokia.device.load("geolocation");
    a.getCurrentPosition(...);
    }
    else{
    alert("permission denied");
    }

  2. #2
    Nokia Developer Expert
    Join Date
    Jun 2008
    Location
    Tampere
    Posts
    833

    Re: Error on Geolocation

    Hi and welcome to forum!

    You can use try-catch when loading geolocation service. If loading fails an error is thrown.

    Code:
    /* 
     * Remember to add Platform Services 2.0 lib into your project 
     */
    var geolocation_so = null;
    	 
    /*
     * Initializes geolocation service object
     */
    function initGeolocation(){
    	
    try {
           geolocation_so = nokia.device.load("geolocation");
    } 
    catch (e) {
           if (e.message == "security access check failed") {
                    alert("Access to location service was not granted");
           }
           else {
                    alert(e);
           }
       }
    }
    -Ilkka

  3. #3
    Registered User
    Join Date
    Oct 2011
    Posts
    34

    Re: Error on Geolocation

    Thanks for your reply isalento, that's actually what i do to solve the problem, it didn't satisfy me, but i guess it is the only way it could be handled.

  4. #4
    Nokia Developer Expert
    Join Date
    Jun 2008
    Location
    Tampere
    Posts
    833

    Re: Error on Geolocation

    You are right, it is not neat way to do it, but should have widest compatibility.

    Since Browser 7.3 / WRT 7.3 a new API was introduced where you can query access to all of the needed services at once.
    http://www.developer.nokia.com/Commu...curity_prompts
    For location you can use following identifier: "Service.Location": "ILocation"

    -Ilkka

Similar Threads

  1. Geolocation problem on N8
    By sangramp@cybage.com in forum [Archived] Flash Lite on Nokia Devices
    Replies: 3
    Last Post: 2011-07-07, 22:27
  2. Geolocation API support for S40 Web?
    By manzar_alam12 in forum Nokia Asha Web Apps
    Replies: 6
    Last Post: 2011-06-10, 11:01
  3. fast geolocation
    By twtb in forum Symbian
    Replies: 3
    Last Post: 2011-05-30, 22:27
  4. How use Geolocation api in symbian
    By soni_neeraj in forum Symbian
    Replies: 5
    Last Post: 2010-08-05, 08:17
  5. Geolocation on browser
    By anushshetty in forum Symbian
    Replies: 1
    Last Post: 2010-07-01, 16:18

Posting Permissions

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