Geolocation HTML5 enableHighAccuracy True , False or Best Option?

后端 未结 2 767
时光说笑
时光说笑 2020-12-08 23:15

i have a problem about HTML5 geolocation feature. I use the code below to get location data. I use \"enableHighAccuracy: false\" option to work with Cell Based GPS feature.

2条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-08 23:39

    The code mentioned here: http://jsfiddle.net/CvSW4/ did not work for me during error handling.

    The reason is that the error functions accept a parameter named 'position' but use an object in the functions called 'error'.

    function errorCallback_highAccuracy(position) { ... }
    function errorCallback_lowAccuracy(position) { ... }
    

    The solution to fix this was to switch the error methods to accept the input value as a parameter named 'error' and not 'position', since the error callbacks do not accept a position and throw an error object instead.

    function errorCallback_highAccuracy(error) { ... }
    function errorCallback_lowAccuracy(error) { ... }
    

    I mention it here, because I could not post on the resulting example page and also, this is the location where I linked through to find the code sample mentioned above.

提交回复
热议问题