Comments (1)
@twocucao
Sorry 回复慢了。
应该是这样的。 我试了下搜「人民广场」出来了几个搜索结果,有些结果搜索后,回调里面的 pois
是空的,所以报错了。你可以这样加个判断。
onSearchResult(pois) {
let latSum = 0;
let lngSum = 0;
// **** 这里加个判断 ****
if (pois.length > 0) {
pois.forEach(poi => {
let {lng, lat} = poi;
lngSum += lng;
latSum += lat;
this.markers.push([poi.lng, poi.lat]);
});
let center = {
lng: lngSum / pois.length,
lat: latSum / pois.length
};
this.mapCenter = [center.lng, center.lat];
}
}
from vue-amap.
Related Issues (20)
- 高德地图API 12月更新加入了密匙 HOT 2
- 使用密钥转发之后,getCurrentPosition()这个方法失效了
- 高德离线地图可以使用吗 HOT 1
- 怎么使用高德的自定义地图? HOT 1
- 地图搜索多了一个参数s=rsv3
- 示例怎么都没了,这对于初次使用的很不友好啊!!更新换带了个寂寞啊 HOT 1
- 文档示例中引用在线vue资源报404 如图
- 高德地图加载不出来,有高德的logo,但地图一片空白 HOT 2
- 使用高德版本 v:2.0 之后 绑定evenet 报请等待地图加载完毕之后再进行绑定事件错误
- 使用高德版本 v:2.0 之后 绑定evenet 报请等待地图加载完毕之后再进行绑定事件错误 HOT 5
- USER_DAILY_QUERY_OVER_LIMIT
- English version on AMap v2.0
- 自定义地图样式不显示
- 使用avue-map搜索时报错INVALID_USER_SCODE
- 关于searchBox的疑问 HOT 1
- 更换标记点报错
- 关于高德平台自2021年12月02日升级,升级之后所申请的 key 必须配备安全密钥 jscode 一起使用
- 还有人维护吗
- 通过spacedesk投屏后,无法手势缩放!!!!
- 鼠标滚轮缩放比例太小了,滚了半天才到底如何配置大一点
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vue-amap.