phonegap中回调的含义是什么

时间:2016-03-29 10:17:28

标签: cordova phonegap-plugins

以Position对象作为参数,将设备的当前位置返回到geolocationSuccess回调。如果有错误,则geolocationError回调将传递一个PositionError对象。

navigator.geolocation.getCurrentPosition(geolocationSuccess,
                                         [geolocationError],
                                         [geolocationOptions]);

1 个答案:

答案 0 :(得分:0)

geolocationSuccess是一个函数,你必须定义,在一切正常的情况下触发,如果出错就会出错

示例:

geolocationSuccess: function () {
  alert ("OK to get geolocation!")
}

geolocationError: function () {
  alert ("Something went wrong on geolocation")
}

navigator.geolocation.getCurrentPosition(geolocationSuccess,
                                         geolocationError,
                                         [geolocationOptions]);