Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User fonurr's Avatar
    Join Date
    Oct 2011
    Posts
    34
    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 Moderator isalento's Avatar
    Join Date
    Jun 2008
    Location
    Tampere
    Posts
    831
    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 fonurr's Avatar
    Join Date
    Oct 2011
    Posts
    34
    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 Moderator isalento's Avatar
    Join Date
    Jun 2008
    Location
    Tampere
    Posts
    831
    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 Web Runtime
    Replies: 3
    Last Post: 2011-05-30, 22:27
  4. How use Geolocation api in symbian
    By soni_neeraj in forum Symbian C++
    Replies: 5
    Last Post: 2010-08-05, 08:17
  5. Geolocation on browser
    By anushshetty in forum Symbian Web Runtime
    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
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved