navigator.geolocation.getCurrentPosition(displayLocation,displayError)
代表引用navigator下的geolocation,其中一个getCurrentPosition的属性,要把属性得到的值传递到函数中,则需按代码使用。
getCurrentPosition(successHandler, errorHandler, options)有三个参数,后两个可选,第一个必选。分别是成功确定位置会调用函数,确定失败会调用函数,定制地理定位方法
successHandler,成功确定位置后会有位置信息,包括经纬度的coordinate对象
coords.latitude表示纬度
coords。longitude表示经度
errorHandler,失败后会返回error对象,里面会有一个code属性,包含0-3的数,还有一个message属性,或许会有相关信息。