作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
{ -6ren">
initMap(): Promise<any> {
this.mapInitialised = true;//part 1
return new Promise((resolve) => {
this.geolocation.getCurrentPosition().then((position) => {// Part 2
let latLng = new google.maps.LatLng(position.coords.latitude,position.coords.longitude);
let mapOptions = {
center: latLng,
zoom: 15,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
this.map = new google.maps.Map(this.mapElement, mapOptions);
resolve(true);
});
});
}
最佳答案
您需要捕获错误并对其进行处理。为此,需要添加错误捕获。解决问题的代码在这里:
initMap(): Promise<any> {
this.mapInitialised = true;//part 1
return new Promise((resolve) => {
this.geolocation.getCurrentPosition().then(
(position) => {// Part 2
let latLng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
let mapOptions = {
center: latLng,
zoom: 15,
mapTypeId: google.maps.MapTypeId.ROADMAP;
}
this.map = new google.maps.Map(this.mapElement, mapOptions);
resolve(true);
},
// Here is the error catching that needs to be added
err =>{
console.log(' Error : ' + JSON.stringify(error));
});
});
}
关于google-maps - ionic 2 map 加载 "Uncaught (in promise): [object PositionError]",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43977280/
有时当运行服务命令时,会出现此错误,几次后它会自动消失: 我必须指出,此错误仅发生在加载谷歌地图的 map 页面上。 Uncaught (in promise): [object PositionEr
initMap(): Promise { this.mapInitialised = true;//part 1 return new Promise((resolve) => {
我正在使用 Geolocation HTML5 API。我正在使用 angular.js。我写了一个小工厂函数 myApp.factory("GeolocationService", ['$q', '
我是一名优秀的程序员,十分优秀!