以Position对象作为参数,将设备的当前位置返回到geolocationSuccess回调。如果有错误,则geolocationError回调将传递一个PositionError对象。
navigator.geolocation.getCurrentPosition(geolocationSuccess,
[geolocationError],
[geolocationOptions]);
答案 0 :(得分:0)
geolocationSuccess是一个函数,你必须定义,在一切正常的情况下触发,如果出错就会出错
示例:
geolocationSuccess: function () {
alert ("OK to get geolocation!")
}
geolocationError: function () {
alert ("Something went wrong on geolocation")
}
navigator.geolocation.getCurrentPosition(geolocationSuccess,
geolocationError,
[geolocationOptions]);