×

Discussion Board

Results 1 to 8 of 8
  1. #1
    Registered User
    Join Date
    Jul 2012
    Posts
    4

    Unhappy GeoCode without any Result

    Hello,

    I am a little bit confused about the handling of the geocode service.
    Ok let me begin from the beginning:

    I read some tutorials, examples and I have used the api.playground. The normal code for geocoding looks like this:
    Code:
    var searchManager = nokia.places.search.manager;
    
    searchManager.geoCode({
    	searchTerm: "Seeligenstadt, 07580 Seeligenstadt",
    	onComplete: function(responseData, status) {
    			if(status == "OK") {
    				var locations = responseData.location;
    
    				if (locations.length > 0) {
    					// loop through the results here
    				} else {
    					alert("Your search produced no results!");
    				}
    			} else if (requestStatus == "ERROR") {
    				alert("The search request failed.");
    			}
    		}
    	});
    There is no problem if the API found results. But as in this example with the searchTerm "Seeligenstadt, 07580 Seeligenstadt" just nothing happens.
    There is no requestStatus = ERROR or locations.length = 0 to handle this case that the API can't found a result.
    The onComplete function will not be called at all...

    My current solution is a timeout. If the onComplete function wasn't called after a few seconds, I handle this as an non-result. I think that this is a very diry solution and thats why I ask here for help about this.

    Is there any way to handle the "can't found anything" case better?

  2. #2
    Registered User
    Join Date
    Sep 2012
    Posts
    3

    Re: GeoCode without any Result

    Ever find a better solution to this problem? I am having the exact same issue. Seems to be happening when the searchTerm is something that can't be geoCoded.
    Last edited by rbegley; 2012-09-13 at 03:06.

  3. #3
    Registered User
    Join Date
    Jul 2012
    Posts
    4

    Re: GeoCode without any Result

    Nope, not yet. But my solution with the timeout works very well. ;-)

  4. #4
    Registered User
    Join Date
    Sep 2012
    Posts
    3

    Re: GeoCode without any Result

    Could you show a small example? Thanks in advance.

  5. #5
    Registered User
    Join Date
    Jul 2012
    Posts
    4

    Re: GeoCode without any Result

    Yeah sure:
    Code:
    function callbackFunction(response) {
    	if(!response)
    		alert("NO RESULT");
    	else
    		alert("GEOCODE OK");
    }
    
    
    nokia.Settings.set("appId", "--------------------------"); 
    nokia.Settings.set("authenticationToken", "---------------------------");
    var searchManager = nokia.places.search.manager;
    
    // init timeout function
    var searchTimeout = setTimeout(function() {
    	callbackFunction(false);	
    }, 3000);
    
    searchManager.geoCode({
    	searchTerm: searchTerm,
    	onComplete: function(responseData, status) {
    		clearTimeout(searchTimeout);
    		if(status == "OK") {
    			callbackFunction(responseData);
    		} else {
    			callbackFunction(false);
    		}
    	}
    });
    The callback function is the one which will called if geocode was sucessfull OR if the timeout was over.
    If the geocode come into onComplete i stop the timeout function and proceed.

    I hope this helps you ;)

  6. #6
    Registered User
    Join Date
    Sep 2012
    Posts
    3

    Re: GeoCode without any Result

    Exactly what I thought you meant! Thanks for clarifying.

  7. #7
    Registered User
    Join Date
    Jul 2012
    Posts
    4

    Re: GeoCode without any Result

    When you have a better solution, don't hesitate to post it here ;-)

  8. #8
    Registered User
    Join Date
    Dec 2012
    Posts
    1

    Re: GeoCode without any Result

    I'm having this problem, too.

    Is this something we can expect Nokia to fix anytime soon?

Similar Threads

  1. GeoCode
    By Tslv in forum [Archived] Map Image API for HTTP
    Replies: 11
    Last Post: 2013-04-24, 09:59
  2. Trying to geocode and add markers from array of addresses
    By MGunner in forum General Development Questions
    Replies: 4
    Last Post: 2011-11-23, 16:02
  3. About the result of sending SMS
    By tuzai in forum PC Suite API and PC Connectivity SDK
    Replies: 0
    Last Post: 2003-07-14, 04:07
  4. drawImage(img, -10, -10, 0); with different result ?!
    By ph0x in forum Mobile Java General
    Replies: 1
    Last Post: 2003-02-12, 12:57

Posting Permissions

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