小编Cri*_*ion的帖子

预期参数 1-3,但得到 0

错误参数获取离子 4 的当前位置

我的形象

我试图寻找任何讨论,但没有找到答案。在指定的离子文档中

this.geolocation.getCurrentPosition().then((resp) => {
    // resp.coords.latitude
    // resp.coords.longitude
}).catch((error) => {
    console.log('Error getting location', error);
});
Run Code Online (Sandbox Code Playgroud)

我的代码是这样的

this.geolocation.getCurrentPosition().then(pos => {
   let latLng = new google.maps.latLng(pos.coords.latitude, pos.coords.longitude);
   this.map.setCenter(latLng);
   this.map.setZoom(15);
}).catch(err => {
   console.log(err);
});
Run Code Online (Sandbox Code Playgroud)

当我悬停时。我收到消息

(method) Geolocation.getCurrentPosition(successCallback: PositionCallback, errorCallback?: PositionErrorCallback, options?: PositionOptions): void
Expected 1-3 arguments, but got 0.ts(2554)
lib.dom.d.ts(5389, 24): An argument for 'successCallback' was not provided.
Run Code Online (Sandbox Code Playgroud)

我模仿了YouTube上的教程https://www.youtube.com/watch?v=Ru57AkoWMJ4&t=199s

我在他的第 43 行出现错误

angular ionic4

0
推荐指数
1
解决办法
1091
查看次数

标签 统计

angular ×1

ionic4 ×1