3

I'm developing a website which will use the geolocation. The fact is I would like to set a timeout if the geolocation system doesn't answer... I'm using javascript to get the position.

And after check if there is or not a geolocation system,

I used this javascript function :

geoloc.getCurrentPosition(successCallback, errorCallbak, {timeout: 5000});

I set the timeout to 5sec. But It doesn't work at all ... I never get a timeout error..

Does anyone have an idea about that?

Thanks

Guillaume le Floch
  • 1,083
  • 2
  • 11
  • 23
  • what does your errorCallback look like? – Paul Aug 28 '12 at 17:22
  • I set a switch case with all the possible error.. But I add a console.log and my code is still waiting the geolocation response ... it never goes to the error callback ... – Guillaume le Floch Aug 28 '12 at 17:24
  • 1
    This should help : http://stackoverflow.com/questions/3397585/navigator-geolocation-getcurrentposition-sometimes-works-sometimes-doesnt – Paul Aug 28 '12 at 17:31
  • So I added a timeout and it works! :) but the fact is, I get two responses, one from the timeout I just set and the response from getCurrentPosition that after a certain amount of time give me the answer ... Is there a way to stop the getCurrentPosition call. – Guillaume le Floch Aug 28 '12 at 17:59

0 Answers0