我试图寻找任何讨论,但没有找到答案。在指定的离子文档中
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 行出现错误